Skip to content

Elide invalid method receiver error when it contains TyErr #58931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,9 @@ fn receiver_is_valid<'fcx, 'tcx, 'gcx>(
} else {
debug!("receiver_is_valid: type `{:?}` does not deref to `{:?}`",
receiver_ty, self_ty);
return false
// If he receiver already has errors reported due to it, consider it valid to avoid
// unecessary errors (#58712).
return receiver_ty.references_error();
}

// without the `arbitrary_self_types` feature, `receiver_ty` must directly deref to
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-58712.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct AddrVec<H, A> {
h: H,
a: A,
}

impl<H> AddrVec<H, DeviceId> {
//~^ ERROR cannot find type `DeviceId` in this scope
pub fn device(&self) -> DeviceId {
//~^ ERROR cannot find type `DeviceId` in this scope
self.tail()
}
}

fn main() {}

15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-58712.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0412]: cannot find type `DeviceId` in this scope
--> $DIR/issue-58712.rs:6:20
|
LL | impl<H> AddrVec<H, DeviceId> {
| ^^^^^^^^ not found in this scope

error[E0412]: cannot find type `DeviceId` in this scope
--> $DIR/issue-58712.rs:8:29
|
LL | pub fn device(&self) -> DeviceId {
| ^^^^^^^^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.