Skip to content

Commit 127c36c

Browse files
committed
add test for #119731
Fixes #119731
1 parent 548e14b commit 127c36c

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// rust-lang/rust#119731
2+
// ICE ... unevaluated constant UnevaluatedConst
3+
4+
#![feature(generic_const_exprs)]
5+
#![allow(incomplete_features)]
6+
7+
mod v20 {
8+
const v4: usize = 512;
9+
pub type v11 = [[usize; v4]; v4];
10+
//~^ WARN type `v11` should have an upper camel case name
11+
const v2: v11 = [[256; v4]; v4];
12+
13+
const v0: [[usize; v4]; v4] = v6(v8);
14+
//~^ ERROR cannot find value `v8` in this scope
15+
//~| ERROR cannot find function `v6` in this scope
16+
pub struct v17<const v10: usize, const v7: v11> {
17+
//~^ WARN type `v17` should have an upper camel case name
18+
//~| ERROR `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
19+
_p: (),
20+
}
21+
22+
impl v17<512, v0> {
23+
pub const fn v21() -> v18 {}
24+
//~^ ERROR cannot find type `v18` in this scope
25+
}
26+
27+
impl<const v10: usize> v17<v10, v2> {
28+
//~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
29+
//~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
30+
pub const fn v21() -> v18 {
31+
//~^ ERROR cannot find type `v18` in this scope
32+
v18 { _p: () }
33+
//~^ ERROR cannot find struct, variant or union type `v18` in this scope
34+
}
35+
}
36+
}
37+
pub use v20::{v13, v17};
38+
//~^ ERROR unresolved import `v20::v13`
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
error[E0432]: unresolved import `v20::v13`
2+
--> $DIR/unevaluated-const-ice-119731.rs:37:15
3+
|
4+
LL | pub use v20::{v13, v17};
5+
| ^^^
6+
| |
7+
| no `v13` in `v20`
8+
| help: a similar name exists in the module: `v11`
9+
10+
error[E0425]: cannot find value `v8` in this scope
11+
--> $DIR/unevaluated-const-ice-119731.rs:13:38
12+
|
13+
LL | const v0: [[usize; v4]; v4] = v6(v8);
14+
| ^^ not found in this scope
15+
16+
error[E0412]: cannot find type `v18` in this scope
17+
--> $DIR/unevaluated-const-ice-119731.rs:23:31
18+
|
19+
LL | pub type v11 = [[usize; v4]; v4];
20+
| --------------------------------- similarly named type alias `v11` defined here
21+
...
22+
LL | pub const fn v21() -> v18 {}
23+
| ^^^ help: a type alias with a similar name exists: `v11`
24+
25+
error[E0412]: cannot find type `v18` in this scope
26+
--> $DIR/unevaluated-const-ice-119731.rs:30:31
27+
|
28+
LL | pub type v11 = [[usize; v4]; v4];
29+
| --------------------------------- similarly named type alias `v11` defined here
30+
...
31+
LL | pub const fn v21() -> v18 {
32+
| ^^^ help: a type alias with a similar name exists: `v11`
33+
34+
error[E0422]: cannot find struct, variant or union type `v18` in this scope
35+
--> $DIR/unevaluated-const-ice-119731.rs:32:13
36+
|
37+
LL | pub type v11 = [[usize; v4]; v4];
38+
| --------------------------------- similarly named type alias `v11` defined here
39+
...
40+
LL | v18 { _p: () }
41+
| ^^^ help: a type alias with a similar name exists: `v11`
42+
43+
warning: type `v11` should have an upper camel case name
44+
--> $DIR/unevaluated-const-ice-119731.rs:9:14
45+
|
46+
LL | pub type v11 = [[usize; v4]; v4];
47+
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V11`
48+
|
49+
= note: `#[warn(non_camel_case_types)]` on by default
50+
51+
warning: type `v17` should have an upper camel case name
52+
--> $DIR/unevaluated-const-ice-119731.rs:16:16
53+
|
54+
LL | pub struct v17<const v10: usize, const v7: v11> {
55+
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V17`
56+
57+
error[E0425]: cannot find function `v6` in this scope
58+
--> $DIR/unevaluated-const-ice-119731.rs:13:35
59+
|
60+
LL | const v0: [[usize; v4]; v4] = v6(v8);
61+
| ^^ not found in this scope
62+
63+
error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
64+
--> $DIR/unevaluated-const-ice-119731.rs:16:48
65+
|
66+
LL | pub struct v17<const v10: usize, const v7: v11> {
67+
| ^^^
68+
|
69+
= note: the only supported types are integers, `bool` and `char`
70+
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
71+
|
72+
LL + #![feature(adt_const_params)]
73+
|
74+
75+
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
76+
--> $DIR/unevaluated-const-ice-119731.rs:27:37
77+
|
78+
LL | impl<const v10: usize> v17<v10, v2> {
79+
| ^^
80+
81+
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
82+
--> $DIR/unevaluated-const-ice-119731.rs:27:37
83+
|
84+
LL | impl<const v10: usize> v17<v10, v2> {
85+
| ^^
86+
|
87+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
88+
89+
error: aborting due to 9 previous errors; 2 warnings emitted
90+
91+
Some errors have detailed explanations: E0412, E0422, E0425, E0432.
92+
For more information about an error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)