Skip to content

Commit 898e50e

Browse files
authored
Merge pull request swiftlang#82 from akyrtzi/fix-pointer-cast-errors
[RawSyntax] Fix pointer cast compiler errors
2 parents a12f46d + cd37283 commit 898e50e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: Sources/SwiftSyntax/RawSyntax.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fileprivate func castElementAs<T>(_ ptr: DataElementPtr) -> UnsafePointer<T> {
3232

3333
fileprivate func castElementAs<T>(_ ptr: MutableDataElementPtr) -> UnsafeMutablePointer<T> {
3434
assert(MemoryLayout<T>.alignment <= MemoryLayout<RawSyntaxDataElement>.alignment)
35-
return UnsafeMutablePointer<T>(ptr)
35+
return UnsafeMutableRawPointer(ptr).assumingMemoryBound(to: T.self)
3636
}
3737

3838
/// Calculates the number of `RawSyntaxDataElement`s needed to fit the given
@@ -146,7 +146,7 @@ fileprivate struct TokenData {
146146
if hasCustomText {
147147
// Copy the full token text, including trivia.
148148
let startOffset = Int(cnode.range.offset)
149-
var charPtr = UnsafeMutablePointer<UInt8>(curPtr)
149+
var charPtr = UnsafeMutableRawPointer(curPtr).assumingMemoryBound(to: UInt8.self)
150150
let utf8 = source.utf8
151151
let begin = utf8.index(utf8.startIndex, offsetBy: startOffset)
152152
let end = utf8.index(begin, offsetBy: Int(cnode.range.length))

0 commit comments

Comments
 (0)