Skip to content

[RawSyntax] Fix pointer cast compiler errors #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/RawSyntax.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fileprivate func castElementAs<T>(_ ptr: DataElementPtr) -> UnsafePointer<T> {

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

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