Skip to content

Detect when unresolved import is caused by item that's cfged away #60279

Closed
@estebank

Description

@estebank

When having an annotated import like #[cfg(test)] use foo::bar; and elsewhere in the same scope we have use self::bar::baz; we currently get an error about unresolved imports when building regularly. We should point out that the import would be valid if it wasn't restricted to test runs and suggest to either remove the other imports annotation or adding one to the current import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-libtestArea: `#[test]` / the `test` libraryA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-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