Skip to content

Commit 2e0b081

Browse files
authored
Rollup merge of rust-lang#92312 - BGR360:needs-test, r=Mark-Simulacrum
Add tests for three old ICEs Closes rust-lang#84044 Closes rust-lang#91594 Closes rust-lang#89066
2 parents edf5d1a + db27403 commit 2e0b081

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// #84044: This used to ICE.
2+
3+
fn main() {
4+
let f = || {};
5+
drop(&mut f); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
2+
--> $DIR/issue-84044-drop-non-mut.rs:5:10
3+
|
4+
LL | let f = || {};
5+
| - help: consider changing this to be mutable: `mut f`
6+
LL | drop(&mut f);
7+
| ^^^^^^ cannot borrow as mutable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0596`.
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// compile-flags: -Zsave-analysis
2+
3+
// Check that this does not ICE.
4+
// Stolen from src/test/ui/inference/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+
//~^ ERROR in expressions
28+
let v: [u8; 10] = [0; _];
29+
//~^ ERROR in expressions
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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: in expressions, `_` can only be used on the left-hand side of an assignment
14+
--> $DIR/issue-89066.rs:26:15
15+
|
16+
LL | let v: [u8; _];
17+
| ^ `_` not allowed here
18+
19+
error: in expressions, `_` can only be used on the left-hand side of an assignment
20+
--> $DIR/issue-89066.rs:28:25
21+
|
22+
LL | let v: [u8; 10] = [0; _];
23+
| ^ `_` not allowed here
24+
25+
error[E0392]: parameter `_` is never used
26+
--> $DIR/issue-89066.rs:12:17
27+
|
28+
LL | struct BadInfer<_>;
29+
| ^ unused parameter
30+
|
31+
= help: consider removing `_`, referring to it in a field, or using a marker such as `PhantomData`
32+
= help: if you intended `_` to be a const parameter, use `const _: usize` instead
33+
34+
error[E0107]: this struct takes 2 generic arguments but 3 generic arguments were supplied
35+
--> $DIR/issue-89066.rs:23:10
36+
|
37+
LL | let a: All<_, _, _>;
38+
| ^^^ - help: remove this generic argument
39+
| |
40+
| expected 2 generic arguments
41+
|
42+
note: struct defined here, with 2 generic parameters: `T`, `N`
43+
--> $DIR/issue-89066.rs:8:8
44+
|
45+
LL | struct All<'a, T, const N: usize> {
46+
| ^^^ - -
47+
48+
error: aborting due to 6 previous errors
49+
50+
Some errors have detailed explanations: E0107, E0392.
51+
For more information about an error, try `rustc --explain E0107`.

src/test/ui/traits/issue-91594.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// #91594: This used to ICE.
2+
3+
trait Component<M> {
4+
type Interface;
5+
}
6+
trait HasComponent<I> {}
7+
8+
struct Foo;
9+
10+
impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {}
11+
//~^ ERROR the trait bound `Foo: HasComponent<()>` is not satisfied
12+
13+
impl<M: HasComponent<()>> Component<M> for Foo {
14+
type Interface = u8;
15+
}
16+
17+
fn main() {}

src/test/ui/traits/issue-91594.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: the trait bound `Foo: HasComponent<()>` is not satisfied
2+
--> $DIR/issue-91594.rs:10:6
3+
|
4+
LL | impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
6+
|
7+
= help: the following implementations were found:
8+
<Foo as HasComponent<<Foo as Component<Foo>>::Interface>>
9+
note: required because of the requirements on the impl of `Component<Foo>` for `Foo`
10+
--> $DIR/issue-91594.rs:13:27
11+
|
12+
LL | impl<M: HasComponent<()>> Component<M> for Foo {
13+
| ^^^^^^^^^^^^ ^^^
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)