about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs4
-rw-r--r--tests/ui/traits/issue-117794.rs10
-rw-r--r--tests/ui/traits/issue-117794.stderr9
3 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
index bf0d9d4856a..3785b61f2f7 100644
--- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
+++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
@@ -278,6 +278,10 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
 
     let mir_opaque_ty = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied();
     if let Some(mir_opaque_ty) = mir_opaque_ty {
+        if mir_opaque_ty.references_error() {
+            return mir_opaque_ty.ty;
+        }
+
         let scope = tcx.local_def_id_to_hir_id(owner_def_id);
         debug!(?scope);
         let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty };
diff --git a/tests/ui/traits/issue-117794.rs b/tests/ui/traits/issue-117794.rs
new file mode 100644
index 00000000000..a66d6eb10ed
--- /dev/null
+++ b/tests/ui/traits/issue-117794.rs
@@ -0,0 +1,10 @@
+trait Foo {}
+
+trait T {
+    fn a(&self) -> impl Foo {
+        self.b(|| 0)
+        //~^ ERROR no method named `b` found for reference `&Self` in the current scope
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/issue-117794.stderr b/tests/ui/traits/issue-117794.stderr
new file mode 100644
index 00000000000..af63b47f07d
--- /dev/null
+++ b/tests/ui/traits/issue-117794.stderr
@@ -0,0 +1,9 @@
+error[E0599]: no method named `b` found for reference `&Self` in the current scope
+  --> $DIR/issue-117794.rs:5:14
+   |
+LL |         self.b(|| 0)
+   |              ^ help: there is a method with a similar name: `a`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0599`.