add a couple of ICE testcases

Fixes #6250
Fixes #6251
Fixes #6252
Fixes #6255
Fixes #6256
This commit is contained in:
Matthias Krüger 2020-10-28 14:45:21 +01:00
parent 645ef505da
commit abd64d7c05
12 changed files with 239 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// originally from glacier/fixed/77218.rs
// ice while adjusting...
pub struct Cache {
data: Vec<i32>,
}
pub fn list_data(cache: &Cache, key: usize) {
for reference in vec![1, 2, 3] {
if
/* let */
Some(reference) = cache.data.get(key) {
unimplemented!()
}
}
}

View File

@ -0,0 +1,27 @@
error[E0601]: `main` function not found in crate `ice_6250`
--> $DIR/ice-6250.rs:4:1
|
LL | / pub struct Cache {
LL | | data: Vec<i32>,
LL | | }
LL | |
... |
LL | | }
LL | | }
| |_^ consider adding a `main` function to `$DIR/ice-6250.rs`
error[E0308]: mismatched types
--> $DIR/ice-6250.rs:12:9
|
LL | Some(reference) = cache.data.get(key) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
|
help: you might have meant to use pattern matching
|
LL | let Some(reference) = cache.data.get(key) {
| ^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0308, E0601.
For more information about an error, try `rustc --explain E0308`.

View File

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

View File

@ -0,0 +1,43 @@
error[E0601]: `main` function not found in crate `ice_6251`
--> $DIR/ice-6251.rs:4:1
|
LL | / fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
LL | | std::iter::empty()
LL | | }
| |_^ consider adding a `main` function to `$DIR/ice-6251.rs`
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/ice-6251.rs:4:45
|
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
| ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
= help: unsized fn params are gated as an unstable feature
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | fn bug<T>() -> impl Iterator<Item = [(); { |&x: [u8]| x }]> {
| ^
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/ice-6251.rs:4:54
|
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
| ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
= note: the return type of a function must have a statically known size
error[E0308]: mismatched types
--> $DIR/ice-6251.rs:4:44
|
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
| ^^^^^^^^^^^ expected `usize`, found closure
|
= note: expected type `usize`
found closure `[closure@$DIR/ice-6251.rs:4:44: 4:55]`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0308, E0601.
For more information about an error, try `rustc --explain E0277`.

View File

@ -0,0 +1,15 @@
// originally from glacier fixed/77919.rs
// encountered errors resolving bounds after type-checking
trait TypeVal<T> {
const VAL: T;
}
struct Five;
struct Multiply<N, M> {
_n: PhantomData,
}
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
fn main() {
[1; <Multiply<Five, Five>>::VAL];
}

View File

@ -0,0 +1,46 @@
error[E0412]: cannot find type `PhantomData` in this scope
--> $DIR/ice-6252.rs:9:9
|
LL | _n: PhantomData,
| ^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
LL | use std::marker::PhantomData;
|
error[E0412]: cannot find type `VAL` in this scope
--> $DIR/ice-6252.rs:11:63
|
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| - ^^^ not found in this scope
| |
| help: you might be missing a type parameter: `, VAL`
error[E0046]: not all trait items implemented, missing: `VAL`
--> $DIR/ice-6252.rs:11:1
|
LL | const VAL: T;
| ------------- `VAL` from trait
...
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
error: any use of this value will cause an error
--> $DIR/ice-6252.rs:5:5
|
LL | const VAL: T;
| ^^^^^^^^^^^^^ no MIR body is available for DefId(0:5 ~ ice_6252[317d]::TypeVal::VAL)
|
= note: `#[deny(const_err)]` on by default
error[E0080]: evaluation of constant value failed
--> $DIR/ice-6252.rs:14:9
|
LL | [1; <Multiply<Five, Five>>::VAL];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0046, E0080, E0412.
For more information about an error, try `rustc --explain E0046`.

View File

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

View File

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

View File

@ -0,0 +1,15 @@
// originally from rustc ./src/test/ui/macros/issue-78325-inconsistent-resolution.rs
// inconsistent resolution for a macro
macro_rules! define_other_core {
( ) => {
extern crate std as core;
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
};
}
fn main() {
core::panic!();
}
define_other_core!();

View File

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

View File

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

View File

@ -0,0 +1,18 @@
error[E0308]: mismatched types
--> $DIR/ice-6256.rs:11:28
|
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
| ^^^^ lifetime mismatch
|
= note: expected reference `&(dyn TT + 'static)`
found reference `&dyn TT`
note: the anonymous lifetime #1 defined on the body at 11:13...
--> $DIR/ice-6256.rs:11:13
|
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...does not necessarily outlive the static lifetime
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.