Skip to content

Rustc suggests both std and core imports at times #83564

Description

@leonardo-m

rustc often offers a help to import something from std and core:

error[E0433]: failed to resolve: use of undeclared type `NonZeroU32`
  --> ...\test.rs:20:33
   |
20 | ...                   NonZeroU32::new(5).unwrap(),
   |                       ^^^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
6  | use core::num::NonZeroU32;
   |
6  | use std::num::NonZeroU32;
   |

Perhaps in such situations rustc could use an heuristic to suggest only one of the two imports.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.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