about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/lib.rs
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2021-01-24 13:32:37 -0500
committerAaron Hill <aa1ronham@gmail.com>2021-06-04 12:24:12 -0500
commitd06f774338995c72284c95a12d159cedfe077aef (patch)
treed6ca64e826994ba8d0d24851bf37897061ccb012 /compiler/rustc_codegen_llvm/src/lib.rs
parent595088d602049d821bf9a217f2d79aea40715208 (diff)
downloadrust-d06f774338995c72284c95a12d159cedfe077aef.tar.gz
rust-d06f774338995c72284c95a12d159cedfe077aef.zip
Support forwarding caller location through trait object method call
Since PR #69251, the `#[track_caller]` attribute has been supported on
traits. However, it only has an effect on direct (monomorphized) method
calls. Calling a `#[track_caller]` method on a trait object will *not*
propagate caller location information - instead, `Location::caller()` will
return the location of the method definition.

This PR forwards caller location information when `#[track_caller]` is
present on the method definition in the trait. This is possible because
`#[track_caller]` in this position is 'inherited' by any impls of that
trait, so all implementations will have the same ABI.

This PR does *not* change the behavior in the case where
`#[track_caller]` is present only on the impl of a trait.
While all implementations of the method might have an explicit
`#[track_caller]`, we cannot know this at codegen time, since other
crates may have impls of the trait. Therefore, we keep the current
behavior of not forwarding the caller location, ensuring that all
implementations of the trait will have the correct ABI.

See the modified test for examples of how this works
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/lib.rs')
0 files changed, 0 insertions, 0 deletions