Skip to content

Commit 4d4686e

Browse files
committed
Add test for inherent type_const normalization
1 parent 5787782 commit 4d4686e

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
struct S<const N: usize>;
2+
impl<const N: usize> S<N> {
3+
#[type_const]
4+
//~^ ERROR: the `#[type_const]` attribute is an experimental feature
5+
const LEN: usize = 1;
6+
fn arr() {
7+
[8; Self::LEN]
8+
//~^ WARN: cannot use constants which depend on generic parameters in types
9+
//~| WARN: this was previously accepted by the compiler but is being phased out
10+
//~| WARN: cannot use constants which depend on generic parameters in types
11+
//~| WARN: this was previously accepted by the compiler but is being phased out
12+
//~| ERROR: mismatched types
13+
}
14+
}
15+
16+
pub fn main() {}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error[E0658]: the `#[type_const]` attribute is an experimental feature
2+
--> $DIR/type-const-inherent-impl-normalize.rs:3:5
3+
|
4+
LL | #[type_const]
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
8+
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
warning: cannot use constants which depend on generic parameters in types
12+
--> $DIR/type-const-inherent-impl-normalize.rs:7:13
13+
|
14+
LL | [8; Self::LEN]
15+
| ^^^^^^^^^
16+
|
17+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18+
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
19+
= note: `#[warn(const_evaluatable_unchecked)]` (part of `#[warn(future_incompatible)]`) on by default
20+
21+
warning: cannot use constants which depend on generic parameters in types
22+
--> $DIR/type-const-inherent-impl-normalize.rs:7:13
23+
|
24+
LL | [8; Self::LEN]
25+
| ^^^^^^^^^
26+
|
27+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
28+
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
29+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
30+
31+
error[E0308]: mismatched types
32+
--> $DIR/type-const-inherent-impl-normalize.rs:7:9
33+
|
34+
LL | fn arr() {
35+
| - help: try adding a return type: `-> [i32; 1]`
36+
LL | [8; Self::LEN]
37+
| ^^^^^^^^^^^^^^ expected `()`, found `[{integer}; 1]`
38+
39+
error: aborting due to 2 previous errors; 2 warnings emitted
40+
41+
Some errors have detailed explanations: E0308, E0658.
42+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)