Skip to content

Commit fb36440

Browse files
committed
test: ensure #[track_caller] tests also test MIR inlining.
1 parent 6bc5eaf commit fb36440

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

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

Lines changed: 4 additions & 2 deletions
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
#[inline(never)]
46
#[track_caller]
@@ -13,13 +15,13 @@ macro_rules! caller_location_from_macro {
1315
fn main() {
1416
let loc = codegen_caller_loc();
1517
assert_eq!(loc.file(), file!());
16-
assert_eq!(loc.line(), 14);
18+
assert_eq!(loc.line(), 16);
1719
assert_eq!(loc.column(), 15);
1820

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

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

Lines changed: 6 additions & 4 deletions
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_caller_location, const_fn)]
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
}
Lines changed: 4 additions & 2 deletions
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
macro_rules! caller_location_from_macro {
46
() => (core::panic::Location::caller());
@@ -7,13 +9,13 @@ macro_rules! caller_location_from_macro {
79
fn main() {
810
let loc = core::panic::Location::caller();
911
assert_eq!(loc.file(), file!());
10-
assert_eq!(loc.line(), 8);
12+
assert_eq!(loc.line(), 10);
1113
assert_eq!(loc.column(), 15);
1214

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

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

Lines changed: 3 additions & 0 deletions
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
#[track_caller]
36
fn f() {}
47

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

Lines changed: 2 additions & 0 deletions
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
#![allow(unconditional_panic)]

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

Lines changed: 6 additions & 4 deletions
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
use std::panic::Location;
46

@@ -18,21 +20,21 @@ fn nested_tracked() -> &'static Location<'static> {
1820
fn main() {
1921
let location = Location::caller();
2022
assert_eq!(location.file(), file!());
21-
assert_eq!(location.line(), 19);
23+
assert_eq!(location.line(), 21);
2224
assert_eq!(location.column(), 20);
2325

2426
let tracked = tracked();
2527
assert_eq!(tracked.file(), file!());
26-
assert_eq!(tracked.line(), 24);
28+
assert_eq!(tracked.line(), 26);
2729
assert_eq!(tracked.column(), 19);
2830

2931
let nested = nested_intrinsic();
3032
assert_eq!(nested.file(), file!());
31-
assert_eq!(nested.line(), 11);
33+
assert_eq!(nested.line(), 13);
3234
assert_eq!(nested.column(), 5);
3335

3436
let contained = nested_tracked();
3537
assert_eq!(contained.file(), file!());
36-
assert_eq!(contained.line(), 15);
38+
assert_eq!(contained.line(), 17);
3739
assert_eq!(contained.column(), 5);
3840
}

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

Lines changed: 2 additions & 0 deletions
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
fn pass_to_ptr_call<T>(f: fn(T), x: T) {
46
f(x);

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

Lines changed: 2 additions & 0 deletions
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
fn ptr_call(f: fn()) {
46
f();

0 commit comments

Comments
 (0)