mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Strict memory safety] Adjust "unsafe" location for string interpolations
String interpolations can end up being unsafe in the call to appendInterpolation when it's provided with unsafe types. Move the location of the proposed "unsafe" out to the string interpolation itself in these cases, which properly suppresses the warning. Fixes rdar://151799777.
This commit is contained in:
@@ -376,3 +376,9 @@ protocol CustomAssociated: Associated { }
|
||||
extension SomeClass: CustomAssociated {
|
||||
typealias Associated = SomeClassWrapper // expected-note{{unsafe type 'SomeClass.Associated' (aka 'SomeClassWrapper') cannot satisfy safe associated type 'Associated'}}
|
||||
}
|
||||
|
||||
func testInterpolation(ptr: UnsafePointer<Int>) {
|
||||
_ = "Hello \(unsafe ptr)" // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{7-7=unsafe }}
|
||||
// expected-note@-1{{reference to unsafe type 'UnsafePointer<Int>'}}
|
||||
// expected-note@-2{{argument #0 in call to instance method 'appendInterpolation' has unsafe type 'UnsafePointer<Int>'}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user