Skip to content

Commit abd64d7

Browse files
committed
add a couple of ICE testcases
Fixes #6250 Fixes #6251 Fixes #6252 Fixes #6255 Fixes #6256
1 parent 645ef50 commit abd64d7

12 files changed

+239
-0
lines changed

tests/ui/crashes/ice-6250.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// originally from glacier/fixed/77218.rs
2+
// ice while adjusting...
3+
4+
pub struct Cache {
5+
data: Vec<i32>,
6+
}
7+
8+
pub fn list_data(cache: &Cache, key: usize) {
9+
for reference in vec![1, 2, 3] {
10+
if
11+
/* let */
12+
Some(reference) = cache.data.get(key) {
13+
unimplemented!()
14+
}
15+
}
16+
}

tests/ui/crashes/ice-6250.stderr

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0601]: `main` function not found in crate `ice_6250`
2+
--> $DIR/ice-6250.rs:4:1
3+
|
4+
LL | / pub struct Cache {
5+
LL | | data: Vec<i32>,
6+
LL | | }
7+
LL | |
8+
... |
9+
LL | | }
10+
LL | | }
11+
| |_^ consider adding a `main` function to `$DIR/ice-6250.rs`
12+
13+
error[E0308]: mismatched types
14+
--> $DIR/ice-6250.rs:12:9
15+
|
16+
LL | Some(reference) = cache.data.get(key) {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
18+
|
19+
help: you might have meant to use pattern matching
20+
|
21+
LL | let Some(reference) = cache.data.get(key) {
22+
| ^^^
23+
24+
error: aborting due to 2 previous errors
25+
26+
Some errors have detailed explanations: E0308, E0601.
27+
For more information about an error, try `rustc --explain E0308`.

tests/ui/crashes/ice-6251.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// originally from glacier/fixed/77329.rs
2+
// assertion failed: `(left == right) ; different DefIds
3+
4+
fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
5+
std::iter::empty()
6+
}

tests/ui/crashes/ice-6251.stderr

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0601]: `main` function not found in crate `ice_6251`
2+
--> $DIR/ice-6251.rs:4:1
3+
|
4+
LL | / fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
5+
LL | | std::iter::empty()
6+
LL | | }
7+
| |_^ consider adding a `main` function to `$DIR/ice-6251.rs`
8+
9+
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
10+
--> $DIR/ice-6251.rs:4:45
11+
|
12+
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
13+
| ^ doesn't have a size known at compile-time
14+
|
15+
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
16+
= help: unsized fn params are gated as an unstable feature
17+
help: function arguments must have a statically known size, borrowed types always have a known size
18+
|
19+
LL | fn bug<T>() -> impl Iterator<Item = [(); { |&x: [u8]| x }]> {
20+
| ^
21+
22+
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
23+
--> $DIR/ice-6251.rs:4:54
24+
|
25+
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
26+
| ^ doesn't have a size known at compile-time
27+
|
28+
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
29+
= note: the return type of a function must have a statically known size
30+
31+
error[E0308]: mismatched types
32+
--> $DIR/ice-6251.rs:4:44
33+
|
34+
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
35+
| ^^^^^^^^^^^ expected `usize`, found closure
36+
|
37+
= note: expected type `usize`
38+
found closure `[closure@$DIR/ice-6251.rs:4:44: 4:55]`
39+
40+
error: aborting due to 4 previous errors
41+
42+
Some errors have detailed explanations: E0277, E0308, E0601.
43+
For more information about an error, try `rustc --explain E0277`.

tests/ui/crashes/ice-6252.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// originally from glacier fixed/77919.rs
2+
// encountered errors resolving bounds after type-checking
3+
4+
trait TypeVal<T> {
5+
const VAL: T;
6+
}
7+
struct Five;
8+
struct Multiply<N, M> {
9+
_n: PhantomData,
10+
}
11+
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
12+
13+
fn main() {
14+
[1; <Multiply<Five, Five>>::VAL];
15+
}

tests/ui/crashes/ice-6252.stderr

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error[E0412]: cannot find type `PhantomData` in this scope
2+
--> $DIR/ice-6252.rs:9:9
3+
|
4+
LL | _n: PhantomData,
5+
| ^^^^^^^^^^^ not found in this scope
6+
|
7+
help: consider importing this struct
8+
|
9+
LL | use std::marker::PhantomData;
10+
|
11+
12+
error[E0412]: cannot find type `VAL` in this scope
13+
--> $DIR/ice-6252.rs:11:63
14+
|
15+
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
16+
| - ^^^ not found in this scope
17+
| |
18+
| help: you might be missing a type parameter: `, VAL`
19+
20+
error[E0046]: not all trait items implemented, missing: `VAL`
21+
--> $DIR/ice-6252.rs:11:1
22+
|
23+
LL | const VAL: T;
24+
| ------------- `VAL` from trait
25+
...
26+
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
28+
29+
error: any use of this value will cause an error
30+
--> $DIR/ice-6252.rs:5:5
31+
|
32+
LL | const VAL: T;
33+
| ^^^^^^^^^^^^^ no MIR body is available for DefId(0:5 ~ ice_6252[317d]::TypeVal::VAL)
34+
|
35+
= note: `#[deny(const_err)]` on by default
36+
37+
error[E0080]: evaluation of constant value failed
38+
--> $DIR/ice-6252.rs:14:9
39+
|
40+
LL | [1; <Multiply<Five, Five>>::VAL];
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
42+
43+
error: aborting due to 5 previous errors
44+
45+
Some errors have detailed explanations: E0046, E0080, E0412.
46+
For more information about an error, try `rustc --explain E0046`.

tests/ui/crashes/ice-6254.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// originally from ./src/test/ui/pattern/usefulness/consts-opaque.rs
2+
// panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())',
3+
// compiler/rustc_mir_build/src/thir/pattern/_match.rs:2030:5
4+
5+
#[derive(PartialEq)]
6+
struct Foo(i32);
7+
const FOO_REF_REF: &&Foo = &&Foo(42);
8+
9+
fn main() {
10+
// This used to cause an ICE (https://github.com/rust-lang/rust/issues/78071)
11+
match FOO_REF_REF {
12+
FOO_REF_REF => {},
13+
Foo(_) => {},
14+
}
15+
}

tests/ui/crashes/ice-6254.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
2+
--> $DIR/ice-6254.rs:12:9
3+
|
4+
LL | FOO_REF_REF => {},
5+
| ^^^^^^^^^^^
6+
|
7+
= note: `-D indirect-structural-match` implied by `-D warnings`
8+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9+
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
10+
11+
error: aborting due to previous error
12+

tests/ui/crashes/ice-6255.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// originally from rustc ./src/test/ui/macros/issue-78325-inconsistent-resolution.rs
2+
// inconsistent resolution for a macro
3+
4+
macro_rules! define_other_core {
5+
( ) => {
6+
extern crate std as core;
7+
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
8+
};
9+
}
10+
11+
fn main() {
12+
core::panic!();
13+
}
14+
15+
define_other_core!();

tests/ui/crashes/ice-6255.stderr

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
2+
--> $DIR/ice-6255.rs:6:9
3+
|
4+
LL | extern crate std as core;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
...
7+
LL | define_other_core!();
8+
| --------------------- in this macro invocation
9+
|
10+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
11+
12+
error: aborting due to previous error
13+

tests/ui/crashes/ice-6256.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// originally from rustc ./src/test/ui/regions/issue-78262.rs
2+
// ICE: to get the signature of a closure, use substs.as_closure().sig() not fn_sig()
3+
4+
trait TT {}
5+
6+
impl dyn TT {
7+
fn func(&self) {}
8+
}
9+
10+
fn main() {
11+
let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
12+
//[nll]~^ ERROR: borrowed data escapes outside of closure
13+
}

tests/ui/crashes/ice-6256.stderr

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/ice-6256.rs:11:28
3+
|
4+
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
5+
| ^^^^ lifetime mismatch
6+
|
7+
= note: expected reference `&(dyn TT + 'static)`
8+
found reference `&dyn TT`
9+
note: the anonymous lifetime #1 defined on the body at 11:13...
10+
--> $DIR/ice-6256.rs:11:13
11+
|
12+
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
13+
| ^^^^^^^^^^^^^^^^^^^^^
14+
= note: ...does not necessarily outlive the static lifetime
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)