File tree 2 files changed +15
-0
lines changed
lib/ASTGen/Sources/ASTGen
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 {
552
552
override func visit( _ node: UnsafeExprSyntax ) -> ExprSyntax {
553
553
return node. expression. with ( \. leadingTrivia, node. leadingTrivia)
554
554
}
555
+
556
+ override func visit( _ node: ForStmtSyntax ) -> StmtSyntax {
557
+ return StmtSyntax ( node. with ( \. unsafeKeyword, nil ) )
558
+ }
555
559
}
556
560
557
561
extension SyntaxProtocol {
Original file line number Diff line number Diff line change 9
9
// CHECK: #endif
10
10
@unsafe public func getIntUnsafely( ) -> Int { 0 }
11
11
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
+
12
21
// CHECK: @inlinable public func useUnsafeCode()
13
22
@inlinable public func useUnsafeCode( ) {
14
23
// CHECK-NOT: unsafe
15
24
print ( unsafe getIntUnsafely( ) )
25
+
26
+ for unsafe _ in SequenceWithUnsafeIterator ( ) { }
16
27
}
17
28
18
29
// CHECK: public protocol P
You can’t perform that action at this time.
0 commit comments