Skip to content

Commit 421d5f5

Browse files
committed
bless the fallout
1 parent ff7f240 commit 421d5f5

18 files changed

Lines changed: 64 additions & 91 deletions

tests/ui/const-generics/fn-item-as-const-arg-137084.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
fn a<const b: i32>() {}
88
fn d(e: &String) {
99
a::<d>
10-
//~^ ERROR mismatched types
11-
//~| ERROR the constant `d` is not of type `i32`
10+
//~^ ERROR function items cannot be used as const args
1211
}
1312

1413
fn main() {}
Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/fn-item-as-const-arg-137084.rs:9:5
3-
|
4-
LL | fn a<const b: i32>() {}
5-
| -------------------- function `a` defined here
6-
LL | fn d(e: &String) {
7-
LL | a::<d>
8-
| ^^^^^^ expected `()`, found fn item
9-
|
10-
= note: expected unit type `()`
11-
found fn item `fn() {a::<d>}`
12-
help: try adding a return type
13-
|
14-
LL | fn d(e: &String) -> fn() {
15-
| +++++++
16-
help: use parentheses to call this function
17-
|
18-
LL | a::<d>()
19-
| ++
20-
21-
error: the constant `d` is not of type `i32`
1+
error: function items cannot be used as const args
222
--> $DIR/fn-item-as-const-arg-137084.rs:9:9
233
|
244
LL | a::<d>
25-
| ^ expected `i32`, found fn item
26-
|
27-
note: required by a const generic parameter in `a`
28-
--> $DIR/fn-item-as-const-arg-137084.rs:7:6
29-
|
30-
LL | fn a<const b: i32>() {}
31-
| ^^^^^^^^^^^^ required by this const generic parameter in `a`
5+
| ^
326

33-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
348

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

tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ trait MyTrait<const F: fn() -> ()> {}
1111
fn foo<'a>(x: &'a ()) -> &'a () { x }
1212

1313
impl<T> Maybe<T> for T where T: MyTrait<{ foo }> {}
14-
//~^ ERROR the constant `foo` is not of type `fn()`
14+
//~^ ERROR function items cannot be used as const args
1515

1616
fn main() {}
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error: function items cannot be used as const args
2+
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:13:43
3+
|
4+
LL | impl<T> Maybe<T> for T where T: MyTrait<{ foo }> {}
5+
| ^^^
6+
17
error: using function pointers as const generic parameters is forbidden
28
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:8:24
39
|
@@ -6,17 +12,5 @@ LL | trait MyTrait<const F: fn() -> ()> {}
612
|
713
= note: the only supported types are integers, `bool`, and `char`
814

9-
error: the constant `foo` is not of type `fn()`
10-
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:13:33
11-
|
12-
LL | impl<T> Maybe<T> for T where T: MyTrait<{ foo }> {}
13-
| ^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
14-
|
15-
note: required by a const generic parameter in `MyTrait`
16-
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:8:15
17-
|
18-
LL | trait MyTrait<const F: fn() -> ()> {}
19-
| ^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `MyTrait`
20-
2115
error: aborting due to 2 previous errors
2216

tests/ui/const-generics/mgca/bad-impl-trait-with-apit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
trait Trait {}
77

88
impl<'t> Trait for [(); N] {}
9-
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for implementations
9+
//~^ ERROR function items cannot be used as const args
1010

1111
fn N(arg: impl Trait) {}
1212

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations
1+
error: function items cannot be used as const args
22
--> $DIR/bad-impl-trait-with-apit.rs:8:25
33
|
44
LL | impl<'t> Trait for [(); N] {}
5-
| ^ not allowed in type signatures
5+
| ^
66

77
error: aborting due to 1 previous error
88

9-
For more information about this error, try `rustc --explain E0121`.

tests/ui/const-generics/mgca/missing_generic_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
#![allow(incomplete_features)]
1212
trait Trait {}
1313
impl Trait for [(); N] {}
14-
//~^ ERROR: missing generics for function `N`
14+
//~^ ERROR function items cannot be used as const args
1515
fn N<T>() {}
1616
pub fn main() {}
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
error[E0107]: missing generics for function `N`
1+
error: function items cannot be used as const args
22
--> $DIR/missing_generic_params.rs:13:21
33
|
44
LL | impl Trait for [(); N] {}
5-
| ^ expected 1 generic argument
6-
|
7-
note: function defined here, with 1 generic parameter: `T`
8-
--> $DIR/missing_generic_params.rs:15:4
9-
|
10-
LL | fn N<T>() {}
11-
| ^ -
12-
help: add missing generic argument
13-
|
14-
LL | impl Trait for [(); N<T>] {}
15-
| +++
5+
| ^
166

177
error: aborting due to 1 previous error
188

19-
For more information about this error, try `rustc --explain E0107`.

tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
fn foo<T>() {
66
[0; size_of::<*mut T>()];
7-
//~^ ERROR: complex const arguments must be placed inside of a `const` block
7+
//~^ ERROR function items cannot be used as const args
8+
//~| ERROR tuple constructor with invalid base path
89
[0; const { size_of::<*mut T>() }];
910
//~^ ERROR: generic parameters may not be used in const operations
1011
[0; const { size_of::<*mut i32>() }];
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
error: complex const arguments must be placed inside of a `const` block
1+
error: function items cannot be used as const args
2+
--> $DIR/size-of-generic-ptr-in-array-len.rs:6:9
3+
|
4+
LL | [0; size_of::<*mut T>()];
5+
| ^^^^^^^^^^^^^^^^^
6+
7+
error: tuple constructor with invalid base path
28
--> $DIR/size-of-generic-ptr-in-array-len.rs:6:9
39
|
410
LL | [0; size_of::<*mut T>()];
511
| ^^^^^^^^^^^^^^^^^^^
612

713
error: generic parameters may not be used in const operations
8-
--> $DIR/size-of-generic-ptr-in-array-len.rs:8:32
14+
--> $DIR/size-of-generic-ptr-in-array-len.rs:9:32
915
|
1016
LL | [0; const { size_of::<*mut T>() }];
1117
| ^
1218
|
1319
= help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item
1420

15-
error: aborting due to 2 previous errors
21+
error: aborting due to 3 previous errors
1622

0 commit comments

Comments
 (0)