Skip to content

allow(single_component_path_imports) does not apply to imports in annotated modules. #9382

@geeklint

Description

@geeklint

Summary

This might be somewhat similar to some existing issues so if it would be preferable to comment on one of them and close this one that's fine, but I didn't see it specifically.

I have some automatically generated code which triggers the single_component_path_imports lint. I'm not opposed to the lint in general, but I'd rather keep the automatically generated code unedited by hand. I thought I could just add the allow(...) attribute to the module declaration, but it doesn't seem to apply recursively to the code in the declared module.

Reproducer

I tried this code:

#[allow(unused_imports)]
#[allow(clippy::single_component_path_imports)]
mod test {
    use anyhow;
}

I expected to see this happen: The lint would be suppressed.

Instead, this happened: The lint warning continues to appear.

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions