Skip to content

Commit c7f9f2e

Browse files
committed
Rename "Unsafe" diagnostic group to "StrictMemorySafety"
This lines up with the feature name and is more consistent. Thank you, Anthony, for the suggestion.
1 parent 05447ce commit c7f9f2e

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

include/swift/AST/DiagnosticGroups.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
GROUP(no_group, "")
2424

2525
GROUP(DeprecatedDeclaration, "deprecated-declaration.md")
26-
GROUP(Unsafe, "unsafe.md")
26+
GROUP(StrictMemorySafety, "strict-memory-safety.md")
2727
GROUP(UnknownWarningGroup, "unknown-warning-group.md")
2828
GROUP(PreconcurrencyImport, "preconcurrency-import.md")
2929
GROUP(StrictLanguageFeatures, "strict-language-features.md")

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ ERROR(experimental_not_supported_in_production,none,
590590
"experimental feature '%0' cannot be enabled in production compiler",
591591
(StringRef))
592592

593-
GROUPED_WARNING(command_line_conflicts_with_strict_safety,Unsafe,none,
593+
GROUPED_WARNING(command_line_conflicts_with_strict_safety,StrictMemorySafety,none,
594594
"'%0' is not memory-safe and should not be combined with "
595595
"strict memory safety checking", (StringRef))
596596

include/swift/AST/DiagnosticsSema.def

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8196,7 +8196,7 @@ NOTE(note_use_of_unsafe_conformance_is_unsafe,none,
81968196
NOTE(note_unsafe_storage,none,
81978197
"%kindbase1 involves unsafe type %2", (bool, const ValueDecl *, Type))
81988198

8199-
GROUPED_WARNING(decl_unsafe_storage,Unsafe,none,
8199+
GROUPED_WARNING(decl_unsafe_storage,StrictMemorySafety,none,
82008200
"%kindbase0 has storage involving unsafe types",
82018201
(const Decl *))
82028202
NOTE(decl_storage_mark_unsafe,none,
@@ -8206,11 +8206,11 @@ NOTE(decl_storage_mark_safe,none,
82068206
"add '@safe' if this type encapsulates the unsafe storage in "
82078207
"a safe interface", ())
82088208

8209-
GROUPED_WARNING(unsafe_superclass,Unsafe,none,
8209+
GROUPED_WARNING(unsafe_superclass,StrictMemorySafety,none,
82108210
"%kindbase0 has superclass involving unsafe type %1",
82118211
(const ValueDecl *, Type))
82128212

8213-
GROUPED_WARNING(conformance_involves_unsafe,Unsafe,none,
8213+
GROUPED_WARNING(conformance_involves_unsafe,StrictMemorySafety,none,
82148214
"conformance of %0 to %kind1 involves unsafe code; use '@unsafe' to "
82158215
"indicate that the conformance is not memory-safe",
82168216
(Type, const ValueDecl *))
@@ -8221,15 +8221,15 @@ NOTE(note_type_witness_unsafe,none,
82218221
"unsafe type %0 cannot satisfy safe associated type %1",
82228222
(Type, DeclName))
82238223

8224-
GROUPED_WARNING(override_safe_with_unsafe,Unsafe,none,
8224+
GROUPED_WARNING(override_safe_with_unsafe,StrictMemorySafety,none,
82258225
"override of safe %0 with unsafe %0", (DescriptiveDeclKind))
82268226

8227-
GROUPED_WARNING(preconcurrency_import_unsafe,Unsafe,none,
8227+
GROUPED_WARNING(preconcurrency_import_unsafe,StrictMemorySafety,none,
82288228
"@preconcurrency import is not memory-safe because it can silently "
82298229
"introduce data races", ())
8230-
GROUPED_WARNING(unsafe_without_unsafe,Unsafe,none,
8230+
GROUPED_WARNING(unsafe_without_unsafe,StrictMemorySafety,none,
82318231
"expression uses unsafe constructs but is not marked with 'unsafe'", ())
8232-
GROUPED_WARNING(for_unsafe_without_unsafe,Unsafe,none,
8232+
GROUPED_WARNING(for_unsafe_without_unsafe,StrictMemorySafety,none,
82338233
"for-in loop uses unsafe constructs but is not marked with 'unsafe'", ())
82348234
WARNING(no_unsafe_in_unsafe,none,
82358235
"no unsafe operations occur within 'unsafe' expression", ())

test/Unsafe/safe.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ func testUnsafeAsSequenceForEach() {
9191

9292
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{12-12=unsafe }}
9393
for _ in uas { } // expected-note{{conformance}}
94-
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{7-7=unsafe }}
94+
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{7-7=unsafe }}
9595

96-
for _ in unsafe uas { } // expected-warning{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{7-7=unsafe }}
96+
for _ in unsafe uas { } // expected-warning{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{7-7=unsafe }}
9797

9898
for unsafe _ in unsafe uas { } // okay
9999
}

test/Unsafe/safe_argument_suppression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class NotSafeSubclass: NotSafe {
3636
_ = NotSafe[ns]
3737
NotSafe.doStatically(NotSafe.self)
3838

39-
ns.stillUnsafe() // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
39+
ns.stillUnsafe() // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
4040
// expected-note@-1{{reference to parameter 'ns' involves unsafe type 'NotSafe'}}
4141
// expected-note@-2{{reference to unsafe instance method 'stillUnsafe()'}}
4242
}

test/Unsafe/unsafe-suppression.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class C {
2121

2222
class D1: C { // expected-note{{make class 'D1' @unsafe to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
2323
@unsafe
24-
override func method() { } // expected-warning{{override of safe instance method with unsafe instance method [Unsafe]}}
24+
override func method() { } // expected-warning{{override of safe instance method with unsafe instance method [StrictMemorySafety]}}
2525
}
2626

2727
@unsafe class D2: C {
@@ -34,7 +34,7 @@ protocol P {
3434
}
3535

3636
struct S1: P {
37-
// expected-warning@-1{{conformance of 'S1' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{12-12=@unsafe }}
37+
// expected-warning@-1{{conformance of 'S1' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{12-12=@unsafe }}
3838
@unsafe
3939
func protoMethod() { } // expected-note{{unsafe instance method 'protoMethod()' cannot satisfy safe requirement}}
4040
}
@@ -48,7 +48,7 @@ struct S2: P {
4848
struct S3 { }
4949

5050
extension S3: P {
51-
// expected-warning@-1{{conformance of 'S3' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{15-15=@unsafe }}
51+
// expected-warning@-1{{conformance of 'S3' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{15-15=@unsafe }}
5252
@unsafe
5353
func protoMethod() { } // expected-note{{unsafe instance method 'protoMethod()' cannot satisfy safe requirement}}
5454
}
@@ -116,12 +116,12 @@ extension UnsafeOuter {
116116
var yieldUnsafe: Int {
117117
_read {
118118
@unsafe let x = 5
119-
yield x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
119+
yield x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
120120
// expected-note@-1{{reference to unsafe let 'x'}}
121121
}
122122
_modify {
123123
@unsafe var x = 5
124-
yield &x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
124+
yield &x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
125125
// expected-note@-1{{reference to unsafe var 'x'}}
126126
}
127127
}
@@ -142,9 +142,9 @@ struct UnsafeSequence: @unsafe IteratorProtocol, @unsafe Sequence {
142142
}
143143

144144
func forEachLoop(us: UnsafeSequence) {
145-
for _ in us { } // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{12-12=unsafe }}
145+
for _ in us { } // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{12-12=unsafe }}
146146
// expected-note@-1{{@unsafe conformance of 'UnsafeSequence' to protocol 'Sequence' involves unsafe code}}
147-
// expected-warning@-2{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
147+
// expected-warning@-2{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
148148
for _ in unsafe us { }
149-
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
149+
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
150150
}

test/Unsafe/unsafe.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protocol P {
1616
@unsafe func g()
1717
}
1818

19-
struct XP: P { // expected-warning{{conformance of 'XP' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{12-12=@unsafe }}
19+
struct XP: P { // expected-warning{{conformance of 'XP' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{12-12=@unsafe }}
2020
@unsafe func f() { } // expected-note{{unsafe instance method 'f()' cannot satisfy safe requirement}}
2121
@unsafe func g() { }
2222
}
@@ -30,7 +30,7 @@ protocol Ptrable2 {
3030
}
3131

3232
extension HasAPointerType: Ptrable2 { } // expected-note{{unsafe type 'HasAPointerType.Ptr' (aka 'PointerType') cannot satisfy safe associated type 'Ptr'}}
33-
// expected-warning@-1{{conformance of 'HasAPointerType' to protocol 'Ptrable2' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{28-28=@unsafe }}
33+
// expected-warning@-1{{conformance of 'HasAPointerType' to protocol 'Ptrable2' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{28-28=@unsafe }}
3434

3535
struct UnsafeXP: @unsafe P {
3636
@unsafe func f() { }
@@ -44,7 +44,7 @@ protocol MultiP {
4444

4545
struct ConformsToMultiP { }
4646

47-
// expected-warning@+1{{conformance of 'ConformsToMultiP' to protocol 'MultiP' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{29-29=@unsafe }}
47+
// expected-warning@+1{{conformance of 'ConformsToMultiP' to protocol 'MultiP' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{29-29=@unsafe }}
4848
extension ConformsToMultiP: MultiP {
4949
// expected-note@-1{{unsafe type 'UnsafeSuper' cannot satisfy safe associated type 'Ptr'}}
5050
@unsafe func f() -> UnsafeSuper {
@@ -74,7 +74,7 @@ class Super {
7474
}
7575

7676
class Sub: Super { // expected-note{{make class 'Sub' @unsafe to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
77-
@unsafe override func f() { } // expected-warning{{override of safe instance method with unsafe instance method [Unsafe]}}
77+
@unsafe override func f() { } // expected-warning{{override of safe instance method with unsafe instance method [StrictMemorySafety]}}
7878
@unsafe override func g() { }
7979
}
8080

@@ -117,7 +117,7 @@ class ExclusivityChecking {
117117
func f() { }
118118
};
119119

120-
// expected-warning@+1{{class 'UnsafeSub' has superclass involving unsafe type 'UnsafeSuper' [Unsafe]}}{{1-1=@unsafe }}
120+
// expected-warning@+1{{class 'UnsafeSub' has superclass involving unsafe type 'UnsafeSuper' [StrictMemorySafety]}}{{1-1=@unsafe }}
121121
class UnsafeSub: UnsafeSuper { }
122122

123123
// -----------------------------------------------------------------------
@@ -129,13 +129,13 @@ struct BufferThingy<T> {
129129
}
130130

131131
func testConstruction() {
132-
let _ = BufferThingy<Int>(count: 17) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{11-11=unsafe }}
132+
let _ = BufferThingy<Int>(count: 17) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{11-11=unsafe }}
133133
// expected-note@-1{{reference to unsafe initializer 'init(count:)'}}
134134
}
135135

136136
func testRHS(b: Bool, x: Int) {
137137
@unsafe let limit = 17
138-
if b && x > limit { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{6-6=unsafe }}
138+
if b && x > limit { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{6-6=unsafe }}
139139
// expected-note@-1{{reference to unsafe let 'limit'}}
140140
}
141141
}
@@ -171,7 +171,7 @@ typealias SuperUnsafe = UnsafeSuper
171171

172172
@unsafe typealias SuperUnsafe2 = UnsafeSuper
173173

174-
// expected-warning@+3{{enum 'HasUnsafeThings' has storage involving unsafe types [Unsafe]}}
174+
// expected-warning@+3{{enum 'HasUnsafeThings' has storage involving unsafe types [StrictMemorySafety]}}
175175
// expected-note@+2{{add '@unsafe' if this type is also unsafe to use}}{{1-1=@unsafe }}
176176
// expected-note@+1{{add '@safe' if this type encapsulates the unsafe storage in a safe interface}}{{1-1=@safe }}
177177
enum HasUnsafeThings {
@@ -181,7 +181,7 @@ case one(UnsafeSuper) // expected-note{{enum case 'one' involves unsafe type 'Un
181181
case two(UnsafeSuper) // expected-note{{enum case 'two' involves unsafe type 'UnsafeSuper'}}
182182
}
183183

184-
// expected-warning@+3{{class 'ClassWithUnsafeStorage' has storage involving unsafe types [Unsafe]}}
184+
// expected-warning@+3{{class 'ClassWithUnsafeStorage' has storage involving unsafe types [StrictMemorySafety]}}
185185
// expected-note@+2{{add '@unsafe' if this type is also unsafe to use}}{{1-1=@unsafe }}
186186
// expected-note@+1{{add '@safe' if this type encapsulates the unsafe storage in a safe interface}}{{1-1=@safe }}
187187
class ClassWithUnsafeStorage {

0 commit comments

Comments
 (0)