Skip to content

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

Closed
@nikomatsakis

Description

@nikomatsakis

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.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions