Skip to content

Commit 15d1f7c

Browse files
committed
Add additional layer of #[track_caller] to test, avoid const prop.
1 parent 1c2483e commit 15d1f7c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
#![feature(track_caller)]
44

5+
#[inline(never)]
6+
#[track_caller]
7+
fn defeat_const_prop() -> &'static core::panic::Location<'static> {
8+
core::panic::Location::caller()
9+
}
10+
511
macro_rules! caller_location_from_macro {
6-
() => (core::panic::Location::caller());
12+
() => (defeat_const_prop());
713
}
814

915
fn main() {
10-
let loc = core::panic::Location::caller();
16+
let loc = defeat_const_prop();
1117
assert_eq!(loc.file(), file!());
12-
assert_eq!(loc.line(), 10);
18+
assert_eq!(loc.line(), 16);
1319
assert_eq!(loc.column(), 15);
1420

1521
// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
1622
// i.e. point to where the macro was invoked, instead of the macro itself.
1723
let loc2 = caller_location_from_macro!();
1824
assert_eq!(loc2.file(), file!());
19-
assert_eq!(loc2.line(), 17);
25+
assert_eq!(loc2.line(), 23);
2026
assert_eq!(loc2.column(), 16);
2127
}

0 commit comments

Comments
 (0)