-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #[track_caller] shims for trait objects.
We were missing an Instance::resolve_for_fn_ptr in resolve_for_vtable. Closes #74764.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// run-pass | ||
|
||
trait Tracked { | ||
#[track_caller] | ||
fn handle(&self) { | ||
let location = std::panic::Location::caller(); | ||
assert_eq!(location.file(), file!()); | ||
// we only call this via trait object, so the def site should *always* be returned | ||
assert_eq!(location.line(), line!() - 4); | ||
assert_eq!(location.column(), 5); | ||
} | ||
} | ||
|
||
impl Tracked for () {} | ||
impl Tracked for u8 {} | ||
|
||
fn main() { | ||
let tracked: &dyn Tracked = &5u8; | ||
tracked.handle(); | ||
|
||
const TRACKED: &dyn Tracked = &(); | ||
TRACKED.handle(); | ||
} |