Skip to content

Commit 4a11628

Browse files
committed
Make "failed region resolution while normalizing ParamEnv" a span_delayed_bug.
Fixes rust-lang#121414.
1 parent 4dbb48d commit 4a11628

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ fn do_normalize_predicates<'tcx>(
172172
// the normalized predicates.
173173
let errors = infcx.resolve_regions(&outlives_env);
174174
if !errors.is_empty() {
175-
// @lcnr: Let's still ICE here for now. I want a test case
176-
// for that.
177-
tcx.dcx().span_bug(
175+
tcx.dcx().span_delayed_bug(
178176
span,
179177
format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"),
180178
);

tests/ui/traits/issue-121414.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trait Bar {
2+
type Type;
3+
}
4+
struct Foo<'a>(&'a ());
5+
impl<'a> Bar for Foo<'f> { //~ ERROR undeclared lifetime
6+
type Type = u32;
7+
}
8+
9+
fn test() //~ ERROR implementation of `Bar` is not general enough
10+
where
11+
for<'a> <Foo<'a> as Bar>::Type: Sized,
12+
{
13+
}
14+
15+
fn main() {}

tests/ui/traits/issue-121414.stderr

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0261]: use of undeclared lifetime name `'f`
2+
--> $DIR/issue-121414.rs:5:22
3+
|
4+
LL | impl<'a> Bar for Foo<'f> {
5+
| - ^^ undeclared lifetime
6+
| |
7+
| help: consider introducing lifetime `'f` here: `'f,`
8+
9+
error: implementation of `Bar` is not general enough
10+
--> $DIR/issue-121414.rs:9:4
11+
|
12+
LL | fn test()
13+
| ^^^^ implementation of `Bar` is not general enough
14+
|
15+
= note: `Bar` would have to be implemented for the type `Foo<'0>`, for any lifetime `'0`...
16+
= note: ...but `Bar` is actually implemented for the type `Foo<'1>`, for some specific lifetime `'1`
17+
18+
error: aborting due to 2 previous errors
19+
20+
For more information about this error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)