Skip to content

Commit d14e52b

Browse files
committed
Auto merge of rust-lang#117884 - bvanjoi:fix-117794, r=compiler-errors
skip rpit constraint checker if borrowck return type error Fixes rust-lang#117794 Fixes rust-lang#117886 Fixes rust-lang#119025 Prior to change rust-lang#117418, the value of `concrete_opaque_types` for `mir_borrock(T::a::opaque)` was `None`. However, due to modifications in `body.local_decls`, the return value had been changed. The changed of `body.local_decls` has let to the addition of `ty:Error` to `infcx.opaque_type_storage.opaque_types` during `TypeChecker::equate_inputs_and_outputs`. This is due to it utilizing the output of a function signature that was appended during `construct_error`(which previously only appended a `ty::Error`) and then execute `TypeChecker::Related_types`. Therefore, in this PR, I've implemented a condition to bypass the rpit check when an error is encountered. r? `@compiler-errors`
2 parents 3a2aa58 + 64e311a commit d14e52b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

+4
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
278278

279279
let mir_opaque_ty = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied();
280280
if let Some(mir_opaque_ty) = mir_opaque_ty {
281+
if mir_opaque_ty.references_error() {
282+
return mir_opaque_ty.ty;
283+
}
284+
281285
let scope = tcx.local_def_id_to_hir_id(owner_def_id);
282286
debug!(?scope);
283287
let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty };

tests/ui/traits/issue-117794.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
trait Foo {}
2+
3+
trait T {
4+
fn a(&self) -> impl Foo {
5+
self.b(|| 0)
6+
//~^ ERROR no method named `b` found for reference `&Self` in the current scope
7+
}
8+
}
9+
10+
fn main() {}

tests/ui/traits/issue-117794.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0599]: no method named `b` found for reference `&Self` in the current scope
2+
--> $DIR/issue-117794.rs:5:14
3+
|
4+
LL | self.b(|| 0)
5+
| ^ help: there is a method with a similar name: `a`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)