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

single-component-path-imports, and macro_rules macros #13419

Open
ijackson opened this issue Sep 19, 2024 · 0 comments
Open

single-component-path-imports, and macro_rules macros #13419

ijackson opened this issue Sep 19, 2024 · 0 comments
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

Comments

@ijackson
Copy link

ijackson commented Sep 19, 2024

Summary

With macro_rules macros, use name_of_the_macro can be useful to give the macro a path scope. Macros otherwise only have lexical scope.

This can be useful to refer to the macro before its definition, or for rustdoc.

Lint Name

single-component-path-imports

Reproducer

Steps

git clone https://gitlab.torproject.org/Diziet/arti
cd arti
git checkout origin/report-clippy-single-path-imports-false-positive~0
cargo clippy --locked -p tor-socksproto

Expected output

No complaints

Actual output

warning: this import is redundant
   --> crates/tor-socksproto/src/handshake/framework.rs:440:1
    |
440 | use derive_deftly_template_Handshake; // for rustdoc's benefit
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it entirely
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
note: the lint level is defined here
   --> crates/tor-socksproto/src/lib.rs:9:9
    |
9   | #![warn(clippy::all)]
    |         ^^^^^^^^^^^
    = note: `#[warn(clippy::single_component_path_imports)]` implied by `#[warn(clippy::all)]`

Repro that suggested code is broken

git checkout origin/report-clippy-single-path-imports-false-positive~1
cargo doc -p tor-socksproto --locked --all-features --document-private-items --no-deps

This produces:

warning: unresolved link to `derive_deftly_template_Handshake`
  --> crates/tor-socksproto/src/handshake/framework.rs:10:29
   |
10 | //!  * Derive [`Handshake`](derive_deftly_template_Handshake).
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `derive_deftly_template_Handshake` in scope
   |
   = note: `macro_rules` named `derive_deftly_template_Handshake` exists in this crate, but it is not in scope at this link's location
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

(multiple copies).

For my reference, the current branch tip for report-clippy-single-path-imports-false-positive is 8063b71ff92dd30d7fdf2d8200cda7e06f2a0db8

Version

rustc 1.81.0-beta.6 (b5fd9f6f1 2024-08-21)
binary: rust
commit-hash: b5fd9f6f1061b79c045cc08fe03e00caad536800
commit-date: 2024-08-21
host: x86_64-unknown-linux-gnu
release: 1.81.0-beta.6
LLVM version: 18.1.7

Additional Labels

No response

@ijackson ijackson added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 19, 2024
@ijackson ijackson changed the title single-path-imports, and macro_rules macros single-component-path-imports, and macro_rules macros Sep 19, 2024
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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

1 participant