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

Compiler suggests wrong import collections::borrow instead of std::borrow #26635

Closed
colin-kiegel opened this issue Jun 28, 2015 · 0 comments · Fixed by #32439
Closed

Compiler suggests wrong import collections::borrow instead of std::borrow #26635

colin-kiegel opened this issue Jun 28, 2015 · 0 comments · Fixed by #32439
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@colin-kiegel
Copy link

Example

type T = u32;

pub fn main() {
    let boxed : Option<Box<T>> = Some(Box::new(5));

    let reference : Option<&T> = match boxed {
        Some(ref x) => Some(x.borrow()),
        None => None
    };
}

results in:

<anon>:7:31: 7:39 error: no method named `borrow` found for type `&Box<u32>` in the current scope
<anon>:7         Some(ref x) => Some(x.borrow()),
                                       ^~~~~~~~
<anon>:7:31: 7:39 help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
<anon>:7:31: 7:39 help: candidate #1: use `collections::borrow::Borrow`
error: aborting due to previous error
playpen: application terminated with error code 101
Compilation failed.

it would be correct if it suggested to use std::borrow::Borrow

@sfackler sfackler added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 28, 2015
bors added a commit that referenced this issue Mar 31, 2016
diagnostics: make paths to external items more visible

This PR changes the reported path for an external item so that it is visible from at least one local module (i.e. it does not use any inaccessible external modules) if possible. If the external item's crate was declared with an `extern crate`, the path is guarenteed to use the `extern crate`.

Fixes #23224, fixes #23355, fixes #26635, fixes #27165.

r? @nrc
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants