File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
lib/ASTGen/Sources/ASTGen Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -552,6 +552,10 @@ fileprivate class RemoveUnsafeExprSyntaxRewriter: SyntaxRewriter {
552552 override func visit( _ node: UnsafeExprSyntax ) -> ExprSyntax {
553553 return node. expression. with ( \. leadingTrivia, node. leadingTrivia)
554554 }
555+
556+ override func visit( _ node: ForStmtSyntax ) -> StmtSyntax {
557+ return StmtSyntax ( node. with ( \. unsafeKeyword, nil ) )
558+ }
555559}
556560
557561extension SyntaxProtocol {
Original file line number Diff line number Diff line change 99// CHECK: #endif
1010@unsafe public func getIntUnsafely( ) -> Int { 0 }
1111
12+ public struct UnsafeIterator : @unsafe IteratorProtocol {
13+ @unsafe public mutating func next( ) -> Int ? { nil }
14+ }
15+
16+ public struct SequenceWithUnsafeIterator : Sequence {
17+ public init ( ) { }
18+ public func makeIterator( ) -> UnsafeIterator { UnsafeIterator ( ) }
19+ }
20+
1221// CHECK: @inlinable public func useUnsafeCode()
1322@inlinable public func useUnsafeCode( ) {
1423 // CHECK-NOT: unsafe
1524 print ( unsafe getIntUnsafely( ) )
25+
26+ for unsafe _ in SequenceWithUnsafeIterator ( ) { }
1627}
1728
1829// CHECK: public protocol P
You can’t perform that action at this time.
0 commit comments