Skip to content

Commit c94d1cd

Browse files
committed
[Type checker] The term "layout constraint" is confusing; don't use it.
Within the compiler, we use the term "layout constraint" for any constraint that affects the layout of a type parameter that has that constraint. However, the only user-visible constraint is "AnyObject", and calling that a layout constraint is confusing. Drop the term "layout" from diagnostics. Fixes rdar://problem/35295372.
1 parent 295c7f3 commit c94d1cd

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,13 +1733,13 @@ NOTE(superclass_redundancy_here,none,
17331733
(unsigned, Type, Type))
17341734

17351735
ERROR(conflicting_layout_constraints,none,
1736-
"%select{generic parameter |protocol |}0%1 has conflicting layout "
1736+
"%select{generic parameter |protocol |}0%1 has conflicting "
17371737
"constraints %2 and %3",
17381738
(unsigned, Type, LayoutConstraint, LayoutConstraint))
17391739
WARNING(redundant_layout_constraint,none,
1740-
"redundant layout constraint %0 : %1", (Type, LayoutConstraint))
1740+
"redundant constraint %0 : %1", (Type, LayoutConstraint))
17411741
NOTE(previous_layout_constraint, none,
1742-
"layout constraint constraint %1 : %2 %select{written here|implied here|"
1742+
"constraint %1 : %2 %select{written here|implied here|"
17431743
"inferred from type here}0",
17441744
(unsigned, Type, LayoutConstraint))
17451745

test/Compatibility/anyobject_class.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// RUN: not %target-swift-frontend -tyepcheck -swift-version 5
44

55
protocol P : class, AnyObject { } // expected-warning{{redundant inheritance from 'AnyObject' and Swift 3 'class' keyword}}{{14-21=}}
6-
// expected-warning@-1{{redundant layout constraint 'Self' : 'AnyObject'}}
7-
// expected-note@-2{{layout constraint constraint 'Self' : 'AnyObject' written here}}
6+
// expected-warning@-1{{redundant constraint 'Self' : 'AnyObject'}}
7+
// expected-note@-2{{constraint 'Self' : 'AnyObject' written here}}

test/attr/attr_specialize.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,16 @@ func funcWithForbiddenSpecializeRequirement<T>(_ t: T) {
161161
}
162162

163163
@_specialize(where T: _Trivial(32), T: _Trivial(64), T: _Trivial, T: _RefCountedObject)
164-
// expected-error@-1{{generic parameter 'T' has conflicting layout constraints '_Trivial(64)' and '_Trivial(32)'}}
165-
// expected-error@-2{{generic parameter 'T' has conflicting layout constraints '_RefCountedObject' and '_Trivial(32)'}}
166-
// expected-warning@-3{{redundant layout constraint 'T' : '_Trivial'}}
167-
// expected-note@-4 3{{layout constraint constraint 'T' : '_Trivial(32)' written here}}
164+
// expected-error@-1{{generic parameter 'T' has conflicting constraints '_Trivial(64)' and '_Trivial(32)'}}
165+
// expected-error@-2{{generic parameter 'T' has conflicting constraints '_RefCountedObject' and '_Trivial(32)'}}
166+
// expected-warning@-3{{redundant constraint 'T' : '_Trivial'}}
167+
// expected-note@-4 3{{constraint 'T' : '_Trivial(32)' written here}}
168168
@_specialize(where T: _Trivial, T: _Trivial(64))
169-
// expected-warning@-1{{redundant layout constraint 'T' : '_Trivial'}}
170-
// expected-note@-2 1{{layout constraint constraint 'T' : '_Trivial(64)' written here}}
169+
// expected-warning@-1{{redundant constraint 'T' : '_Trivial'}}
170+
// expected-note@-2 1{{constraint 'T' : '_Trivial(64)' written here}}
171171
@_specialize(where T: _RefCountedObject, T: _NativeRefCountedObject)
172-
// expected-warning@-1{{redundant layout constraint 'T' : '_RefCountedObject'}}
173-
// expected-note@-2 1{{layout constraint constraint 'T' : '_NativeRefCountedObject' written here}}
172+
// expected-warning@-1{{redundant constraint 'T' : '_RefCountedObject'}}
173+
// expected-note@-2 1{{constraint 'T' : '_NativeRefCountedObject' written here}}
174174
@_specialize(where Array<T> == Int) // expected-error{{Only requirements on generic parameters are supported by '_specialize' attribute}}
175175
// expected-error@-1{{generic signature requires types 'Array<T>' and 'Int' to be the same}}
176176
@_specialize(where T.Element == Int) // expected-error{{Only requirements on generic parameters are supported by '_specialize' attribute}}
@@ -183,9 +183,9 @@ public protocol Proto: class {
183183

184184
@_specialize(where T: _RefCountedObject)
185185
@_specialize(where T: _Trivial)
186-
// expected-error@-1{{generic parameter 'T' has conflicting layout constraints '_Trivial' and '_NativeClass'}}
186+
// expected-error@-1{{generic parameter 'T' has conflicting constraints '_Trivial' and '_NativeClass'}}
187187
@_specialize(where T: _Trivial(64))
188-
// expected-error@-1{{generic parameter 'T' has conflicting layout constraints '_Trivial(64)' and '_NativeClass'}}
188+
// expected-error@-1{{generic parameter 'T' has conflicting constraints '_Trivial(64)' and '_NativeClass'}}
189189
public func funcWithABaseClassRequirement<T>(t: T) -> Int where T: C1 {
190190
return 44444
191191
}

test/decl/protocol/req/class.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ protocol P1 : class { }
55
protocol P2 : class, class { } // expected-error{{redundant 'class' requirement}}{{20-27=}}
66

77
protocol P3 : P2, class { } // expected-error{{'class' must come first in the requirement list}}{{15-15=class, }}{{17-24=}}
8-
// expected-warning@-1 {{redundant layout constraint 'Self' : 'AnyObject'}}
9-
// expected-note@-2 {{layout constraint constraint 'Self' : 'AnyObject' implied here}}
8+
// expected-warning@-1 {{redundant constraint 'Self' : 'AnyObject'}}
9+
// expected-note@-2 {{constraint 'Self' : 'AnyObject' implied here}}
1010

1111
struct X : class { } // expected-error{{'class' constraint can only appear on protocol declarations}}

0 commit comments

Comments
 (0)