Skip to content

Commit 8f26bf2

Browse files
committed
skip borrow check if RpitConstraintChecker had type error
1 parent 85c42b7 commit 8f26bf2

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ struct RpitConstraintChecker<'tcx> {
324324
impl RpitConstraintChecker<'_> {
325325
#[instrument(skip(self), level = "debug")]
326326
fn check(&self, def_id: LocalDefId) {
327+
if self.found.references_error() {
328+
return;
329+
}
327330
// Use borrowck to get the type with unerased regions.
328331
let concrete_opaque_types = &self.tcx.mir_borrowck(def_id).concrete_opaque_types;
329332
debug!(?concrete_opaque_types);
@@ -335,8 +338,7 @@ impl RpitConstraintChecker<'_> {
335338

336339
debug!(?concrete_type, "found constraint");
337340

338-
if concrete_type.ty != self.found.ty && !(concrete_type, self.found).references_error()
339-
{
341+
if concrete_type.ty != self.found.ty && !concrete_type.references_error() {
340342
self.found.report_mismatch(&concrete_type, self.def_id, self.tcx).emit();
341343
}
342344
}

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 previous error
8+
9+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)