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

Foo::bar() invokes do not give suggestions for Foo when it is not in scope #52468

Closed
nikomatsakis opened this issue Jul 17, 2018 · 3 comments · Fixed by #72923
Closed

Foo::bar() invokes do not give suggestions for Foo when it is not in scope #52468

nikomatsakis opened this issue Jul 17, 2018 · 3 comments · Fixed by #72923
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jul 17, 2018

In this example:

fn main() {
    let _: HashMap<u32, u32> = HashMap::new();
}

there are two uses of HashMap. Neither is in scope, but only the type gives me a suggestion for how to import it:

error[E0433]: failed to resolve. Use of undeclared type or module `HashMap`
 --> src/main.rs:2:32
  |
2 |     let _: HashMap<u32, u32> = HashMap::new();
  |                                ^^^^^^^ Use of undeclared type or module `HashMap`

error[E0412]: cannot find type `HashMap` in this scope
 --> src/main.rs:2:12
  |
2 |     let _: HashMap<u32, u32> = HashMap::new();
  |            ^^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
  |
1 | use std::collections::HashMap;
  |
1 | use std::collections::hash_map::HashMap;
  |

This issue has been assigned to @Patryk27 via this comment.

@nikomatsakis nikomatsakis added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically labels Jul 17, 2018
@estebank
Copy link
Contributor

Maybe, once the current ticket is resolved, we should also elide suggestions to only appear once the first time they're needed.

@estebank estebank added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 14, 2020
@estebank
Copy link
Contributor

Triage: no change.

@Patryk27
Copy link
Contributor

@rustbot claim

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 A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants