Skip to content

Commit 5c68eb3

Browse files
Add a bunch of tests
1 parent 2f4b7dc commit 5c68eb3

15 files changed

+311
-29
lines changed

Diff for: tests/ui/associated-types/defaults-suitability.stderr renamed to tests/ui/associated-types/defaults-suitability.current.stderr

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
2-
--> $DIR/defaults-suitability.rs:13:22
2+
--> $DIR/defaults-suitability.rs:16:22
33
|
44
LL | type Ty: Clone = NotClone;
55
| ^^^^^^^^ the trait `Clone` is not implemented for `NotClone`
66
|
77
note: required by a bound in `Tr::Ty`
8-
--> $DIR/defaults-suitability.rs:13:14
8+
--> $DIR/defaults-suitability.rs:16:14
99
|
1010
LL | type Ty: Clone = NotClone;
1111
| ^^^^^ required by this bound in `Tr::Ty`
@@ -16,13 +16,13 @@ LL | struct NotClone;
1616
|
1717

1818
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
19-
--> $DIR/defaults-suitability.rs:22:15
19+
--> $DIR/defaults-suitability.rs:25:15
2020
|
2121
LL | type Ty = NotClone;
2222
| ^^^^^^^^ the trait `Clone` is not implemented for `NotClone`
2323
|
2424
note: required by a bound in `Tr2::Ty`
25-
--> $DIR/defaults-suitability.rs:20:15
25+
--> $DIR/defaults-suitability.rs:23:15
2626
|
2727
LL | Self::Ty: Clone,
2828
| ^^^^^ required by this bound in `Tr2::Ty`
@@ -36,14 +36,14 @@ LL | struct NotClone;
3636
|
3737

3838
error[E0277]: the trait bound `T: Clone` is not satisfied
39-
--> $DIR/defaults-suitability.rs:28:23
39+
--> $DIR/defaults-suitability.rs:31:23
4040
|
4141
LL | type Bar: Clone = Vec<T>;
4242
| ^^^^^^ the trait `Clone` is not implemented for `T`, which is required by `Vec<T>: Clone`
4343
|
4444
= note: required for `Vec<T>` to implement `Clone`
4545
note: required by a bound in `Foo::Bar`
46-
--> $DIR/defaults-suitability.rs:28:15
46+
--> $DIR/defaults-suitability.rs:31:15
4747
|
4848
LL | type Bar: Clone = Vec<T>;
4949
| ^^^^^ required by this bound in `Foo::Bar`
@@ -53,30 +53,30 @@ LL | trait Foo<T: std::clone::Clone> {
5353
| +++++++++++++++++++
5454

5555
error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
56-
--> $DIR/defaults-suitability.rs:34:29
56+
--> $DIR/defaults-suitability.rs:37:29
5757
|
5858
LL | type Assoc: Foo<Self> = ();
5959
| ^^ the trait `Foo<Self>` is not implemented for `()`
6060
|
6161
help: this trait has no implementations, consider adding one
62-
--> $DIR/defaults-suitability.rs:27:1
62+
--> $DIR/defaults-suitability.rs:30:1
6363
|
6464
LL | trait Foo<T> {
6565
| ^^^^^^^^^^^^
6666
note: required by a bound in `Bar::Assoc`
67-
--> $DIR/defaults-suitability.rs:34:17
67+
--> $DIR/defaults-suitability.rs:37:17
6868
|
6969
LL | type Assoc: Foo<Self> = ();
7070
| ^^^^^^^^^ required by this bound in `Bar::Assoc`
7171

7272
error[E0277]: the trait bound `NotClone: IsU8<NotClone>` is not satisfied
73-
--> $DIR/defaults-suitability.rs:56:18
73+
--> $DIR/defaults-suitability.rs:59:18
7474
|
7575
LL | type Assoc = NotClone;
7676
| ^^^^^^^^ the trait `IsU8<NotClone>` is not implemented for `NotClone`
7777
|
7878
note: required by a bound in `D::Assoc`
79-
--> $DIR/defaults-suitability.rs:53:18
79+
--> $DIR/defaults-suitability.rs:56:18
8080
|
8181
LL | Self::Assoc: IsU8<Self::Assoc>,
8282
| ^^^^^^^^^^^^^^^^^ required by this bound in `D::Assoc`
@@ -85,14 +85,14 @@ LL | type Assoc = NotClone;
8585
| ----- required by a bound in this associated type
8686

8787
error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
88-
--> $DIR/defaults-suitability.rs:65:23
88+
--> $DIR/defaults-suitability.rs:68:23
8989
|
9090
LL | type Bar: Clone = Vec<Self::Baz>;
9191
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`, which is required by `Vec<<Self as Foo2<T>>::Baz>: Clone`
9292
|
9393
= note: required for `Vec<<Self as Foo2<T>>::Baz>` to implement `Clone`
9494
note: required by a bound in `Foo2::Bar`
95-
--> $DIR/defaults-suitability.rs:65:15
95+
--> $DIR/defaults-suitability.rs:68:15
9696
|
9797
LL | type Bar: Clone = Vec<Self::Baz>;
9898
| ^^^^^ required by this bound in `Foo2::Bar`
@@ -102,14 +102,14 @@ LL | trait Foo2<T> where <Self as Foo2<T>>::Baz: Clone {
102102
| +++++++++++++++++++++++++++++++++++
103103

104104
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: Clone` is not satisfied
105-
--> $DIR/defaults-suitability.rs:74:23
105+
--> $DIR/defaults-suitability.rs:77:23
106106
|
107107
LL | type Bar: Clone = Vec<Self::Baz>;
108108
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`, which is required by `Vec<<Self as Foo25<T>>::Baz>: Clone`
109109
|
110110
= note: required for `Vec<<Self as Foo25<T>>::Baz>` to implement `Clone`
111111
note: required by a bound in `Foo25::Bar`
112-
--> $DIR/defaults-suitability.rs:74:15
112+
--> $DIR/defaults-suitability.rs:77:15
113113
|
114114
LL | type Bar: Clone = Vec<Self::Baz>;
115115
| ^^^^^ required by this bound in `Foo25::Bar`
@@ -119,13 +119,13 @@ LL | trait Foo25<T: Clone> where <Self as Foo25<T>>::Baz: Clone {
119119
| ++++++++++++++++++++++++++++++++++++
120120

121121
error[E0277]: the trait bound `T: Clone` is not satisfied
122-
--> $DIR/defaults-suitability.rs:87:16
122+
--> $DIR/defaults-suitability.rs:90:16
123123
|
124124
LL | type Baz = T;
125125
| ^ the trait `Clone` is not implemented for `T`
126126
|
127127
note: required by a bound in `Foo3::Baz`
128-
--> $DIR/defaults-suitability.rs:84:16
128+
--> $DIR/defaults-suitability.rs:87:16
129129
|
130130
LL | Self::Baz: Clone,
131131
| ^^^^^ required by this bound in `Foo3::Baz`
+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
2+
--> $DIR/defaults-suitability.rs:16:22
3+
|
4+
LL | type Ty: Clone = NotClone;
5+
| ^^^^^^^^ the trait `Clone` is not implemented for `NotClone`
6+
|
7+
note: required by a bound in `Tr::Ty`
8+
--> $DIR/defaults-suitability.rs:16:14
9+
|
10+
LL | type Ty: Clone = NotClone;
11+
| ^^^^^ required by this bound in `Tr::Ty`
12+
help: consider annotating `NotClone` with `#[derive(Clone)]`
13+
|
14+
LL + #[derive(Clone)]
15+
LL | struct NotClone;
16+
|
17+
18+
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
19+
--> $DIR/defaults-suitability.rs:25:15
20+
|
21+
LL | type Ty = NotClone;
22+
| ^^^^^^^^ the trait `Clone` is not implemented for `NotClone`
23+
|
24+
note: required by a bound in `Tr2::Ty`
25+
--> $DIR/defaults-suitability.rs:23:15
26+
|
27+
LL | Self::Ty: Clone,
28+
| ^^^^^ required by this bound in `Tr2::Ty`
29+
LL | {
30+
LL | type Ty = NotClone;
31+
| -- required by a bound in this associated type
32+
help: consider annotating `NotClone` with `#[derive(Clone)]`
33+
|
34+
LL + #[derive(Clone)]
35+
LL | struct NotClone;
36+
|
37+
38+
error[E0277]: the trait bound `T: Clone` is not satisfied
39+
--> $DIR/defaults-suitability.rs:31:23
40+
|
41+
LL | type Bar: Clone = Vec<T>;
42+
| ^^^^^^ the trait `Clone` is not implemented for `T`, which is required by `Vec<T>: Clone`
43+
|
44+
= note: required for `Vec<T>` to implement `Clone`
45+
note: required by a bound in `Foo::Bar`
46+
--> $DIR/defaults-suitability.rs:31:15
47+
|
48+
LL | type Bar: Clone = Vec<T>;
49+
| ^^^^^ required by this bound in `Foo::Bar`
50+
help: consider restricting type parameter `T`
51+
|
52+
LL | trait Foo<T: std::clone::Clone> {
53+
| +++++++++++++++++++
54+
55+
error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
56+
--> $DIR/defaults-suitability.rs:37:29
57+
|
58+
LL | type Assoc: Foo<Self> = ();
59+
| ^^ the trait `Foo<Self>` is not implemented for `()`
60+
|
61+
help: this trait has no implementations, consider adding one
62+
--> $DIR/defaults-suitability.rs:30:1
63+
|
64+
LL | trait Foo<T> {
65+
| ^^^^^^^^^^^^
66+
note: required by a bound in `Bar::Assoc`
67+
--> $DIR/defaults-suitability.rs:37:17
68+
|
69+
LL | type Assoc: Foo<Self> = ();
70+
| ^^^^^^^^^ required by this bound in `Bar::Assoc`
71+
72+
error[E0277]: the trait bound `NotClone: IsU8<NotClone>` is not satisfied
73+
--> $DIR/defaults-suitability.rs:59:18
74+
|
75+
LL | type Assoc = NotClone;
76+
| ^^^^^^^^ the trait `IsU8<NotClone>` is not implemented for `NotClone`
77+
|
78+
note: required by a bound in `D::Assoc`
79+
--> $DIR/defaults-suitability.rs:56:18
80+
|
81+
LL | Self::Assoc: IsU8<Self::Assoc>,
82+
| ^^^^^^^^^^^^^^^^^ required by this bound in `D::Assoc`
83+
...
84+
LL | type Assoc = NotClone;
85+
| ----- required by a bound in this associated type
86+
87+
error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
88+
--> $DIR/defaults-suitability.rs:68:23
89+
|
90+
LL | type Bar: Clone = Vec<Self::Baz>;
91+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`, which is required by `Vec<<Self as Foo2<T>>::Baz>: Clone`
92+
|
93+
= note: required for `Vec<<Self as Foo2<T>>::Baz>` to implement `Clone`
94+
note: required by a bound in `Foo2::Bar`
95+
--> $DIR/defaults-suitability.rs:68:15
96+
|
97+
LL | type Bar: Clone = Vec<Self::Baz>;
98+
| ^^^^^ required by this bound in `Foo2::Bar`
99+
help: consider further restricting the associated type
100+
|
101+
LL | trait Foo2<T> where <Self as Foo2<T>>::Baz: Clone {
102+
| +++++++++++++++++++++++++++++++++++
103+
104+
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: Clone` is not satisfied
105+
--> $DIR/defaults-suitability.rs:77:23
106+
|
107+
LL | type Bar: Clone = Vec<Self::Baz>;
108+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`, which is required by `Vec<<Self as Foo25<T>>::Baz>: Clone`
109+
|
110+
= note: required for `Vec<<Self as Foo25<T>>::Baz>` to implement `Clone`
111+
note: required by a bound in `Foo25::Bar`
112+
--> $DIR/defaults-suitability.rs:77:15
113+
|
114+
LL | type Bar: Clone = Vec<Self::Baz>;
115+
| ^^^^^ required by this bound in `Foo25::Bar`
116+
help: consider further restricting the associated type
117+
|
118+
LL | trait Foo25<T: Clone> where <Self as Foo25<T>>::Baz: Clone {
119+
| ++++++++++++++++++++++++++++++++++++
120+
121+
error[E0277]: the trait bound `T: Clone` is not satisfied
122+
--> $DIR/defaults-suitability.rs:90:16
123+
|
124+
LL | type Baz = T;
125+
| ^ the trait `Clone` is not implemented for `T`
126+
|
127+
note: required by a bound in `Foo3::Baz`
128+
--> $DIR/defaults-suitability.rs:87:16
129+
|
130+
LL | Self::Baz: Clone,
131+
| ^^^^^ required by this bound in `Foo3::Baz`
132+
...
133+
LL | type Baz = T;
134+
| --- required by a bound in this associated type
135+
help: consider further restricting type parameter `T`
136+
|
137+
LL | Self::Baz: Clone, T: std::clone::Clone
138+
| ~~~~~~~~~~~~~~~~~~~~~~
139+
140+
error: aborting due to 8 previous errors
141+
142+
For more information about this error, try `rustc --explain E0277`.

Diff for: tests/ui/associated-types/defaults-suitability.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
14
//! Checks that associated type defaults are properly validated.
25
//!
36
//! This means:

Diff for: tests/ui/associated-types/issue-54108.stderr renamed to tests/ui/associated-types/issue-54108.current.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error[E0277]: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
2-
--> $DIR/issue-54108.rs:19:17
2+
--> $DIR/issue-54108.rs:23:17
33
|
44
LL | type Size = <Self as SubEncoder>::ActualSize;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<T as SubEncoder>::ActualSize + <T as SubEncoder>::ActualSize`
66
|
77
= help: the trait `Add` is not implemented for `<T as SubEncoder>::ActualSize`
88
note: required by a bound in `Encoder::Size`
9-
--> $DIR/issue-54108.rs:4:16
9+
--> $DIR/issue-54108.rs:8:16
1010
|
1111
LL | type Size: Add<Output = Self::Size>;
1212
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`

Diff for: tests/ui/associated-types/issue-54108.next.stderr

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error[E0271]: type mismatch resolving `<<T as SubEncoder>::ActualSize as Add>::Output == <T as SubEncoder>::ActualSize`
2+
--> $DIR/issue-54108.rs:23:17
3+
|
4+
LL | type Size = <Self as SubEncoder>::ActualSize;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
6+
|
7+
note: required by a bound in `Encoder::Size`
8+
--> $DIR/issue-54108.rs:8:20
9+
|
10+
LL | type Size: Add<Output = Self::Size>;
11+
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`
12+
13+
error[E0277]: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
14+
--> $DIR/issue-54108.rs:23:17
15+
|
16+
LL | type Size = <Self as SubEncoder>::ActualSize;
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<T as SubEncoder>::ActualSize + <T as SubEncoder>::ActualSize`
18+
|
19+
= help: the trait `Add` is not implemented for `<T as SubEncoder>::ActualSize`
20+
note: required by a bound in `Encoder::Size`
21+
--> $DIR/issue-54108.rs:8:16
22+
|
23+
LL | type Size: Add<Output = Self::Size>;
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`
25+
help: consider further restricting the associated type
26+
|
27+
LL | T: SubEncoder, <T as SubEncoder>::ActualSize: Add
28+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29+
30+
error: aborting due to 2 previous errors
31+
32+
Some errors have detailed explanations: E0271, E0277.
33+
For more information about an error, try `rustc --explain E0271`.

Diff for: tests/ui/associated-types/issue-54108.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
15
use std::ops::Add;
26

37
pub trait Encoder {
@@ -18,6 +22,7 @@ where
1822
{
1923
type Size = <Self as SubEncoder>::ActualSize;
2024
//~^ ERROR: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
25+
//[next]~| ERROR type mismatch resolving `<<T as SubEncoder>::ActualSize as Add>::Output == <T as SubEncoder>::ActualSize`
2126

2227
fn foo(&self) -> Self::Size {
2328
self.bar() + self.bar()

Diff for: tests/ui/associated-types/issue-63593.stderr renamed to tests/ui/associated-types/issue-63593.current.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0277]: the size for values of type `Self` cannot be known at compilation time
2-
--> $DIR/issue-63593.rs:9:17
2+
--> $DIR/issue-63593.rs:13:17
33
|
44
LL | type This = Self;
55
| ^^^^ doesn't have a size known at compile-time
66
|
77
note: required by a bound in `MyTrait::This`
8-
--> $DIR/issue-63593.rs:9:5
8+
--> $DIR/issue-63593.rs:13:5
99
|
1010
LL | type This = Self;
1111
| ^^^^^^^^^^^^^^^^^ required by this bound in `MyTrait::This`

Diff for: tests/ui/associated-types/issue-63593.next.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
2+
--> $DIR/issue-63593.rs:13:17
3+
|
4+
LL | type This = Self;
5+
| ^^^^ doesn't have a size known at compile-time
6+
|
7+
note: required by a bound in `MyTrait::This`
8+
--> $DIR/issue-63593.rs:13:5
9+
|
10+
LL | type This = Self;
11+
| ^^^^^^^^^^^^^^^^^ required by this bound in `MyTrait::This`
12+
help: consider further restricting `Self`
13+
|
14+
LL | trait MyTrait: Sized {
15+
| +++++++
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0277`.

Diff for: tests/ui/associated-types/issue-63593.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
15
#![feature(associated_type_defaults)]
26

37
// Tests that `Self` is not assumed to implement `Sized` when used as an

0 commit comments

Comments
 (0)