Skip to content

Commit 4d4da92

Browse files
Fix rebase damage
1 parent 9930e1f commit 4d4da92

17 files changed

+126
-94
lines changed

src/librustc_typeck/check/wfcheck.rs

+1
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ fn check_associated_type_defaults(fcx: &FnCtxt<'_, '_>, trait_def_id: DefId) {
443443
// `<Self as Trait<...>>::Assoc` to the default type.
444444
let map = tcx
445445
.associated_items(trait_def_id)
446+
.iter()
446447
.filter_map(|item| {
447448
if item.kind == ty::AssocKind::Type && item.defaultness.has_value() {
448449
// `<Self as Trait<...>>::Assoc`

src/test/ui/associated-const/defaults-not-assumed-fail.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fn main() {
3232
assert_eq!(<() as Tr>::A, 255);
3333
assert_eq!(<() as Tr>::B, 0); // causes the error above
3434
//~^ ERROR evaluation of constant expression failed
35+
//~| ERROR erroneous constant used
3536

3637
assert_eq!(<u8 as Tr>::A, 254);
3738
assert_eq!(<u8 as Tr>::B, 255);

src/test/ui/associated-const/defaults-not-assumed-fail.stderr

+10-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
1616
| |
1717
| referenced constant has errors
1818
|
19-
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
19+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2020

21-
error: aborting due to 2 previous errors
21+
error: erroneous constant used
22+
--> $DIR/defaults-not-assumed-fail.rs:33:5
23+
|
24+
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
26+
|
27+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
28+
29+
error: aborting due to 3 previous errors
2230

2331
For more information about this error, try `rustc --explain E0080`.

src/test/ui/associated-types/defaults-cyclic-fail-1.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0275]: overflow evaluating the requirement `<() as Tr>::B`
2-
--> $DIR/defaults-cyclic-fail-1.rs:12:6
2+
--> $DIR/defaults-cyclic-fail-1.rs:10:6
33
|
44
LL | impl Tr for () {}
55
| ^^
66

77
error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
8-
--> $DIR/defaults-cyclic-fail-1.rs:30:6
8+
--> $DIR/defaults-cyclic-fail-1.rs:28:6
99
|
1010
LL | impl Tr for bool {
1111
| ^^
1212

1313
error[E0275]: overflow evaluating the requirement `<usize as Tr>::B`
14-
--> $DIR/defaults-cyclic-fail-1.rs:37:6
14+
--> $DIR/defaults-cyclic-fail-1.rs:35:6
1515
|
1616
LL | impl Tr for usize {
1717
| ^^
1818

1919
error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
20-
--> $DIR/defaults-cyclic-fail-1.rs:32:5
20+
--> $DIR/defaults-cyclic-fail-1.rs:30:5
2121
|
2222
LL | type A = Box<Self::B>;
2323
| ^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error[E0275]: overflow evaluating the requirement `<usize as Tr>::A`
26-
--> $DIR/defaults-cyclic-fail-1.rs:39:5
26+
--> $DIR/defaults-cyclic-fail-1.rs:37:5
2727
|
2828
LL | type B = &'static Self::A;
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/associated-types/defaults-cyclic-fail-2.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-fail
2-
31
#![feature(associated_type_defaults)]
42

53
// A more complex version of `defaults-cyclic-fail-1.rs`, with non-trivial defaults.

src/test/ui/associated-types/defaults-cyclic-fail-2.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0275]: overflow evaluating the requirement `<() as Tr>::B`
2-
--> $DIR/defaults-cyclic-fail-2.rs:14:6
2+
--> $DIR/defaults-cyclic-fail-2.rs:12:6
33
|
44
LL | impl Tr for () {}
55
| ^^
66

77
error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
8-
--> $DIR/defaults-cyclic-fail-2.rs:32:6
8+
--> $DIR/defaults-cyclic-fail-2.rs:30:6
99
|
1010
LL | impl Tr for bool {
1111
| ^^
1212

1313
error[E0275]: overflow evaluating the requirement `<usize as Tr>::B`
14-
--> $DIR/defaults-cyclic-fail-2.rs:39:6
14+
--> $DIR/defaults-cyclic-fail-2.rs:37:6
1515
|
1616
LL | impl Tr for usize {
1717
| ^^
1818

1919
error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
20-
--> $DIR/defaults-cyclic-fail-2.rs:34:5
20+
--> $DIR/defaults-cyclic-fail-2.rs:32:5
2121
|
2222
LL | type A = Box<Self::B>;
2323
| ^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error[E0275]: overflow evaluating the requirement `<usize as Tr>::A`
26-
--> $DIR/defaults-cyclic-fail-2.rs:41:5
26+
--> $DIR/defaults-cyclic-fail-2.rs:39:5
2727
|
2828
LL | type B = &'static Self::A;
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

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

+1-1
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:39:25
13+
--> $DIR/defaults-in-other-trait-items.rs:37:25
1414
|
1515
LL | const C: Self::Ty = 0u8;
1616
| ^^^ expected associated type, found `u8`

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-fail
2-
31
#![feature(associated_type_defaults)]
42

53
// Tests that a trait with one defaulted and one non-defaulted assoc. type behaves properly.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0046]: not all trait items implemented, missing: `Bar`
2-
--> $DIR/defaults-mixed.rs:13:1
2+
--> $DIR/defaults-mixed.rs:11:1
33
|
44
LL | type Bar;
55
| --------- `Bar` from trait
@@ -8,7 +8,7 @@ LL | impl Trait for () {}
88
| ^^^^^^^^^^^^^^^^^ missing `Bar` in implementation
99

1010
error[E0046]: not all trait items implemented, missing: `Bar`
11-
--> $DIR/defaults-mixed.rs:16:1
11+
--> $DIR/defaults-mixed.rs:14:1
1212
|
1313
LL | type Bar;
1414
| --------- `Bar` from trait

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Tests the interaction of associated type defaults and specialization.
22
3-
// compile-fail
4-
53
#![feature(associated_type_defaults, specialization)]
64

75
trait Tr {

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0053]: method `make` has an incompatible type for trait
2-
--> $DIR/defaults-specialization.rs:20:18
2+
--> $DIR/defaults-specialization.rs:18:18
33
|
44
LL | fn make() -> Self::Ty {
55
| -------- type in trait
@@ -13,7 +13,7 @@ LL | fn make() -> u8 { 0 }
1313
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
1414

1515
error[E0053]: method `make` has an incompatible type for trait
16-
--> $DIR/defaults-specialization.rs:36:18
16+
--> $DIR/defaults-specialization.rs:34:18
1717
|
1818
LL | fn make() -> Self::Ty {
1919
| -------- type in trait
@@ -27,7 +27,7 @@ LL | fn make() -> bool { true }
2727
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
2828

2929
error[E0308]: mismatched types
30-
--> $DIR/defaults-specialization.rs:11:9
30+
--> $DIR/defaults-specialization.rs:9:9
3131
|
3232
LL | fn make() -> Self::Ty {
3333
| -------- expected `<Self as Tr>::Ty` because of return type
@@ -40,7 +40,7 @@ LL | 0u8
4040
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
4141

4242
error[E0308]: mismatched types
43-
--> $DIR/defaults-specialization.rs:27:29
43+
--> $DIR/defaults-specialization.rs:25:29
4444
|
4545
LL | fn make() -> Self::Ty { 0u8 }
4646
| -------- ^^^ expected associated type, found `u8`
@@ -53,7 +53,7 @@ LL | fn make() -> Self::Ty { 0u8 }
5353
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
5454

5555
error[E0308]: mismatched types
56-
--> $DIR/defaults-specialization.rs:45:29
56+
--> $DIR/defaults-specialization.rs:43:29
5757
|
5858
LL | fn make() -> Self::Ty { true }
5959
| -------- ^^^^ expected associated type, found `bool`
@@ -66,7 +66,7 @@ LL | fn make() -> Self::Ty { true }
6666
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
6767

6868
error[E0308]: mismatched types
69-
--> $DIR/defaults-specialization.rs:88:32
69+
--> $DIR/defaults-specialization.rs:86:32
7070
|
7171
LL | let _: <B<()> as Tr>::Ty = 0u8;
7272
| ----------------- ^^^ expected associated type, found `u8`
@@ -79,7 +79,7 @@ LL | let _: <B<()> as Tr>::Ty = 0u8;
7979
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
8080

8181
error[E0308]: mismatched types
82-
--> $DIR/defaults-specialization.rs:89:32
82+
--> $DIR/defaults-specialization.rs:87:32
8383
|
8484
LL | let _: <B<()> as Tr>::Ty = true;
8585
| ----------------- ^^^^ expected associated type, found `bool`
@@ -92,7 +92,7 @@ LL | let _: <B<()> as Tr>::Ty = true;
9292
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
9393

9494
error[E0308]: mismatched types
95-
--> $DIR/defaults-specialization.rs:90:33
95+
--> $DIR/defaults-specialization.rs:88:33
9696
|
9797
LL | let _: <B2<()> as Tr>::Ty = 0u8;
9898
| ------------------ ^^^ expected associated type, found `u8`
@@ -105,7 +105,7 @@ LL | let _: <B2<()> as Tr>::Ty = 0u8;
105105
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
106106

107107
error[E0308]: mismatched types
108-
--> $DIR/defaults-specialization.rs:91:33
108+
--> $DIR/defaults-specialization.rs:89:33
109109
|
110110
LL | let _: <B2<()> as Tr>::Ty = true;
111111
| ------------------ ^^^^ expected associated type, found `bool`

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

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//! (eg. `type Assoc: Clone = NotClone`), and also against where clauses on
77
//! the trait itself when possible
88
9-
// compile-fail
10-
119
#![feature(associated_type_defaults)]
1210

1311
struct NotClone;

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

+24-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied
2-
--> $DIR/defaults-suitability.rs:17:14
2+
--> $DIR/defaults-suitability.rs:15:14
33
|
44
LL | trait Tr {
55
| -------- required by `Tr`
66
LL | type Ty: Clone = NotClone;
77
| ^^^^^ the trait `std::clone::Clone` is not implemented for `NotClone`
88

99
error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied
10-
--> $DIR/defaults-suitability.rs:22:27
10+
--> $DIR/defaults-suitability.rs:20:27
1111
|
1212
LL | trait Tr2 where Self::Ty: Clone {
1313
| --------------------------^^^^^
@@ -16,20 +16,22 @@ LL | trait Tr2 where Self::Ty: Clone {
1616
| required by `Tr2`
1717

1818
error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
19-
--> $DIR/defaults-suitability.rs:35:15
19+
--> $DIR/defaults-suitability.rs:33:15
2020
|
2121
LL | trait Foo<T> {
22-
| ------------
23-
| | |
24-
| | help: consider restricting this bound: `T: std::clone::Clone`
25-
| required by `Foo`
22+
| ------------ required by `Foo`
2623
LL | type Bar: Clone = Vec<T>;
2724
| ^^^^^ the trait `std::clone::Clone` is not implemented for `T`
2825
|
26+
help: consider restricting this type parameter with `T: std::clone::Clone`
27+
--> $DIR/defaults-suitability.rs:32:11
28+
|
29+
LL | trait Foo<T> {
30+
| ^
2931
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<T>`
3032

3133
error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
32-
--> $DIR/defaults-suitability.rs:41:17
34+
--> $DIR/defaults-suitability.rs:39:17
3335
|
3436
LL | trait Bar: Sized {
3537
| ---------------- required by `Bar`
@@ -38,7 +40,7 @@ LL | type Assoc: Foo<Self> = ();
3840
| ^^^^^^^^^ the trait `Foo<Self>` is not implemented for `()`
3941

4042
error[E0277]: the trait bound `NotClone: IsU8<NotClone>` is not satisfied
41-
--> $DIR/defaults-suitability.rs:61:18
43+
--> $DIR/defaults-suitability.rs:59:18
4244
|
4345
LL | / trait D where
4446
LL | | Vec<Self::Assoc>: Clone,
@@ -51,7 +53,7 @@ LL | | }
5153
| |_- required by `D`
5254

5355
error[E0277]: the trait bound `bool: IsU8<NotClone>` is not satisfied
54-
--> $DIR/defaults-suitability.rs:63:11
56+
--> $DIR/defaults-suitability.rs:61:11
5557
|
5658
LL | / trait D where
5759
LL | | Vec<Self::Assoc>: Clone,
@@ -66,7 +68,7 @@ LL | | }
6668
| |_- required by `D`
6769

6870
error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied
69-
--> $DIR/defaults-suitability.rs:59:23
71+
--> $DIR/defaults-suitability.rs:57:23
7072
|
7173
LL | / trait D where
7274
LL | | Vec<Self::Assoc>: Clone,
@@ -81,7 +83,7 @@ LL | | }
8183
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<NotClone>`
8284

8385
error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: std::clone::Clone` is not satisfied
84-
--> $DIR/defaults-suitability.rs:74:15
86+
--> $DIR/defaults-suitability.rs:72:15
8587
|
8688
LL | trait Foo2<T> {
8789
| -------------- help: consider further restricting the associated type: `where <Self as Foo2<T>>::Baz: std::clone::Clone`
@@ -93,7 +95,7 @@ LL | type Bar: Clone = Vec<Self::Baz>;
9395
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo2<T>>::Baz>`
9496

9597
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: std::clone::Clone` is not satisfied
96-
--> $DIR/defaults-suitability.rs:83:15
98+
--> $DIR/defaults-suitability.rs:81:15
9799
|
98100
LL | trait Foo25<T: Clone> {
99101
| ---------------------- help: consider further restricting the associated type: `where <Self as Foo25<T>>::Baz: std::clone::Clone`
@@ -105,22 +107,26 @@ LL | type Bar: Clone = Vec<Self::Baz>;
105107
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo25<T>>::Baz>`
106108

107109
error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
108-
--> $DIR/defaults-suitability.rs:92:16
110+
--> $DIR/defaults-suitability.rs:90:16
109111
|
110112
LL | / trait Foo3<T> where
111113
LL | | Self::Bar: Clone,
112114
LL | | Self::Baz: Clone,
113-
| | ^^^^^ - help: consider further restricting type parameter `T`: `, T: std::clone::Clone`
114-
| | |
115-
| | the trait `std::clone::Clone` is not implemented for `T`
115+
| | ^^^^^ the trait `std::clone::Clone` is not implemented for `T`
116116
LL | |
117117
... |
118118
LL | | type Baz = T;
119119
LL | | }
120120
| |_- required by `Foo3`
121+
|
122+
help: consider restricting this type parameter with `where T: std::clone::Clone`
123+
--> $DIR/defaults-suitability.rs:88:12
124+
|
125+
LL | trait Foo3<T> where
126+
| ^
121127

122128
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
123-
--> $DIR/defaults-suitability.rs:29:5
129+
--> $DIR/defaults-suitability.rs:27:5
124130
|
125131
LL | type Ty = Vec<[u8]>;
126132
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time

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

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//! Note that the underlying cause of this is still not yet fixed.
88
//! See: https://github.com/rust-lang/rust/issues/33017
99
10-
// compile-fail
11-
1210
#![feature(associated_type_defaults)]
1311

1412
use std::{

0 commit comments

Comments
 (0)