Skip to content

Commit c86ecbe

Browse files
committed
Add new UI tests
1 parent d0a8172 commit c86ecbe

8 files changed

+200
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trait Foo1 {}
2+
3+
trait Foo2 {
4+
type Bar;
5+
}
6+
7+
impl<const N: usize> Foo1 for u32 where [u32; N]: Clone {}
8+
//~^ ERROR: the const parameter `N` is not constrained
9+
10+
impl<T, const N: usize> Foo1 for String where T: Iterator<Item = [u32; N]> {}
11+
//~^ ERROR: the type parameter `T` is not constrained
12+
//~| ERROR: the const parameter `N` is not constrained
13+
14+
impl<T, const N: usize> Foo2 for T where T: Foo2<Bar = [u32; N]> { type Bar = [u32; N]; }
15+
//~^ ERROR: the const parameter `N` is not constrained
16+
17+
fn main() {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/mentioned-but-unconstrained-const-generic.rs:7:6
3+
|
4+
LL | impl<const N: usize> Foo1 for u32 where [u32; N]: Clone {}
5+
| ^^^^^^^^^^^^^^ unconstrained const parameter
6+
|
7+
= note: to constrain `N`, use it in the implemented trait, in the self type, or in an equality with an associated type
8+
= note: expressions using a const parameter must map each value to a distinct output value
9+
= note: proving the result of expressions other than the parameter are unique is not supported
10+
11+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
12+
--> $DIR/mentioned-but-unconstrained-const-generic.rs:10:6
13+
|
14+
LL | impl<T, const N: usize> Foo1 for String where T: Iterator<Item = [u32; N]> {}
15+
| ^ unconstrained type parameter
16+
|
17+
= note: to constrain `T`, use it in the implemented trait, in the self type, or in an equality with an associated type
18+
19+
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
20+
--> $DIR/mentioned-but-unconstrained-const-generic.rs:10:9
21+
|
22+
LL | impl<T, const N: usize> Foo1 for String where T: Iterator<Item = [u32; N]> {}
23+
| ^^^^^^^^^^^^^^ unconstrained const parameter
24+
|
25+
= note: to constrain `N`, use it in the implemented trait, in the self type, or in an equality with an associated type
26+
= note: `N` is bound to an associated type, but the reference to the associated type itself uses unconstrained generic parameters
27+
= note: expressions using a const parameter must map each value to a distinct output value
28+
= note: proving the result of expressions other than the parameter are unique is not supported
29+
30+
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
31+
--> $DIR/mentioned-but-unconstrained-const-generic.rs:14:9
32+
|
33+
LL | impl<T, const N: usize> Foo2 for T where T: Foo2<Bar = [u32; N]> { type Bar = [u32; N]; }
34+
| ^^^^^^^^^^^^^^ unconstrained const parameter
35+
|
36+
= note: to constrain `N`, use it in the implemented trait, in the self type, or in an equality with an associated type
37+
= note: `N` is bound to an associated type, but the associated type is circularly defined in this impl
38+
= note: expressions using a const parameter must map each value to a distinct output value
39+
= note: proving the result of expressions other than the parameter are unique is not supported
40+
41+
error: aborting due to 4 previous errors
42+
43+
For more information about this error, try `rustc --explain E0207`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
trait Foo1 {}
2+
3+
trait Foo2 {
4+
type Bar;
5+
}
6+
7+
trait Foo3 {
8+
type Bar;
9+
}
10+
11+
impl<T> Foo1 for u32 where T: Clone {}
12+
//~^ ERROR: the type parameter `T` is not constrained
13+
14+
impl<T, U> Foo1 for String where T: Iterator<Item = U> {}
15+
//~^ ERROR: the type parameter `T` is not constrained
16+
//~| ERROR: the type parameter `U` is not constrained
17+
18+
impl<T, U> Foo2 for T where T: Foo2<Bar = U> { type Bar = U; }
19+
//~^ ERROR: the type parameter `U` is not constrained
20+
21+
impl<T, U> Foo3 for T where T: Foo3<Bar = Option<U>> { type Bar = Option<U>; }
22+
//~^ ERROR: the type parameter `U` is not constrained
23+
24+
fn main() {}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/mentioned-but-unconstrained-type.rs:11:6
3+
|
4+
LL | impl<T> Foo1 for u32 where T: Clone {}
5+
| ^ unconstrained type parameter
6+
|
7+
= note: to constrain `T`, use it in the implemented trait, in the self type, or in an equality with an associated type
8+
9+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
10+
--> $DIR/mentioned-but-unconstrained-type.rs:14:6
11+
|
12+
LL | impl<T, U> Foo1 for String where T: Iterator<Item = U> {}
13+
| ^ unconstrained type parameter
14+
|
15+
= note: to constrain `T`, use it in the implemented trait, in the self type, or in an equality with an associated type
16+
17+
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
18+
--> $DIR/mentioned-but-unconstrained-type.rs:14:9
19+
|
20+
LL | impl<T, U> Foo1 for String where T: Iterator<Item = U> {}
21+
| ^ unconstrained type parameter
22+
|
23+
= note: to constrain `U`, use it in the implemented trait, in the self type, or in an equality with an associated type
24+
= note: `U` is bound to an associated type, but the reference to the associated type itself uses unconstrained generic parameters
25+
26+
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
27+
--> $DIR/mentioned-but-unconstrained-type.rs:18:9
28+
|
29+
LL | impl<T, U> Foo2 for T where T: Foo2<Bar = U> { type Bar = U; }
30+
| ^ unconstrained type parameter
31+
|
32+
= note: to constrain `U`, use it in the implemented trait, in the self type, or in an equality with an associated type
33+
= note: `U` is bound to an associated type, but the associated type is circularly defined in this impl
34+
35+
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
36+
--> $DIR/mentioned-but-unconstrained-type.rs:21:9
37+
|
38+
LL | impl<T, U> Foo3 for T where T: Foo3<Bar = Option<U>> { type Bar = Option<U>; }
39+
| ^ unconstrained type parameter
40+
|
41+
= note: to constrain `U`, use it in the implemented trait, in the self type, or in an equality with an associated type
42+
= note: `U` is bound to an associated type, but the associated type is circularly defined in this impl
43+
44+
error: aborting due to 5 previous errors
45+
46+
For more information about this error, try `rustc --explain E0207`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
struct Foo;
2+
3+
impl<const N: usize> Foo {}
4+
//~^ ERROR: the const parameter `N` is not constrained
5+
6+
impl<const N: usize> Default for Foo {
7+
//~^ ERROR: the const parameter `N` is not constrained
8+
fn default() -> Self { Foo }
9+
}
10+
11+
// This one isn't an error
12+
fn foo<const N: usize>() {}
13+
14+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/unused-const-generic.rs:3:6
3+
|
4+
LL | impl<const N: usize> Foo {}
5+
| ^^^^^^^^^^^^^^ unconstrained const parameter
6+
|
7+
= note: to constrain `N`, use it in the self type, or in an equality with an associated type
8+
= note: expressions using a const parameter must map each value to a distinct output value
9+
= note: proving the result of expressions other than the parameter are unique is not supported
10+
11+
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
12+
--> $DIR/unused-const-generic.rs:6:6
13+
|
14+
LL | impl<const N: usize> Default for Foo {
15+
| ^^^^^^^^^^^^^^ unconstrained const parameter
16+
|
17+
= note: to constrain `N`, use it in the implemented trait, in the self type, or in an equality with an associated type
18+
= note: expressions using a const parameter must map each value to a distinct output value
19+
= note: proving the result of expressions other than the parameter are unique is not supported
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0207`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
struct Foo;
2+
3+
impl<T> Foo {}
4+
//~^ ERROR: the type parameter `T` is not constrained
5+
6+
impl<T> Default for Foo {
7+
//~^ ERROR: the type parameter `T` is not constrained
8+
fn default() -> Self { Foo }
9+
}
10+
11+
// This one isn't an error
12+
fn foo<T>() {}
13+
14+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/unused-type-generic.rs:3:6
3+
|
4+
LL | impl<T> Foo {}
5+
| ^ unconstrained type parameter
6+
|
7+
= note: to constrain `T`, use it in the self type, or in an equality with an associated type
8+
9+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
10+
--> $DIR/unused-type-generic.rs:6:6
11+
|
12+
LL | impl<T> Default for Foo {
13+
| ^ unconstrained type parameter
14+
|
15+
= note: to constrain `T`, use it in the implemented trait, in the self type, or in an equality with an associated type
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)