-
Notifications
You must be signed in to change notification settings - Fork 13k
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 more ice tests #122863
Merged
Merged
add more ice tests #122863
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1bcbed1
add test for #110696
matthiaskrgr 4d9ce7a
add test for ice #121472
matthiaskrgr 2b57403
add test for https://github.com/rust-lang/rust/issues/112823
matthiaskrgr d7e166d
add test for ice "type mismatching when copying!"
matthiaskrgr b0e1008
add test for ice #113017 no entry found for key in generics_of.rs
matthiaskrgr bd2d70d
add test for ice #119275 "no entry found for key" in predicates_of.rs
matthiaskrgr e68cb00
address review comments
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
13 changes: 13 additions & 0 deletions
13
tests/ui/const-generics/generic_const_exprs/ice-generics_of-no-entry-found-for-key-113017.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,13 @@ | ||
// test for ICE "no entry found for key" in generics_of.rs #113017 | ||
|
||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
pub fn foo() | ||
where | ||
for<const N: usize = { || {}; 1 }> ():, | ||
//~^ ERROR only lifetime parameters can be used in this context | ||
//~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders | ||
{} | ||
|
||
pub fn main() {} |
19 changes: 19 additions & 0 deletions
19
...i/const-generics/generic_const_exprs/ice-generics_of-no-entry-found-for-key-113017.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,19 @@ | ||
error[E0658]: only lifetime parameters can be used in this context | ||
--> $DIR/ice-generics_of-no-entry-found-for-key-113017.rs:8:15 | ||
| | ||
LL | for<const N: usize = { || {}; 1 }> ():, | ||
| ^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: defaults for generic parameters are not allowed in `for<...>` binders | ||
--> $DIR/ice-generics_of-no-entry-found-for-key-113017.rs:8:9 | ||
| | ||
LL | for<const N: usize = { || {}; 1 }> ():, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
18 changes: 18 additions & 0 deletions
18
.../ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.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,18 @@ | ||
// test for ICE #119275 "no entry found for key" in predicates_of.rs | ||
|
||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
fn bug<const N: Nat>(&self) | ||
//~^ ERROR `self` parameter is only allowed in associated functions | ||
//~^^ ERROR cannot find type `Nat` in this scope | ||
where | ||
for<const N: usize = 3, T = u32> [(); COT::BYTES]:, | ||
//~^ ERROR only lifetime parameters can be used in this context | ||
//~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders | ||
//~^^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders | ||
//~^^^^ ERROR failed to resolve: use of undeclared type `COT` | ||
{ | ||
} | ||
|
||
pub fn main() {} |
46 changes: 46 additions & 0 deletions
46
...const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.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,46 @@ | ||
error: `self` parameter is only allowed in associated functions | ||
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:22 | ||
| | ||
LL | fn bug<const N: Nat>(&self) | ||
| ^^^^^ not semantically valid as function parameter | ||
| | ||
= note: associated functions are those in `impl` or `trait` definitions | ||
|
||
error[E0412]: cannot find type `Nat` in this scope | ||
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:17 | ||
| | ||
LL | fn bug<const N: Nat>(&self) | ||
| ^^^ not found in this scope | ||
|
||
error[E0658]: only lifetime parameters can be used in this context | ||
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:15 | ||
| | ||
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:, | ||
| ^ ^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: defaults for generic parameters are not allowed in `for<...>` binders | ||
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:9 | ||
| | ||
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:, | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: defaults for generic parameters are not allowed in `for<...>` binders | ||
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:29 | ||
| | ||
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:, | ||
| ^^^^^^^ | ||
|
||
error[E0433]: failed to resolve: use of undeclared type `COT` | ||
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:43 | ||
| | ||
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:, | ||
| ^^^ use of undeclared type `COT` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0433, E0658. | ||
For more information about an error, try `rustc --explain E0412`. |
20 changes: 20 additions & 0 deletions
20
tests/ui/const_prop/ice-type-mismatch-when-copying-112824.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,20 @@ | ||
// test for #112824 ICE type mismatching when copying! | ||
|
||
pub struct Opcode(pub u8); | ||
|
||
pub struct Opcode2(&'a S); | ||
//~^ ERROR use of undeclared lifetime name `'a` | ||
//~^^ ERROR cannot find type `S` in this scope | ||
|
||
impl Opcode2 { | ||
pub const OP2: Opcode2 = Opcode2(Opcode(0x1)); | ||
} | ||
|
||
pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) { | ||
move |i| match msg_type { | ||
Opcode2::OP2 => unimplemented!(), | ||
//~^ ERROR could not evaluate constant pattern | ||
} | ||
} | ||
|
||
pub fn main() {} |
29 changes: 29 additions & 0 deletions
29
tests/ui/const_prop/ice-type-mismatch-when-copying-112824.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,29 @@ | ||
error[E0261]: use of undeclared lifetime name `'a` | ||
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21 | ||
| | ||
LL | pub struct Opcode2(&'a S); | ||
| - ^^ undeclared lifetime | ||
| | | ||
| help: consider introducing lifetime `'a` here: `<'a>` | ||
|
||
error[E0412]: cannot find type `S` in this scope | ||
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24 | ||
| | ||
LL | pub struct Opcode2(&'a S); | ||
| ^ not found in this scope | ||
| | ||
help: you might be missing a type parameter | ||
| | ||
LL | pub struct Opcode2<S>(&'a S); | ||
| +++ | ||
|
||
error: could not evaluate constant pattern | ||
--> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9 | ||
| | ||
LL | Opcode2::OP2 => unimplemented!(), | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0261, E0412. | ||
For more information about an error, try `rustc --explain E0261`. |
30 changes: 30 additions & 0 deletions
30
tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.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,30 @@ | ||
// test for ICE #112823 | ||
// Unexpected parameter Type(Repr) when substituting in region | ||
|
||
#![feature(impl_trait_in_assoc_type)] | ||
|
||
use std::future::Future; | ||
|
||
trait Stream {} | ||
|
||
trait X { | ||
type LineStream<'a, Repr> | ||
where | ||
Self: 'a; | ||
type LineStreamFut<'a, Repr> | ||
where | ||
Self: 'a; | ||
} | ||
|
||
struct Y; | ||
|
||
impl X for Y { | ||
type LineStream<'c, 'd> = impl Stream; | ||
//~^ ERROR type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter | ||
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>; | ||
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ||
//~^ ERROR `()` is not a future | ||
//~^^ method `line_stream` is not a member of trait `X` | ||
} | ||
|
||
pub fn main() {} |
31 changes: 31 additions & 0 deletions
31
tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.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,31 @@ | ||
error[E0407]: method `line_stream` is not a member of trait `X` | ||
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:5 | ||
| | ||
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X` | ||
|
||
error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter | ||
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:22:21 | ||
| | ||
LL | type LineStream<'a, Repr> | ||
| -- ---- | ||
| | | ||
| expected 1 type parameter | ||
... | ||
LL | type LineStream<'c, 'd> = impl Stream; | ||
| ^^ ^^ | ||
| | | ||
| found 0 type parameters | ||
|
||
error[E0277]: `()` is not a future | ||
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:43 | ||
| | ||
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future | ||
| | ||
= help: the trait `Future` is not implemented for `()` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0049, E0277, E0407. | ||
For more information about an error, try `rustc --explain E0049`. |
52 changes: 52 additions & 0 deletions
52
tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.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,52 @@ | ||
// test for #110696 | ||
// failed to resolve instance for <Scope<()> as MyIndex<()>>::my_index | ||
// ignore-tidy-linelength | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of that adapt the formatting/don't use the full message for the expected error? 🤔 |
||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
use std::marker::PhantomData; | ||
|
||
|
||
trait MyIndex<T> { | ||
type O; | ||
fn my_index(self) -> Self::O; | ||
} | ||
trait MyFrom<T>: Sized { | ||
type Error; | ||
fn my_from(value: T) -> Result<Self, Self::Error>; | ||
} | ||
|
||
|
||
trait F {} | ||
impl F for () {} | ||
type DummyT<T> = impl F; | ||
fn _dummy_t<T>() -> DummyT<T> {} | ||
|
||
struct Phantom1<T>(PhantomData<T>); | ||
struct Phantom2<T>(PhantomData<T>); | ||
struct Scope<T>(Phantom2<DummyT<T>>); | ||
|
||
impl<T> Scope<T> { | ||
fn new() -> Self { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> { | ||
type Error = (); | ||
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> { | ||
//~^ ERROR the type parameter `T` is not constrained by the impl | ||
type O = T; | ||
fn my_index(self) -> Self::O { | ||
MyFrom::my_from(self.0).ok().unwrap() | ||
} | ||
} | ||
|
||
fn main() { | ||
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index(); | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.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,9 @@ | ||
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/ice-failed-to-resolve-instance-for-110696.rs:42:6 | ||
| | ||
LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> { | ||
| ^ unconstrained type parameter | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0207`. |
16 changes: 16 additions & 0 deletions
16
tests/ui/type-alias-impl-trait/underef-index-out-of-bounds-121472.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 @@ | ||
// test for ICE #121472 index out of bounds un_derefer.rs | ||
#![feature(type_alias_impl_trait)] | ||
|
||
trait T {} | ||
|
||
type Alias<'a> = impl T; | ||
|
||
struct S; | ||
impl<'a> T for &'a S {} | ||
|
||
fn with_positive(fun: impl Fn(Alias<'_>)) {} | ||
|
||
fn main() { | ||
with_positive(|&n| ()); | ||
//~^ ERROR mismatched types | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/ui/type-alias-impl-trait/underef-index-out-of-bounds-121472.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 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/underef-index-out-of-bounds-121472.rs:14:20 | ||
| | ||
LL | type Alias<'a> = impl T; | ||
| ------ the expected opaque type | ||
... | ||
LL | with_positive(|&n| ()); | ||
| ^^ | ||
| | | ||
| expected opaque type, found `&_` | ||
| expected due to this | ||
| | ||
= note: expected opaque type `Alias<'_>` | ||
found reference `&_` | ||
help: consider removing `&` from the pattern | ||
| | ||
LL - with_positive(|&n| ()); | ||
LL + with_positive(|n| ()); | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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.
I would expecct that this file is still not minimized for this ICE
and believe that most of the syntax issues don't contribute to the ICE and make it more likely this tests ends up being ineffective once we change the way we handle such errors when continuing compilation.
It would be nice to manually spend a few minutes trying to fix all unrelated errors while tracking whether the ICE still triggers.
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.
well what you call "syntax issues" I call "additional coverage" 😄
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.
what I mean is, we want tests to also protect against future ICEs and minimizing everything to the absolute minimum just reduces the effectiveness in that regard
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.
I'll use the example from #113017 (comment)