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

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

Open
geeklint opened this issue Aug 26, 2022 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@geeklint
Copy link

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

@geeklint geeklint added the C-bug Category: Clippy is not doing the correct thing label Aug 26, 2022
@giraffate
Copy link
Contributor

It looks like that this lint can't be enabled or disabled per module, so it would need to be set up as follows:

#![allow(clippy::single_component_path_imports)]

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

2 participants