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

Suggest import for E0433 Use of undeclared type or module #48676

Closed
alexheretic opened this issue Mar 2, 2018 · 2 comments · Fixed by #103706
Closed

Suggest import for E0433 Use of undeclared type or module #48676

alexheretic opened this issue Mar 2, 2018 · 2 comments · Fixed by #103706
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alexheretic
Copy link
Member

alexheretic commented Mar 2, 2018

While E0412 already provides suggested imports, E0433 does not. It seems like a similar problem on the face of it. Can we add suggestions for undeclared type or module?

Particularly this helps IDEs working toward rust-lang/rls#742.

For example no suggestion is currently provided for the following.

pub fn main() {
    let set = HashSet::new();
}
error[E0433]: failed to resolve. Use of undeclared type or module `HashSet`
 --> src/main.rs:5:15
  |
5 |     let set = HashSet::new();
  |               ^^^^^^^ Use of undeclared type or module `HashSet`
{
  "children": [],
  "code": {
    "code": "E0433",
    "explanation": "\nAn undeclared type or module was used.\n\nErroneous code example:\n\n```compile_fail,E0433\nlet map = HashMap::new();\n// error: failed to resolve. Use of undeclared type or module `HashMap`\n```\n\nPlease verify you didn't misspell the type/module's name or that you didn't\nforgot to import it:\n\n\n```\nuse std::collections::HashMap; // HashMap has been imported.\nlet map: HashMap<u32, u32> = HashMap::new(); // So it can be used!\n```\n"
  },
  "level": "error",
  "message": "failed to resolve. Use of undeclared type or module `HashSet`",
  "rendered": "error[E0433]: failed to resolve. Use of undeclared type or module `HashSet`\n --> src/main.rs:2:15\n  |\n2 |     let set = HashSet::new();\n  |               ^^^^^^^ Use of undeclared type or module `HashSet`\n\nIf you want more information on this error, try using \"rustc --explain E0433\"\n",
  "spans": [{
    "byte_end": 37,
    "byte_start": 30,
    "column_end": 22,
    "column_start": 15,
    "expansion": null,
    "file_name": "src/main.rs",
    "is_primary": true,
    "label": "Use of undeclared type or module `HashSet`",
    "line_end": 2,
    "line_start": 2,
    "suggested_replacement": null,
    "text": [{
      "highlight_end": 22,
      "highlight_start": 15,
      "text": "    let set = HashSet::new();"
    }]
  }]
}
@pietroalbini pietroalbini added C-enhancement Category: An issue proposing an enhancement or a PR with one. 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. labels Mar 6, 2018
@TatriX
Copy link

TatriX commented Dec 4, 2019

Any progress on this? If not, how can I help?

@jonas-schievink jonas-schievink added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Apr 20, 2020
@m-ysk
Copy link
Contributor

m-ysk commented May 6, 2022

@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 C-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

5 participants