Skip to content

absolute_paths can trigger on code produced by a macro #13920

@ilyvion

Description

@ilyvion

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveS-fixedStatus: Issues that got fixed, waiting to be closed as completed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions