Skip to content

Commit 6e6c721

Browse files
committed
Auto merge of rust-lang#122895 - matthiaskrgr:ice-tests-5xxxx-to-9xxxx, r=fmease
add some ice tests 5xxxx to 9xxxx Fixes rust-lang#98842 Fixes rust-lang#90691 Fixes rust-lang#88421 Fixes rust-lang#88212 Fixes rust-lang#83056 Fixes rust-lang#80125 Fixes rust-lang#64784 Fixes rust-lang#52334
2 parents 6a92312 + 114d012 commit 6e6c721

15 files changed

+346
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// ICE #90691 Encountered error `Unimplemented` selecting ...
2+
//@ build-pass
3+
// issue: rust-lang/rust#90691
4+
5+
trait TError: std::fmt::Debug {}
6+
impl TError for () {}
7+
8+
trait SuperTrait {
9+
type Error;
10+
}
11+
12+
trait Trait: SuperTrait<Error: TError> {}
13+
14+
impl<T> Trait for T
15+
where
16+
T: SuperTrait,
17+
<T as SuperTrait>::Error: TError,
18+
{
19+
}
20+
21+
struct SomeTrait<S>(S);
22+
struct BoxedTrait(Box<dyn Trait<Error = ()>>);
23+
24+
impl<S: 'static> From<SomeTrait<S>> for BoxedTrait {
25+
fn from(other: SomeTrait<S>) -> Self {
26+
Self(Box::new(other))
27+
}
28+
}
29+
30+
impl<S> SuperTrait for SomeTrait<S> {
31+
type Error = ();
32+
}
33+
34+
impl From<()> for BoxedTrait {
35+
fn from(c: ()) -> Self {
36+
Self::from(SomeTrait(c))
37+
}
38+
}
39+
40+
fn main() {
41+
let _: BoxedTrait = ().into();
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//@ check-pass
2+
// issue: rust-lang/rust#88421
3+
#![feature(adt_const_params)]
4+
#![feature(generic_const_exprs)]
5+
#![allow(incomplete_features)]
6+
7+
use std::ops::Index;
8+
9+
pub struct CellPossibilities;
10+
11+
pub enum CellState<const SQUARE_SIZE: usize> {
12+
Empty(Option<CellPossibilities>),
13+
}
14+
15+
pub struct Sudoku<const SQUARE_SIZE: usize>;
16+
17+
impl<const SQUARE_SIZE: usize> Sudoku<SQUARE_SIZE>where
18+
[CellState<SQUARE_SIZE>; SQUARE_SIZE * SQUARE_SIZE]: Sized,
19+
{
20+
pub fn random() {
21+
let CellState::Empty(_) = Self[()];
22+
}
23+
}
24+
25+
impl<const SQUARE_SIZE: usize> Index<()> for Sudoku<SQUARE_SIZE>
26+
where
27+
[CellState<SQUARE_SIZE>; SQUARE_SIZE * SQUARE_SIZE]: Sized,
28+
{
29+
type Output = CellState<SQUARE_SIZE>;
30+
31+
fn index(&self, _: ()) -> &Self::Output {
32+
todo!()
33+
}
34+
}
35+
36+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #83056 ICE "bad input type for cast"
2+
// issue: rust-lang/rust#83056
3+
4+
struct S([bool; f as usize]);
5+
fn f() -> T {}
6+
//~^ ERROR cannot find type `T` in this scope
7+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0412]: cannot find type `T` in this scope
2+
--> $DIR/ice-bad-input-type-for-cast-83056.rs:5:11
3+
|
4+
LL | struct S([bool; f as usize]);
5+
| ----------------------------- similarly named struct `S` defined here
6+
LL | fn f() -> T {}
7+
| ^
8+
|
9+
help: a struct with a similar name exists
10+
|
11+
LL | fn f() -> S {}
12+
| ~
13+
help: you might be missing a type parameter
14+
|
15+
LL | fn f<T>() -> T {}
16+
| +++
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// test for ICE when casting extern "C" fn when it has a non-FFI-safe argument
2+
// issue: rust-lang/rust#52334
3+
//@ check-pass
4+
//@ normalize-stderr-test "\[i8\]" -> "[i8 or u8 (arch dependant)]"
5+
//@ normalize-stderr-test "\[u8\]" -> "[i8 or u8 (arch dependant)]"
6+
7+
type Foo = extern "C" fn(::std::ffi::CStr);
8+
//~^ WARN `extern` fn uses type
9+
extern "C" {
10+
fn meh(blah: Foo);
11+
//~^ WARN `extern` block uses type
12+
}
13+
14+
fn main() {
15+
meh as usize;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
warning: `extern` fn uses type `[i8 or u8 (arch dependant)]`, which is not FFI-safe
2+
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:7:12
3+
|
4+
LL | type Foo = extern "C" fn(::std::ffi::CStr);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
6+
|
7+
= help: consider using a raw pointer instead
8+
= note: slices have no C equivalent
9+
= note: `#[warn(improper_ctypes_definitions)]` on by default
10+
11+
warning: `extern` block uses type `[i8 or u8 (arch dependant)]`, which is not FFI-safe
12+
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:10:18
13+
|
14+
LL | fn meh(blah: Foo);
15+
| ^^^ not FFI-safe
16+
|
17+
= help: consider using a raw pointer instead
18+
= note: slices have no C equivalent
19+
= note: `#[warn(improper_ctypes)]` on by default
20+
21+
warning: 2 warnings emitted
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// issue: rust-lang/rust#80125
2+
//@ check-pass
3+
type ExternCallback = extern "C" fn(*const u8, u32, str);
4+
//~^ WARN `extern` fn uses type `str`, which is not FFI-safe
5+
6+
pub struct Struct(ExternCallback);
7+
8+
#[no_mangle]
9+
pub extern "C" fn register_something(bind: ExternCallback) -> Struct {
10+
//~^ WARN `extern` fn uses type `str`, which is not FFI-safe
11+
//~^^ WARN `extern` fn uses type `Struct`, which is not FFI-safe
12+
Struct(bind)
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
warning: `extern` fn uses type `str`, which is not FFI-safe
2+
--> $DIR/extern-C-str-arg-ice-80125.rs:3:23
3+
|
4+
LL | type ExternCallback = extern "C" fn(*const u8, u32, str);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
6+
|
7+
= help: consider using `*const u8` and a length instead
8+
= note: string slices have no C equivalent
9+
= note: `#[warn(improper_ctypes_definitions)]` on by default
10+
11+
warning: `extern` fn uses type `str`, which is not FFI-safe
12+
--> $DIR/extern-C-str-arg-ice-80125.rs:9:44
13+
|
14+
LL | pub extern "C" fn register_something(bind: ExternCallback) -> Struct {
15+
| ^^^^^^^^^^^^^^ not FFI-safe
16+
|
17+
= help: consider using `*const u8` and a length instead
18+
= note: string slices have no C equivalent
19+
20+
warning: `extern` fn uses type `Struct`, which is not FFI-safe
21+
--> $DIR/extern-C-str-arg-ice-80125.rs:9:63
22+
|
23+
LL | pub extern "C" fn register_something(bind: ExternCallback) -> Struct {
24+
| ^^^^^^ not FFI-safe
25+
|
26+
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
27+
= note: this struct has unspecified layout
28+
note: the type is defined here
29+
--> $DIR/extern-C-str-arg-ice-80125.rs:6:1
30+
|
31+
LL | pub struct Struct(ExternCallback);
32+
| ^^^^^^^^^^^^^^^^^
33+
34+
warning: 3 warnings emitted
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// ICE #64784 already borrowed: BorrowMutError
2+
//@ check-pass
3+
// issue: rust-lang/rust#64784
4+
#![feature(decl_macro)]
5+
6+
pub macro m($i:ident, $j:ident) {
7+
mod $i {
8+
pub use crate::$j::*;
9+
pub struct A;
10+
}
11+
}
12+
13+
m!(x, y);
14+
m!(y, x);
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0391]: cycle detected when computing layout of `Foo`
2+
|
3+
= note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`...
4+
= note: ...which again requires computing layout of `Foo`, completing the cycle
5+
note: cycle used when const-evaluating + checking `_`
6+
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1
7+
|
8+
LL | const _: *const Foo = 0 as _;
9+
| ^^^^^^^^^^^^^^^^^^^
10+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
11+
12+
error[E0080]: it is undefined behavior to use this value
13+
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1
14+
|
15+
LL | const _: *const Foo = 0 as _;
16+
| ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation
17+
|
18+
= note: the raw bytes of the constant (size: 4, align: 4) {
19+
00 00 00 00 │ ....
20+
}
21+
22+
error: aborting due to 2 previous errors
23+
24+
Some errors have detailed explanations: E0080, E0391.
25+
For more information about an error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0391]: cycle detected when computing layout of `Foo`
2+
|
3+
= note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`...
4+
= note: ...which again requires computing layout of `Foo`, completing the cycle
5+
note: cycle used when const-evaluating + checking `_`
6+
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1
7+
|
8+
LL | const _: *const Foo = 0 as _;
9+
| ^^^^^^^^^^^^^^^^^^^
10+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
11+
12+
error[E0080]: it is undefined behavior to use this value
13+
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1
14+
|
15+
LL | const _: *const Foo = 0 as _;
16+
| ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation
17+
|
18+
= note: the raw bytes of the constant (size: 8, align: 8) {
19+
00 00 00 00 00 00 00 00 │ ........
20+
}
21+
22+
error: aborting due to 2 previous errors
23+
24+
Some errors have detailed explanations: E0080, E0391.
25+
For more information about an error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// #98842 stack overflow in trait inference
2+
// issue: rust-lang/rust#98842
3+
//@ check-fail
4+
//@ edition:2021
5+
//@ stderr-per-bitwidth
6+
//@ ignore-endian-big
7+
//~^^^^^^ ERROR cycle detected when computing layout of `Foo`
8+
9+
// If the inner `Foo` is named through an associated type,
10+
// the "infinite size" error does not occur.
11+
struct Foo(<&'static Foo as ::core::ops::Deref>::Target);
12+
// But Rust will be unable to know whether `Foo` is sized or not,
13+
// and it will infinitely recurse somewhere trying to figure out the
14+
// size of this pointer (is my guess):
15+
const _: *const Foo = 0 as _;
16+
//~^ ERROR it is undefined behavior to use this value
17+
18+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0391]: cycle detected when computing layout of `Foo`
2+
|
3+
= note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`...
4+
= note: ...which again requires computing layout of `Foo`, completing the cycle
5+
note: cycle used when const-evaluating + checking `_`
6+
--> $DIR/stack-overflow-trait-infer-98842.rs:13:1
7+
|
8+
LL | const _: *const Foo = 0 as _;
9+
| ^^^^^^^^^^^^^^^^^^^
10+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
11+
12+
error[E0080]: it is undefined behavior to use this value
13+
--> $DIR/stack-overflow-trait-infer-98842.rs:13:1
14+
|
15+
LL | const _: *const Foo = 0 as _;
16+
| ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation
17+
|
18+
= note: the raw bytes of the constant (size: 8, align: 8) {
19+
00 00 00 00 00 00 00 00 │ ........
20+
}
21+
22+
error: aborting due to 2 previous errors
23+
24+
Some errors have detailed explanations: E0080, E0391.
25+
For more information about an error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ICE size_and_align_of::<[[email protected]:15:5: 17:7]> not supported #88212
2+
// issue: rust-lang/rust#88212
3+
#![feature(unsized_locals)]
4+
//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
5+
6+
trait Example {}
7+
struct Foo();
8+
9+
impl Example for Foo {}
10+
11+
fn example() -> Box<dyn Example> {
12+
Box::new(Foo())
13+
}
14+
15+
fn main() {
16+
let x: dyn Example = *example();
17+
(move || {
18+
let _y = x;
19+
//~^ ERROR the size for values of type `dyn Example` cannot be known at compilation time
20+
})();
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:3:12
3+
|
4+
LL | #![feature(unsized_locals)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: the size for values of type `dyn Example` cannot be known at compilation time
11+
--> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:18:18
12+
|
13+
LL | (move || {
14+
| -- this closure captures all values by move
15+
LL | let _y = x;
16+
| ^ doesn't have a size known at compile-time
17+
|
18+
= help: the trait `Sized` is not implemented for `dyn Example`
19+
= note: all values captured by value by a closure must have a statically known size
20+
21+
error: aborting due to 1 previous error; 1 warning emitted
22+
23+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)