Skip to content

Commit 6402909

Browse files
committed
delay bug in RPITIT refinement checking with resolution errors
1 parent d929a42 commit 6402909

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
171171
}
172172
// Resolve any lifetime variables that may have been introduced during normalization.
173173
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
174-
// This code path is not reached in any tests, but may be reachable. If
175-
// this is triggered, it should be converted to `delayed_bug` and the
176-
// triggering case turned into a test.
177-
tcx.dcx().bug("encountered errors when checking RPITIT refinement (resolution)");
174+
// If resolution didn't fully complete, we cannot continue checking RPITIT refinement, and
175+
// delay a bug as the original code contains load-bearing errors.
176+
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (resolution)");
177+
return;
178178
};
179179

180180
// For quicker lookup, use an `IndexSet` (we don't use one earlier because
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This is a non-regression test for issue #126670 where RPITIT refinement checking encountered
2+
// errors during resolution and ICEd.
3+
4+
//@ edition: 2018
5+
6+
pub trait Mirror {
7+
type Assoc;
8+
}
9+
impl<T: ?Sized> Mirror for () {
10+
//~^ ERROR the type parameter `T` is not constrained
11+
type Assoc = T;
12+
}
13+
14+
pub trait First {
15+
async fn first() -> <() as Mirror>::Assoc;
16+
//~^ ERROR type annotations needed
17+
}
18+
19+
impl First for () {
20+
async fn first() {}
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/refine-resolution-errors.rs:9:6
3+
|
4+
LL | impl<T: ?Sized> Mirror for () {
5+
| ^ unconstrained type parameter
6+
7+
error[E0282]: type annotations needed
8+
--> $DIR/refine-resolution-errors.rs:15:5
9+
|
10+
LL | async fn first() -> <() as Mirror>::Assoc;
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
12+
13+
error: aborting due to 2 previous errors
14+
15+
Some errors have detailed explanations: E0207, E0282.
16+
For more information about an error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)