Skip to content

Commit 138f85d

Browse files
committed
test: ensure #[track_caller] tests also test MIR inlining.
1 parent 275cb05 commit 138f85d

8 files changed

+29
-12
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
24

35
#![feature(track_caller)]
46

@@ -15,13 +17,13 @@ macro_rules! caller_location_from_macro {
1517
fn main() {
1618
let loc = codegen_caller_loc();
1719
assert_eq!(loc.file(), file!());
18-
assert_eq!(loc.line(), 16);
20+
assert_eq!(loc.line(), 18);
1921
assert_eq!(loc.column(), 15);
2022

2123
// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
2224
// i.e. point to where the macro was invoked, instead of the macro itself.
2325
let loc2 = caller_location_from_macro!();
2426
assert_eq!(loc2.file(), file!());
25-
assert_eq!(loc2.line(), 23);
27+
assert_eq!(loc2.line(), 25);
2628
assert_eq!(loc2.column(), 16);
2729
}

src/test/ui/rfc-2091-track-caller/const-caller-location.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
24

35
#![feature(const_fn, track_caller)]
46

@@ -24,18 +26,18 @@ const fn contained() -> &'static Location<'static> {
2426

2527
fn main() {
2628
assert_eq!(LOCATION.file(), file!());
27-
assert_eq!(LOCATION.line(), 7);
29+
assert_eq!(LOCATION.line(), 9);
2830
assert_eq!(LOCATION.column(), 29);
2931

3032
assert_eq!(TRACKED.file(), file!());
31-
assert_eq!(TRACKED.line(), 9);
33+
assert_eq!(TRACKED.line(), 11);
3234
assert_eq!(TRACKED.column(), 28);
3335

3436
assert_eq!(NESTED.file(), file!());
35-
assert_eq!(NESTED.line(), 17);
37+
assert_eq!(NESTED.line(), 19);
3638
assert_eq!(NESTED.column(), 5);
3739

3840
assert_eq!(CONTAINED.file(), file!());
39-
assert_eq!(CONTAINED.line(), 22);
41+
assert_eq!(CONTAINED.line(), 24);
4042
assert_eq!(CONTAINED.column(), 5);
4143
}

src/test/ui/rfc-2091-track-caller/intrinsic-wrapper.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
24

35
#![feature(track_caller)]
46

@@ -9,13 +11,13 @@ macro_rules! caller_location_from_macro {
911
fn main() {
1012
let loc = core::panic::Location::caller();
1113
assert_eq!(loc.file(), file!());
12-
assert_eq!(loc.line(), 10);
14+
assert_eq!(loc.line(), 12);
1315
assert_eq!(loc.column(), 15);
1416

1517
// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
1618
// i.e. point to where the macro was invoked, instead of the macro itself.
1719
let loc2 = caller_location_from_macro!();
1820
assert_eq!(loc2.file(), file!());
19-
assert_eq!(loc2.line(), 17);
21+
assert_eq!(loc2.line(), 19);
2022
assert_eq!(loc2.column(), 16);
2123
}

src/test/ui/rfc-2091-track-caller/pass.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
4+
25
#![feature(track_caller)]
36

47
#[track_caller]

src/test/ui/rfc-2091-track-caller/std-panic-locations.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// run-pass
22
// ignore-wasm32-bare compiled with panic=abort by default
3+
// revisions: default mir-opt
4+
//[mir-opt] compile-flags: -Zmir-opt-level=3
35

46
#![feature(option_expect_none, option_unwrap_none)]
57

src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
24

35
#![feature(track_caller)]
46

@@ -20,21 +22,21 @@ fn nested_tracked() -> &'static Location<'static> {
2022
fn main() {
2123
let location = Location::caller();
2224
assert_eq!(location.file(), file!());
23-
assert_eq!(location.line(), 21);
25+
assert_eq!(location.line(), 23);
2426
assert_eq!(location.column(), 20);
2527

2628
let tracked = tracked();
2729
assert_eq!(tracked.file(), file!());
28-
assert_eq!(tracked.line(), 26);
30+
assert_eq!(tracked.line(), 28);
2931
assert_eq!(tracked.column(), 19);
3032

3133
let nested = nested_intrinsic();
3234
assert_eq!(nested.file(), file!());
33-
assert_eq!(nested.line(), 13);
35+
assert_eq!(nested.line(), 15);
3436
assert_eq!(nested.column(), 5);
3537

3638
let contained = nested_tracked();
3739
assert_eq!(contained.file(), file!());
38-
assert_eq!(contained.line(), 17);
40+
assert_eq!(contained.line(), 19);
3941
assert_eq!(contained.column(), 5);
4042
}

src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
24

35
#![feature(track_caller)]
46

src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: default mir-opt
3+
//[mir-opt] compile-flags: -Zmir-opt-level=3
24

35
#![feature(track_caller)]
46

0 commit comments

Comments
 (0)