Skip to content

Commit 35a7845

Browse files
committed
add test for #122098 ICE: index out of bounds, snapshot_vec.rs
Fixes #122098
1 parent 7d01878 commit 35a7845

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// test for #122098 ICE snapshot_vec.rs: index out of bounds: the len is 4 but the index is 4
2+
3+
trait LendingIterator {
4+
type Item<'q>: 'a;
5+
//~^ ERROR use of undeclared lifetime name `'a`
6+
7+
fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
8+
//~^ ERROR the size for values of type `Self` cannot be known at compilation time
9+
}
10+
11+
struct Query<'q> {}
12+
//~^ ERROR lifetime parameter `'q` is never used
13+
14+
impl<'static> Query<'q> {
15+
//~^ ERROR invalid lifetime parameter name: `'static`
16+
//~^^ ERROR use of undeclared lifetime name `'q`
17+
pub fn new() -> Self {}
18+
}
19+
20+
fn data() {
21+
LendingIterator::for_each(Query::new(&data), Box::new);
22+
//~^ ERROR this function takes 0 arguments but 1 argument was supplied
23+
}
24+
25+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:4:20
3+
|
4+
LL | type Item<'q>: 'a;
5+
| ^^ undeclared lifetime
6+
|
7+
help: consider introducing lifetime `'a` here
8+
|
9+
LL | type Item<'a, 'q>: 'a;
10+
| +++
11+
help: consider introducing lifetime `'a` here
12+
|
13+
LL | trait LendingIterator<'a> {
14+
| ++++
15+
16+
error[E0262]: invalid lifetime parameter name: `'static`
17+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:6
18+
|
19+
LL | impl<'static> Query<'q> {
20+
| ^^^^^^^ 'static is a reserved lifetime name
21+
22+
error[E0261]: use of undeclared lifetime name `'q`
23+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:21
24+
|
25+
LL | impl<'static> Query<'q> {
26+
| - ^^ undeclared lifetime
27+
| |
28+
| help: consider introducing lifetime `'q` here: `'q,`
29+
30+
error[E0392]: lifetime parameter `'q` is never used
31+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:11:14
32+
|
33+
LL | struct Query<'q> {}
34+
| ^^ unused lifetime parameter
35+
|
36+
= help: consider removing `'q`, referring to it in a field, or using a marker such as `PhantomData`
37+
38+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
39+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:7:17
40+
|
41+
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
42+
| ^^^^^^^^ doesn't have a size known at compile-time
43+
|
44+
= help: unsized fn params are gated as an unstable feature
45+
help: consider further restricting `Self`
46+
|
47+
LL | fn for_each(mut self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) where Self: Sized {}
48+
| +++++++++++++++++
49+
help: function arguments must have a statically known size, borrowed types always have a known size
50+
|
51+
LL | fn for_each(mut &self, mut f: Box<dyn FnMut(Self::Item<'_>) + 'static>) {}
52+
| +
53+
54+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
55+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:21:31
56+
|
57+
LL | LendingIterator::for_each(Query::new(&data), Box::new);
58+
| ^^^^^^^^^^ -----
59+
| |
60+
| unexpected argument of type `&fn() {data}`
61+
| help: remove the extra argument
62+
|
63+
note: associated function defined here
64+
--> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:17:12
65+
|
66+
LL | pub fn new() -> Self {}
67+
| ^^^
68+
69+
error: aborting due to 6 previous errors
70+
71+
Some errors have detailed explanations: E0061, E0261, E0262, E0277, E0392.
72+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)