Skip to content

Commit f94eaea

Browse files
Fix rebase damage
1 parent 24ec364 commit f94eaea

10 files changed

+95
-79
lines changed

src/librustc_typeck/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ fn check_associated_type_defaults(
496496
}
497497

498498
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
499-
match t.sty {
499+
match t.kind {
500500
ty::Projection(proj_ty) => {
501501
if let Some(default) = self.map.get(&proj_ty) {
502502
default

src/test/ui/associated-types/defaults-in-other-trait-items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Tr {
1010
//~^ ERROR mismatched types
1111
//~| NOTE expected associated type, found `()`
1212
//~| NOTE expected associated type `<Self as Tr>::A`
13-
//~| NOTE consider constraining
13+
//~| NOTE consider constraining the associated type
1414
//~| NOTE for more information, visit
1515
}
1616
}
@@ -38,7 +38,7 @@ trait AssocConst {
3838
//~^ ERROR mismatched types
3939
//~| NOTE expected associated type, found `u8`
4040
//~| NOTE expected associated type `<Self as AssocConst>::Ty`
41-
//~| NOTE consider constraining
41+
//~| NOTE consider constraining the associated type
4242
//~| NOTE for more information, visit
4343
}
4444

src/test/ui/associated-types/defaults-in-other-trait-items.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | let () = p;
1010
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
1111

1212
error[E0308]: mismatched types
13-
--> $DIR/defaults-in-other-trait-items.rs:37:25
13+
--> $DIR/defaults-in-other-trait-items.rs:39:25
1414
|
1515
LL | const C: Self::Ty = 0u8;
1616
| ^^^ expected associated type, found `u8`

src/test/ui/associated-types/defaults-specialization.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl Tr for D<bool> {
6666

6767
struct E<T>(T);
6868
impl<T> Tr for E<T> {
69+
default type Ty = bool;
6970
default fn make() -> Self::Ty { panic!(); }
7071
}
7172

src/test/ui/associated-types/defaults-specialization.stderr

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ LL | fn make() -> Self::Ty {
55
| -------- type in trait
66
...
77
LL | fn make() -> u8 { 0 }
8-
| ^^ expected associated type, found u8
8+
| ^^ expected associated type, found `u8`
99
|
10-
= note: expected type `fn() -> <A<T> as Tr>::Ty`
11-
found type `fn() -> u8`
10+
= note: expected fn pointer `fn() -> <A<T> as Tr>::Ty`
11+
found fn pointer `fn() -> u8`
12+
= note: consider constraining the associated type `<A<T> as Tr>::Ty` to `u8` or calling a method that returns `<A<T> as Tr>::Ty`
13+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
1214

1315
error[E0053]: method `make` has an incompatible type for trait
1416
--> $DIR/defaults-specialization.rs:36:18
@@ -17,79 +19,95 @@ LL | fn make() -> Self::Ty {
1719
| -------- type in trait
1820
...
1921
LL | fn make() -> bool { true }
20-
| ^^^^ expected associated type, found bool
22+
| ^^^^ expected associated type, found `bool`
2123
|
22-
= note: expected type `fn() -> <B<T> as Tr>::Ty`
23-
found type `fn() -> bool`
24+
= note: expected fn pointer `fn() -> <B<T> as Tr>::Ty`
25+
found fn pointer `fn() -> bool`
26+
= note: consider constraining the associated type `<B<T> as Tr>::Ty` to `bool` or calling a method that returns `<B<T> as Tr>::Ty`
27+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
2428

2529
error[E0308]: mismatched types
2630
--> $DIR/defaults-specialization.rs:11:9
2731
|
2832
LL | fn make() -> Self::Ty {
2933
| -------- expected `<Self as Tr>::Ty` because of return type
3034
LL | 0u8
31-
| ^^^ expected associated type, found u8
35+
| ^^^ expected associated type, found `u8`
3236
|
33-
= note: expected type `<Self as Tr>::Ty`
34-
found type `u8`
37+
= note: expected associated type `<Self as Tr>::Ty`
38+
found type `u8`
39+
= note: consider constraining the associated type `<Self as Tr>::Ty` to `u8` or calling a method that returns `<Self as Tr>::Ty`
40+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
3541

3642
error[E0308]: mismatched types
3743
--> $DIR/defaults-specialization.rs:27:29
3844
|
3945
LL | fn make() -> Self::Ty { 0u8 }
40-
| -------- ^^^ expected associated type, found u8
46+
| -------- ^^^ expected associated type, found `u8`
4147
| |
4248
| expected `<A2<T> as Tr>::Ty` because of return type
4349
|
44-
= note: expected type `<A2<T> as Tr>::Ty`
45-
found type `u8`
50+
= note: expected associated type `<A2<T> as Tr>::Ty`
51+
found type `u8`
52+
= note: consider constraining the associated type `<A2<T> as Tr>::Ty` to `u8` or calling a method that returns `<A2<T> as Tr>::Ty`
53+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
4654

4755
error[E0308]: mismatched types
4856
--> $DIR/defaults-specialization.rs:45:29
4957
|
5058
LL | fn make() -> Self::Ty { true }
51-
| -------- ^^^^ expected associated type, found bool
59+
| -------- ^^^^ expected associated type, found `bool`
5260
| |
5361
| expected `<B2<T> as Tr>::Ty` because of return type
5462
|
55-
= note: expected type `<B2<T> as Tr>::Ty`
56-
found type `bool`
63+
= note: expected associated type `<B2<T> as Tr>::Ty`
64+
found type `bool`
65+
= note: consider constraining the associated type `<B2<T> as Tr>::Ty` to `bool` or calling a method that returns `<B2<T> as Tr>::Ty`
66+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
5767

5868
error[E0308]: mismatched types
59-
--> $DIR/defaults-specialization.rs:87:32
69+
--> $DIR/defaults-specialization.rs:88:32
6070
|
6171
LL | let _: <B<()> as Tr>::Ty = 0u8;
62-
| ^^^ expected associated type, found u8
72+
| ^^^ expected associated type, found `u8`
6373
|
64-
= note: expected type `<B<()> as Tr>::Ty`
65-
found type `u8`
74+
= note: expected associated type `<B<()> as Tr>::Ty`
75+
found type `u8`
76+
= note: consider constraining the associated type `<B<()> as Tr>::Ty` to `u8` or calling a method that returns `<B<()> as Tr>::Ty`
77+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
6678

6779
error[E0308]: mismatched types
68-
--> $DIR/defaults-specialization.rs:88:32
80+
--> $DIR/defaults-specialization.rs:89:32
6981
|
7082
LL | let _: <B<()> as Tr>::Ty = true;
71-
| ^^^^ expected associated type, found bool
83+
| ^^^^ expected associated type, found `bool`
7284
|
73-
= note: expected type `<B<()> as Tr>::Ty`
74-
found type `bool`
85+
= note: expected associated type `<B<()> as Tr>::Ty`
86+
found type `bool`
87+
= note: consider constraining the associated type `<B<()> as Tr>::Ty` to `bool` or calling a method that returns `<B<()> as Tr>::Ty`
88+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
7589

7690
error[E0308]: mismatched types
77-
--> $DIR/defaults-specialization.rs:89:33
91+
--> $DIR/defaults-specialization.rs:90:33
7892
|
7993
LL | let _: <B2<()> as Tr>::Ty = 0u8;
80-
| ^^^ expected associated type, found u8
94+
| ^^^ expected associated type, found `u8`
8195
|
82-
= note: expected type `<B2<()> as Tr>::Ty`
83-
found type `u8`
96+
= note: expected associated type `<B2<()> as Tr>::Ty`
97+
found type `u8`
98+
= note: consider constraining the associated type `<B2<()> as Tr>::Ty` to `u8` or calling a method that returns `<B2<()> as Tr>::Ty`
99+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
84100

85101
error[E0308]: mismatched types
86-
--> $DIR/defaults-specialization.rs:90:33
102+
--> $DIR/defaults-specialization.rs:91:33
87103
|
88104
LL | let _: <B2<()> as Tr>::Ty = true;
89-
| ^^^^ expected associated type, found bool
105+
| ^^^^ expected associated type, found `bool`
90106
|
91-
= note: expected type `<B2<()> as Tr>::Ty`
92-
found type `bool`
107+
= note: expected associated type `<B2<()> as Tr>::Ty`
108+
found type `bool`
109+
= note: consider constraining the associated type `<B2<()> as Tr>::Ty` to `bool` or calling a method that returns `<B2<()> as Tr>::Ty`
110+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
93111

94112
error: aborting due to 9 previous errors
95113

src/test/ui/associated-types/defaults-suitability.stderr

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
1919
--> $DIR/defaults-suitability.rs:35:15
2020
|
2121
LL | trait Foo<T> {
22-
| ------------ required by `Foo`
22+
| ------------
23+
| | |
24+
| | help: consider restricting this bound: `T: std::clone::Clone`
25+
| required by `Foo`
2326
LL | type Bar: Clone = Vec<T>;
2427
| ^^^^^ the trait `std::clone::Clone` is not implemented for `T`
2528
|
26-
= help: consider adding a `where T: std::clone::Clone` bound
2729
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<T>`
2830

2931
error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
@@ -82,22 +84,24 @@ error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: std::clone::Clone` is not
8284
--> $DIR/defaults-suitability.rs:74:15
8385
|
8486
LL | trait Foo2<T> {
85-
| ------------- required by `Foo2`
87+
| -------------- help: consider further restricting the associated type: `where <Self as Foo2<T>>::Baz: std::clone::Clone`
88+
| |
89+
| required by `Foo2`
8690
LL | type Bar: Clone = Vec<Self::Baz>;
8791
| ^^^^^ the trait `std::clone::Clone` is not implemented for `<Self as Foo2<T>>::Baz`
8892
|
89-
= help: consider adding a `where <Self as Foo2<T>>::Baz: std::clone::Clone` bound
9093
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo2<T>>::Baz>`
9194

9295
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: std::clone::Clone` is not satisfied
9396
--> $DIR/defaults-suitability.rs:83:15
9497
|
9598
LL | trait Foo25<T: Clone> {
96-
| --------------------- required by `Foo25`
99+
| ---------------------- help: consider further restricting the associated type: `where <Self as Foo25<T>>::Baz: std::clone::Clone`
100+
| |
101+
| required by `Foo25`
97102
LL | type Bar: Clone = Vec<Self::Baz>;
98103
| ^^^^^ the trait `std::clone::Clone` is not implemented for `<Self as Foo25<T>>::Baz`
99104
|
100-
= help: consider adding a `where <Self as Foo25<T>>::Baz: std::clone::Clone` bound
101105
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo25<T>>::Baz>`
102106

103107
error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
@@ -106,14 +110,14 @@ error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
106110
LL | / trait Foo3<T> where
107111
LL | | Self::Bar: Clone,
108112
LL | | Self::Baz: Clone,
109-
| | ^^^^^ the trait `std::clone::Clone` is not implemented for `T`
113+
| | ^^^^^ - help: consider further restricting type parameter `T`: `, T: std::clone::Clone`
114+
| | |
115+
| | the trait `std::clone::Clone` is not implemented for `T`
110116
LL | |
111117
... |
112118
LL | | type Baz = T;
113119
LL | | }
114120
| |_- required by `Foo3`
115-
|
116-
= help: consider adding a `where T: std::clone::Clone` bound
117121

118122
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
119123
--> $DIR/defaults-suitability.rs:29:5

src/test/ui/associated-types/defaults-unsound-62211-1.stderr

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | trait UncheckedCopy: Sized {
66
...
77
LL | type Output: Copy
88
| ^^^^ the trait `std::marker::Copy` is not implemented for `Self`
9-
|
10-
= help: consider adding a `where Self: std::marker::Copy` bound
119

1210
error[E0277]: cannot add-assign `&'static str` to `Self`
1311
--> $DIR/defaults-unsound-62211-1.rs:27:7
@@ -19,7 +17,6 @@ LL | + AddAssign<&'static str>
1917
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
2018
|
2119
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
22-
= help: consider adding a `where Self: std::ops::AddAssign<&'static str>` bound
2320

2421
error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
2522
--> $DIR/defaults-unsound-62211-1.rs:25:7
@@ -29,8 +26,6 @@ LL | trait UncheckedCopy: Sized {
2926
...
3027
LL | + Deref<Target = str>
3128
| ^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `Self`
32-
|
33-
= help: consider adding a `where Self: std::ops::Deref` bound
3429

3530
error[E0277]: `Self` doesn't implement `std::fmt::Display`
3631
--> $DIR/defaults-unsound-62211-1.rs:30:7
@@ -43,42 +38,43 @@ LL | + Display = Self;
4338
|
4439
= help: the trait `std::fmt::Display` is not implemented for `Self`
4540
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
46-
= help: consider adding a `where Self: std::fmt::Display` bound
4741

4842
error[E0277]: `T` doesn't implement `std::fmt::Display`
4943
--> $DIR/defaults-unsound-62211-1.rs:43:9
5044
|
5145
LL | impl<T> UncheckedCopy for T {}
52-
| ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
46+
| - ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
47+
| |
48+
| help: consider restricting this bound: `T: std::fmt::Display`
5349
|
5450
= help: the trait `std::fmt::Display` is not implemented for `T`
5551
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
56-
= help: consider adding a `where T: std::fmt::Display` bound
5752

5853
error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied
5954
--> $DIR/defaults-unsound-62211-1.rs:43:9
6055
|
6156
LL | impl<T> UncheckedCopy for T {}
62-
| ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T`
63-
|
64-
= help: consider adding a `where T: std::ops::Deref` bound
57+
| - ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T`
58+
| |
59+
| help: consider restricting this bound: `T: std::ops::Deref`
6560

6661
error[E0277]: cannot add-assign `&'static str` to `T`
6762
--> $DIR/defaults-unsound-62211-1.rs:43:9
6863
|
6964
LL | impl<T> UncheckedCopy for T {}
70-
| ^^^^^^^^^^^^^ no implementation for `T += &'static str`
65+
| - ^^^^^^^^^^^^^ no implementation for `T += &'static str`
66+
| |
67+
| help: consider restricting this bound: `T: std::ops::AddAssign<&'static str>`
7168
|
7269
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T`
73-
= help: consider adding a `where T: std::ops::AddAssign<&'static str>` bound
7470

7571
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
7672
--> $DIR/defaults-unsound-62211-1.rs:43:9
7773
|
7874
LL | impl<T> UncheckedCopy for T {}
79-
| ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
80-
|
81-
= help: consider adding a `where T: std::marker::Copy` bound
75+
| - ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
76+
| |
77+
| help: consider restricting this bound: `T: std::marker::Copy`
8278

8379
error: aborting due to 8 previous errors
8480

0 commit comments

Comments
 (0)