Skip to content

Commit 2bf76b4

Browse files
committed
Add a regression test for an escaping late-bound region ICE during canonicalisation
1 parent f908263 commit 2bf76b4

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Regression test for https://github.com/rust-lang/rust/issues/113870
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
const fn allow<'b, 'b>() -> usize
7+
//~^ ERROR the name `'b` is already used for a generic parameter in this item's generic parameters
8+
where
9+
for<'b> [u8; foo::<'a, 'b>()]: Sized,
10+
//~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope
11+
//~| ERROR use of undeclared lifetime name `'a`
12+
//~| ERROR cannot capture late-bound lifetime in constant
13+
{
14+
4
15+
}
16+
17+
const fn foo<'a, 'b>() -> usize
18+
where
19+
&'a (): Sized,
20+
&'b (): Sized,
21+
{
22+
4
23+
}
24+
//~^ ERROR `main` function not found in crate
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error[E0403]: the name `'b` is already used for a generic parameter in this item's generic parameters
2+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:6:20
3+
|
4+
LL | const fn allow<'b, 'b>() -> usize
5+
| -- ^^ already used
6+
| |
7+
| first use of `'b`
8+
9+
error[E0496]: lifetime name `'b` shadows a lifetime name that is already in scope
10+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:9
11+
|
12+
LL | const fn allow<'b, 'b>() -> usize
13+
| -- first declared here
14+
...
15+
LL | for<'b> [u8; foo::<'a, 'b>()]: Sized,
16+
| ^^ lifetime `'b` already in scope
17+
18+
error[E0261]: use of undeclared lifetime name `'a`
19+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:24
20+
|
21+
LL | for<'b> [u8; foo::<'a, 'b>()]: Sized,
22+
| ^^ undeclared lifetime
23+
|
24+
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
25+
help: consider making the bound lifetime-generic with a new `'a` lifetime
26+
|
27+
LL | for<'a, 'b> [u8; foo::<'a, 'b>()]: Sized,
28+
| +++
29+
help: consider introducing lifetime `'a` here
30+
|
31+
LL | const fn allow<'a, 'b, 'b>() -> usize
32+
| +++
33+
34+
error[E0601]: `main` function not found in crate `escaping_late_bound_region_in_canonical_ice_113870`
35+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:23:2
36+
|
37+
LL | }
38+
| ^ consider adding a `main` function to `$DIR/escaping-late-bound-region-in-canonical-ice-113870.rs`
39+
40+
error: cannot capture late-bound lifetime in constant
41+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:28
42+
|
43+
LL | const fn allow<'b, 'b>() -> usize
44+
| -- lifetime defined here
45+
...
46+
LL | for<'b> [u8; foo::<'a, 'b>()]: Sized,
47+
| ^^
48+
49+
error: aborting due to 5 previous errors
50+
51+
Some errors have detailed explanations: E0261, E0403, E0496, E0601.
52+
For more information about an error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)