Skip to content

Commit

Permalink
add test for #122098 ICE: index out of bounds, snapshot_vec.rs
Browse files Browse the repository at this point in the history
Fixes #122098
  • Loading branch information
matthiaskrgr committed Mar 21, 2024
1 parent 7d01878 commit 35a7845
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/ui/inference/ice-ifer-var-leaked-out-of-rollback-122098.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// test for #122098 ICE snapshot_vec.rs: index out of bounds: the len is 4 but the index is 4

trait LendingIterator {
type Item<'q>: 'a;
//~^ ERROR use of undeclared lifetime name `'a`

fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
//~^ ERROR the size for values of type `Self` cannot be known at compilation time
}

struct Query<'q> {}
//~^ ERROR lifetime parameter `'q` is never used

impl<'static> Query<'q> {
//~^ ERROR invalid lifetime parameter name: `'static`
//~^^ ERROR use of undeclared lifetime name `'q`
pub fn new() -> Self {}
}

fn data() {
LendingIterator::for_each(Query::new(&data), Box::new);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:4:20
|
LL | type Item<'q>: 'a;
| ^^ undeclared lifetime
|
help: consider introducing lifetime `'a` here
|
LL | type Item<'a, 'q>: 'a;
| +++
help: consider introducing lifetime `'a` here
|
LL | trait LendingIterator<'a> {
| ++++

error[E0262]: invalid lifetime parameter name: `'static`
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:6
|
LL | impl<'static> Query<'q> {
| ^^^^^^^ 'static is a reserved lifetime name

error[E0261]: use of undeclared lifetime name `'q`
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:21
|
LL | impl<'static> Query<'q> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'q` here: `'q,`

error[E0392]: lifetime parameter `'q` is never used
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:11:14
|
LL | struct Query<'q> {}
| ^^ unused lifetime parameter
|
= help: consider removing `'q`, referring to it in a field, or using a marker such as `PhantomData`

error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:7:17
|
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
| ^^^^^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) where Self: Sized {}
| +++++++++++++++++
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | fn for_each(mut &self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
| +

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:21:31
|
LL | LendingIterator::for_each(Query::new(&data), Box::new);
| ^^^^^^^^^^ -----
| |
| unexpected argument of type `&fn() {data}`
| help: remove the extra argument
|
note: associated function defined here
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:17:12
|
LL | pub fn new() -> Self {}
| ^^^

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0061, E0261, E0262, E0277, E0392.
For more information about an error, try `rustc --explain E0061`.

0 comments on commit 35a7845

Please sign in to comment.