Skip to content
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

Spurious error reported after name not found in scope #58712

Closed
joshlf opened this issue Feb 24, 2019 · 0 comments
Closed

Spurious error reported after name not found in scope #58712

joshlf opened this issue Feb 24, 2019 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@joshlf
Copy link
Contributor

joshlf commented Feb 24, 2019

I have the following code:

impl<H> AddrVec<H, DeviceId> {
    pub fn device(&self) -> DeviceId {
        self.tail()
    }
}

I forgot to use DeviceId, so it wasn't in scope. rustc gave me the following errors:

error[E0412]: cannot find type `DeviceId` in this scope
   --> src/address.rs:343:20
    |
343 | impl<H> AddrVec<H, DeviceId> {
    |                    ^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
5   | use crate::device::DeviceId;
    |

error[E0412]: cannot find type `DeviceId` in this scope
   --> src/address.rs:344:29
    |
344 |     pub fn device(&self) -> DeviceId {
    |                             ^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
5   | use crate::device::DeviceId;
    |

error[E0307]: invalid method receiver type: &address::AddrVec<H, [type error]>
   --> src/address.rs:344:19
    |
344 |     pub fn device(&self) -> DeviceId {
    |                   ^^^^^
    |
    = note: type must be `Self` or a type that dereferences to it
    = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`

Maybe this is the intended behavior, but it seems odd to report an invalid method receiver type error simply because the type's name was unknown.

@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 26, 2019
estebank added a commit to estebank/rust that referenced this issue Mar 5, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this issue Mar 8, 2019
…rkor

Elide invalid method receiver error when it contains TyErr

Fix rust-lang#58712.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants