rust/compiler/rustc_middle/src
Aaron Hill d06f774338
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
2021-06-04 12:24:12 -05:00
..
dep_graph Restrict access to crate_name. 2021-06-02 18:35:32 +02:00
hir Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
ich Rename RealFileName::Named to LocalPath and Devirtualized to Remapped 2021-05-05 15:10:50 +01:00
infer Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
middle Restrict access to crate_name. 2021-06-02 18:35:32 +02:00
mir Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
query Support forwarding caller location through trait object method call 2021-06-04 12:24:12 -05:00
traits Make traits with GATs not object safe 2021-04-27 14:34:23 -04:00
ty Support forwarding caller location through trait object method call 2021-06-04 12:24:12 -05:00
util Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
arena.rs Make THIR building a stealable query 2021-05-22 14:36:22 +02:00
lib.rs Remove unused feature gates 2021-05-31 13:55:43 +02:00
lint.rs Add a page on force-warns in unstable book 2021-06-02 18:07:39 +02:00
macros.rs Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk 2020-11-17 12:24:34 +00:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Make THIR building a stealable query 2021-05-22 14:36:22 +02:00