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

absolute_paths can trigger on code produced by a macro #13920

Open
ilyvion opened this issue Jan 1, 2025 · 1 comment
Open

absolute_paths can trigger on code produced by a macro #13920

ilyvion opened this issue Jan 1, 2025 · 1 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

Comments

@ilyvion
Copy link

ilyvion commented Jan 1, 2025

Summary

It looks like absolute_paths isn't properly "shielded" from macro code as something as simple as deriving serde::Deserialize on any type that holds another type with a generic sets it off.

Lint Name

absolute_paths

Reproducer

I tried this code:

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Foo {
    bar: Vec<char>,
}

I saw this happen:

error: consider bringing this path into scope with the `use` keyword
 --> examples\min-repro.rs:9:5
  |
9 |     bar: Vec<char>,
  |     ^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absolute_paths
  = note: `-D clippy::absolute-paths` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]`

error: consider bringing this path into scope with the `use` keyword
 --> examples\min-repro.rs:9:5
  |
9 |     bar: Vec<char>,
  |     ^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absolute_paths

I expected to see this happen:

Nothing, obviously. There are no absolute paths in non-macro generated code here.

Version

rustc 1.85.0-nightly (d117b7f21 2024-12-31)
binary: rustc
commit-hash: d117b7f211835282b3b177dc64245fff0327c04c
commit-date: 2024-12-31
host: x86_64-pc-windows-msvc
release: 1.85.0-nightly
LLVM version: 19.1.6

Additional Labels

No response

@ilyvion ilyvion 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 Jan 1, 2025
@Centri3
Copy link
Member

Centri3 commented Jan 1, 2025

It is.. I guess this is more procedural macros weirdness... Or this could very well be a bug in Path's implementation of WithSearchPat.

I see that TypeRelative doesn't check the beginning of the span, which might be why this happens.

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

2 participants