Skip to content

Commit 64e311a

Browse files
committed
skip rpit constraint check if borrowck return type error
1 parent 5e70254 commit 64e311a

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)