Skip to content

Commit 3f849a8

Browse files
BGR360Mark-Simulacrum
authored andcommitted
Add test for old ICE in #89066
1 parent 2819d90 commit 3f849a8

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// compile-flags: -Zsave-analysis
2+
3+
// Check that this does not ICE.
4+
// Stolen from src/test/ui/const-generics/generic_arg_infer/infer-arg-test.rs
5+
6+
#![feature(generic_arg_infer)]
7+
8+
struct All<'a, T, const N: usize> {
9+
v: &'a T,
10+
}
11+
12+
struct BadInfer<_>;
13+
//~^ ERROR expected identifier
14+
//~| ERROR parameter `_` is never used
15+
16+
fn all_fn<'a, T, const N: usize>() {}
17+
18+
fn bad_infer_fn<_>() {}
19+
//~^ ERROR expected identifier
20+
21+
22+
fn main() {
23+
let a: All<_, _, _>;
24+
//~^ ERROR this struct takes 2 generic arguments but 3 generic arguments were supplied
25+
all_fn();
26+
let v: [u8; _];
27+
let v: [u8; 10] = [0; _];
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error: expected identifier, found reserved identifier `_`
2+
--> $DIR/issue-89066.rs:12:17
3+
|
4+
LL | struct BadInfer<_>;
5+
| ^ expected identifier, found reserved identifier
6+
7+
error: expected identifier, found reserved identifier `_`
8+
--> $DIR/issue-89066.rs:18:17
9+
|
10+
LL | fn bad_infer_fn<_>() {}
11+
| ^ expected identifier, found reserved identifier
12+
13+
error[E0392]: parameter `_` is never used
14+
--> $DIR/issue-89066.rs:12:17
15+
|
16+
LL | struct BadInfer<_>;
17+
| ^ unused parameter
18+
|
19+
= help: consider removing `_`, referring to it in a field, or using a marker such as `PhantomData`
20+
= help: if you intended `_` to be a const parameter, use `const _: usize` instead
21+
22+
error[E0107]: this struct takes 2 generic arguments but 3 generic arguments were supplied
23+
--> $DIR/issue-89066.rs:23:10
24+
|
25+
LL | let a: All<_, _, _>;
26+
| ^^^ - help: remove this generic argument
27+
| |
28+
| expected 2 generic arguments
29+
|
30+
note: struct defined here, with 2 generic parameters: `T`, `N`
31+
--> $DIR/issue-89066.rs:8:8
32+
|
33+
LL | struct All<'a, T, const N: usize> {
34+
| ^^^ - -
35+
36+
error: aborting due to 4 previous errors
37+
38+
Some errors have detailed explanations: E0107, E0392.
39+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)