#[track_caller] cannot be used in traits yet. This is due to limitations in the compiler which are likely to be temporary. See RFC 2091 for details on this and other restrictions.

Erroneous example with a trait method implementation:

#![feature(track_caller)]

trait Foo {
    fn bar(&self);
}

impl Foo for u64 {
    #[track_caller]
    fn bar(&self) {}
}

Erroneous example with a blanket trait method implementation:

#![feature(track_caller)]

trait Foo {
    #[track_caller]
    fn bar(&self) {}
    fn baz(&self);
}

Erroneous example with a trait method declaration:

#![feature(track_caller)]

trait Foo {
    fn bar(&self) {}

    #[track_caller]
    fn baz(&self);
}

Note that while the compiler may be able to support the attribute in traits in the future, RFC 2091 prohibits their implementation without a follow-up RFC.