-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add some ice tests 5xxxx to 9xxxx #122895
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
14d05c4
add test for #52334
matthiaskrgr a5ad0be
add test for #64784 Declarative macros can create infinite glob impo…
matthiaskrgr 19310ce
add test for str as extern "C" arg causes compiler panic #80125
matthiaskrgr 445507a
add test for ice 83056 "bad input type for cast"
matthiaskrgr 74ca981
add test for #88212 ICE when lambda captures unsized local
matthiaskrgr f44ee8f
add test for 88421 ICE: could not fully normalize `&<MyType as std::o…
matthiaskrgr 5ae9025
add test for ice #90691 ICE: resolution failed during building vtable…
matthiaskrgr 57f5005
add test for stack overflow with recursive type #98842
matthiaskrgr 114d012
add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directive
matthiaskrgr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
.../ui/associated-type-bounds/resolution-failure-building-vtable-representation-ice-90691.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// ICE #90691 Encountered error `Unimplemented` selecting ... | ||
//@ build-pass | ||
// issue: rust-lang/rust#90691 | ||
|
||
trait TError: std::fmt::Debug {} | ||
impl TError for () {} | ||
|
||
trait SuperTrait { | ||
type Error; | ||
} | ||
|
||
trait Trait: SuperTrait<Error: TError> {} | ||
|
||
impl<T> Trait for T | ||
where | ||
T: SuperTrait, | ||
<T as SuperTrait>::Error: TError, | ||
{ | ||
} | ||
|
||
struct SomeTrait<S>(S); | ||
struct BoxedTrait(Box<dyn Trait<Error = ()>>); | ||
|
||
impl<S: 'static> From<SomeTrait<S>> for BoxedTrait { | ||
fn from(other: SomeTrait<S>) -> Self { | ||
Self(Box::new(other)) | ||
} | ||
} | ||
|
||
impl<S> SuperTrait for SomeTrait<S> { | ||
type Error = (); | ||
} | ||
|
||
impl From<()> for BoxedTrait { | ||
fn from(c: ()) -> Self { | ||
Self::from(SomeTrait(c)) | ||
} | ||
} | ||
|
||
fn main() { | ||
let _: BoxedTrait = ().into(); | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/ui/const-generics/generic_const_exprs/failed-to-normalize-ice-issue-88421.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//@ check-pass | ||
// issue: rust-lang/rust#88421 | ||
#![feature(adt_const_params)] | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::ops::Index; | ||
|
||
pub struct CellPossibilities; | ||
|
||
pub enum CellState<const SQUARE_SIZE: usize> { | ||
Empty(Option<CellPossibilities>), | ||
} | ||
|
||
pub struct Sudoku<const SQUARE_SIZE: usize>; | ||
|
||
impl<const SQUARE_SIZE: usize> Sudoku<SQUARE_SIZE>where | ||
[CellState<SQUARE_SIZE>; SQUARE_SIZE * SQUARE_SIZE]: Sized, | ||
{ | ||
pub fn random() { | ||
let CellState::Empty(_) = Self[()]; | ||
} | ||
} | ||
|
||
impl<const SQUARE_SIZE: usize> Index<()> for Sudoku<SQUARE_SIZE> | ||
where | ||
[CellState<SQUARE_SIZE>; SQUARE_SIZE * SQUARE_SIZE]: Sized, | ||
{ | ||
type Output = CellState<SQUARE_SIZE>; | ||
|
||
fn index(&self, _: ()) -> &Self::Output { | ||
todo!() | ||
} | ||
} | ||
|
||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// #83056 ICE "bad input type for cast" | ||
// issue: rust-lang/rust#83056 | ||
|
||
struct S([bool; f as usize]); | ||
fn f() -> T {} | ||
//~^ ERROR cannot find type `T` in this scope | ||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0412]: cannot find type `T` in this scope | ||
--> $DIR/ice-bad-input-type-for-cast-83056.rs:5:11 | ||
| | ||
LL | struct S([bool; f as usize]); | ||
| ----------------------------- similarly named struct `S` defined here | ||
LL | fn f() -> T {} | ||
| ^ | ||
| | ||
help: a struct with a similar name exists | ||
| | ||
LL | fn f() -> S {} | ||
| ~ | ||
help: you might be missing a type parameter | ||
| | ||
LL | fn f<T>() -> T {} | ||
| +++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0412`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// test for ICE when casting extern "C" fn when it has a non-FFI-safe argument | ||
// issue: rust-lang/rust#52334 | ||
//@ check-pass | ||
//@ normalize-stderr-test "\[i8\]" -> "[i8 or u8 (arch dependant)]" | ||
//@ normalize-stderr-test "\[u8\]" -> "[i8 or u8 (arch dependant)]" | ||
|
||
type Foo = extern "C" fn(::std::ffi::CStr); | ||
//~^ WARN `extern` fn uses type | ||
extern "C" { | ||
fn meh(blah: Foo); | ||
//~^ WARN `extern` block uses type | ||
} | ||
|
||
fn main() { | ||
meh as usize; | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/ui/extern/extern-C-non-FFI-safe-arg-ice-52334.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
warning: `extern` fn uses type `[i8 or u8 (arch dependant)]`, which is not FFI-safe | ||
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:7:12 | ||
| | ||
LL | type Foo = extern "C" fn(::std::ffi::CStr); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | ||
| | ||
= help: consider using a raw pointer instead | ||
= note: slices have no C equivalent | ||
= note: `#[warn(improper_ctypes_definitions)]` on by default | ||
|
||
warning: `extern` block uses type `[i8 or u8 (arch dependant)]`, which is not FFI-safe | ||
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:10:18 | ||
| | ||
LL | fn meh(blah: Foo); | ||
| ^^^ not FFI-safe | ||
| | ||
= help: consider using a raw pointer instead | ||
= note: slices have no C equivalent | ||
= note: `#[warn(improper_ctypes)]` on by default | ||
|
||
warning: 2 warnings emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// issue: rust-lang/rust#80125 | ||
//@ check-pass | ||
type ExternCallback = extern "C" fn(*const u8, u32, str); | ||
//~^ WARN `extern` fn uses type `str`, which is not FFI-safe | ||
|
||
pub struct Struct(ExternCallback); | ||
|
||
#[no_mangle] | ||
pub extern "C" fn register_something(bind: ExternCallback) -> Struct { | ||
//~^ WARN `extern` fn uses type `str`, which is not FFI-safe | ||
//~^^ WARN `extern` fn uses type `Struct`, which is not FFI-safe | ||
Struct(bind) | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
warning: `extern` fn uses type `str`, which is not FFI-safe | ||
--> $DIR/extern-C-str-arg-ice-80125.rs:3:23 | ||
| | ||
LL | type ExternCallback = extern "C" fn(*const u8, u32, str); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | ||
| | ||
= help: consider using `*const u8` and a length instead | ||
= note: string slices have no C equivalent | ||
= note: `#[warn(improper_ctypes_definitions)]` on by default | ||
|
||
warning: `extern` fn uses type `str`, which is not FFI-safe | ||
--> $DIR/extern-C-str-arg-ice-80125.rs:9:44 | ||
| | ||
LL | pub extern "C" fn register_something(bind: ExternCallback) -> Struct { | ||
| ^^^^^^^^^^^^^^ not FFI-safe | ||
| | ||
= help: consider using `*const u8` and a length instead | ||
= note: string slices have no C equivalent | ||
|
||
warning: `extern` fn uses type `Struct`, which is not FFI-safe | ||
--> $DIR/extern-C-str-arg-ice-80125.rs:9:63 | ||
| | ||
LL | pub extern "C" fn register_something(bind: ExternCallback) -> Struct { | ||
| ^^^^^^ not FFI-safe | ||
| | ||
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct | ||
= note: this struct has unspecified layout | ||
note: the type is defined here | ||
--> $DIR/extern-C-str-arg-ice-80125.rs:6:1 | ||
| | ||
LL | pub struct Struct(ExternCallback); | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
warning: 3 warnings emitted | ||
|
16 changes: 16 additions & 0 deletions
16
tests/ui/privacy/decl-macro-infinite-global-import-cycle-ice-64784.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// ICE #64784 already borrowed: BorrowMutError | ||
//@ check-pass | ||
// issue: rust-lang/rust#64784 | ||
#![feature(decl_macro)] | ||
|
||
pub macro m($i:ident, $j:ident) { | ||
mod $i { | ||
pub use crate::$j::*; | ||
pub struct A; | ||
} | ||
} | ||
|
||
m!(x, y); | ||
m!(y, x); | ||
|
||
fn main() {} |
25 changes: 25 additions & 0 deletions
25
tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0391]: cycle detected when computing layout of `Foo` | ||
| | ||
= note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`... | ||
= note: ...which again requires computing layout of `Foo`, completing the cycle | ||
note: cycle used when const-evaluating + checking `_` | ||
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1 | ||
| | ||
LL | const _: *const Foo = 0 as _; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
= 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 | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1 | ||
| | ||
LL | const _: *const Foo = 0 as _; | ||
| ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation | ||
| | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
00 00 00 00 │ .... | ||
} | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0080, E0391. | ||
For more information about an error, try `rustc --explain E0080`. |
25 changes: 25 additions & 0 deletions
25
tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0391]: cycle detected when computing layout of `Foo` | ||
| | ||
= note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`... | ||
= note: ...which again requires computing layout of `Foo`, completing the cycle | ||
note: cycle used when const-evaluating + checking `_` | ||
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1 | ||
| | ||
LL | const _: *const Foo = 0 as _; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
= 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 | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/stack-overflow-trait-infer-98842.rs:15:1 | ||
| | ||
LL | const _: *const Foo = 0 as _; | ||
| ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation | ||
| | ||
= note: the raw bytes of the constant (size: 8, align: 8) { | ||
00 00 00 00 00 00 00 00 │ ........ | ||
} | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0080, E0391. | ||
For more information about an error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// #98842 stack overflow in trait inference | ||
// issue: rust-lang/rust#98842 | ||
//@ check-fail | ||
//@ edition:2021 | ||
//@ stderr-per-bitwidth | ||
//@ ignore-endian-big | ||
//~^^^^^^ ERROR cycle detected when computing layout of `Foo` | ||
|
||
// If the inner `Foo` is named through an associated type, | ||
// the "infinite size" error does not occur. | ||
struct Foo(<&'static Foo as ::core::ops::Deref>::Target); | ||
// But Rust will be unable to know whether `Foo` is sized or not, | ||
// and it will infinitely recurse somewhere trying to figure out the | ||
// size of this pointer (is my guess): | ||
const _: *const Foo = 0 as _; | ||
//~^ ERROR it is undefined behavior to use this value | ||
|
||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0391]: cycle detected when computing layout of `Foo` | ||
| | ||
= note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`... | ||
= note: ...which again requires computing layout of `Foo`, completing the cycle | ||
note: cycle used when const-evaluating + checking `_` | ||
--> $DIR/stack-overflow-trait-infer-98842.rs:13:1 | ||
| | ||
LL | const _: *const Foo = 0 as _; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
= 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 | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/stack-overflow-trait-infer-98842.rs:13:1 | ||
| | ||
LL | const _: *const Foo = 0 as _; | ||
| ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation | ||
| | ||
= note: the raw bytes of the constant (size: 8, align: 8) { | ||
00 00 00 00 00 00 00 00 │ ........ | ||
} | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0080, E0391. | ||
For more information about an error, try `rustc --explain E0080`. |
21 changes: 21 additions & 0 deletions
21
tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ICE size_and_align_of::<[closure@test.rs:15:5: 17:7]> not supported #88212 | ||
// issue: rust-lang/rust#88212 | ||
#![feature(unsized_locals)] | ||
//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes | ||
|
||
trait Example {} | ||
struct Foo(); | ||
|
||
impl Example for Foo {} | ||
|
||
fn example() -> Box<dyn Example> { | ||
Box::new(Foo()) | ||
} | ||
|
||
fn main() { | ||
let x: dyn Example = *example(); | ||
(move || { | ||
let _y = x; | ||
//~^ ERROR the size for values of type `dyn Example` cannot be known at compilation time | ||
})(); | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:3:12 | ||
| | ||
LL | #![feature(unsized_locals)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0277]: the size for values of type `dyn Example` cannot be known at compilation time | ||
--> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:18:18 | ||
| | ||
LL | (move || { | ||
| -- this closure captures all values by move | ||
LL | let _y = x; | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `dyn Example` | ||
= note: all values captured by value by a closure must have a statically known size | ||
|
||
error: aborting due to 1 previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output here doesn't look endianess-dependent, why is this ignored on big-endian targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I don't think there's a meaningful reason for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cc @uweigand might be worth testing this on a big-endian target and removing the annotation if it passes there.
(Sorry for always pinging you here, unfortunately our platform page doesn't list people to ping for our big-endian targets so I am going off of PRs like #106047. If you are part of a group of people that are helping maintain one of our tier 2 targets, please see #113739.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc this was to work around the output differing in #122895 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bitwidth difference, but not an endianess difference.
Also we often use normalization to remove these bitwidth differences as maintaining the bessed output becomes a lot more annoying with stderr-per-bitwidth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply. I've now verified that the test continues to pass on s390x if the annotation is removed.