single_component_path_imports with macros and $crate:: #9718
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
In exported macros, it is often necessary to write things like
$crate::some_other_crate::its_thing
, and arrange to reexportsome_other_crate
, to avoid imposing strange import requirements on other crates that use the macro.If one writes a macro that is currently not exported, but one might want to export in the future, it is a good idea to do this, because nothing will spot a failure to do it later when the macro becomes exported.
But, then, one gets a single_component_path_imports false positive due to the single element path import of
some_other_crate
, which is necessary for the$crate
to work, but which also ought to be private.I found #7168 which is a complaint about the same kind of situation, but in that case arguably the code ought to be changed. I think in my case the code is fine as it is.
Lint Name
single_component_path_imports
Reproducer
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=387d054d9673c5e30737f65c4a47a23a
I saw this happen:
I expected to see this happen:
No complaint.
Version
Additional Labels
@rustbot label +suggestion-causes-error
The text was updated successfully, but these errors were encountered: