Skip to content

lint: ignored #[track_caller] on trait define #143864

@A4-Tacks

Description

@A4-Tacks

Code

pub trait Foo {
    #[track_caller]
    fn foo(&self);
}

Current output

empty

Desired output

warning: `#[track_caller]` is ignored on function prototypes
    --> src/main.rs:2:5
     |
2    |     #[track_caller]
     |     ^^^^^^^^^^^^^^^
     |
     = note: `#[warn(unused_attributes)]` on by default

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.88.0-nightly (a15cce269 2025-04-17)
binary: rustc
commit-hash: a15cce2690e8fab72422515c9dc02c6fbc506733
commit-date: 2025-04-17
host: aarch64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-panicArea: Panicking machineryS-needs-infoStatus: The issue lacks details necessary to triage or act on it.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions