Skip to content

Commit 38698c7

Browse files
committed
Update tests for refinements to ~const bounds validation.
1 parent d6a6f74 commit 38698c7

File tree

4 files changed

+60
-16
lines changed

4 files changed

+60
-16
lines changed

tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ struct Foo<const N: usize>;
77

88
impl<const N: usize> Foo<N> {
99
fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
10-
//~^ ERROR mismatched types
10+
//~^ ERROR `~const` is not allowed here
11+
//~| ERROR mismatched types
1112
Foo
1213
}
1314
}
@@ -30,7 +31,7 @@ fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
3031
}
3132

3233
fn main() {
33-
let foo = Foo::<0>;
34-
let foo = bar::<(), _>(foo);
35-
let _foo = bar::<(), _>(foo);
34+
let foo = Foo::<0>;
35+
let foo = bar::<(), _>(foo);
36+
let _foo = bar::<(), _>(foo);
3637
}

tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
error: `~const` is not allowed here
2-
--> $DIR/tilde-const-and-const-params.rs:26:11
2+
--> $DIR/tilde-const-and-const-params.rs:9:15
3+
|
4+
LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
5+
| ^^^^^^^^^^^^
6+
|
7+
note: this function is not `const`, so it cannot have `~const` trait bounds
8+
--> $DIR/tilde-const-and-const-params.rs:9:8
9+
|
10+
LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
11+
| ^^^
12+
13+
error: `~const` is not allowed here
14+
--> $DIR/tilde-const-and-const-params.rs:27:11
315
|
416
LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
517
| ^^^^^^^^^^^^
618
|
719
note: this function is not `const`, so it cannot have `~const` trait bounds
8-
--> $DIR/tilde-const-and-const-params.rs:26:4
20+
--> $DIR/tilde-const-and-const-params.rs:27:4
921
|
1022
LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
1123
| ^^^
1224

1325
error[E0308]: mismatched types
14-
--> $DIR/tilde-const-and-const-params.rs:26:61
26+
--> $DIR/tilde-const-and-const-params.rs:27:61
1527
|
1628
LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
1729
| ^^^^^^^^^ expected `false`, found `true`
@@ -28,6 +40,6 @@ LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
2840
= note: expected constant `false`
2941
found constant `true`
3042

31-
error: aborting due to 3 previous errors
43+
error: aborting due to 4 previous errors
3244

3345
For more information about this error, try `rustc --explain E0308`.

tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ trait Bar {}
55

66
trait Foo {
77
fn a();
8-
fn b() where Self: ~const Bar;
8+
fn b()
9+
where
10+
Self: ~const Bar;
11+
//~^ ERROR `~const` is not allowed here
912
fn c<T: ~const Bar>();
13+
//~^ ERROR `~const` is not allowed here
1014
}
1115

1216
fn test1<T: Foo>() {
Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,54 @@
1+
error: `~const` is not allowed here
2+
--> $DIR/trait-where-clause.rs:10:15
3+
|
4+
LL | Self: ~const Bar;
5+
| ^^^^^^^^^^
6+
|
7+
note: this function is not `const`, so it cannot have `~const` trait bounds
8+
--> $DIR/trait-where-clause.rs:8:8
9+
|
10+
LL | fn b()
11+
| ^
12+
13+
error: `~const` is not allowed here
14+
--> $DIR/trait-where-clause.rs:12:13
15+
|
16+
LL | fn c<T: ~const Bar>();
17+
| ^^^^^^^^^^
18+
|
19+
note: this function is not `const`, so it cannot have `~const` trait bounds
20+
--> $DIR/trait-where-clause.rs:12:8
21+
|
22+
LL | fn c<T: ~const Bar>();
23+
| ^
24+
125
error[E0277]: the trait bound `T: Bar` is not satisfied
2-
--> $DIR/trait-where-clause.rs:14:5
26+
--> $DIR/trait-where-clause.rs:18:5
327
|
428
LL | T::b();
529
| ^ the trait `Bar` is not implemented for `T`
630
|
731
note: required by a bound in `Foo::b`
8-
--> $DIR/trait-where-clause.rs:8:24
32+
--> $DIR/trait-where-clause.rs:10:15
933
|
10-
LL | fn b() where Self: ~const Bar;
11-
| ^^^^^^^^^^ required by this bound in `Foo::b`
34+
LL | fn b()
35+
| - required by a bound in this associated function
36+
LL | where
37+
LL | Self: ~const Bar;
38+
| ^^^^^^^^^^ required by this bound in `Foo::b`
1239
help: consider further restricting this bound
1340
|
1441
LL | fn test1<T: Foo + Bar>() {
1542
| +++++
1643

1744
error[E0277]: the trait bound `T: Bar` is not satisfied
18-
--> $DIR/trait-where-clause.rs:16:12
45+
--> $DIR/trait-where-clause.rs:20:12
1946
|
2047
LL | T::c::<T>();
2148
| ^ the trait `Bar` is not implemented for `T`
2249
|
2350
note: required by a bound in `Foo::c`
24-
--> $DIR/trait-where-clause.rs:9:13
51+
--> $DIR/trait-where-clause.rs:12:13
2552
|
2653
LL | fn c<T: ~const Bar>();
2754
| ^^^^^^^^^^ required by this bound in `Foo::c`
@@ -30,6 +57,6 @@ help: consider further restricting this bound
3057
LL | fn test1<T: Foo + Bar>() {
3158
| +++++
3259

33-
error: aborting due to 2 previous errors
60+
error: aborting due to 4 previous errors
3461

3562
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)