mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
test: ensure #[track_caller] tests also test MIR inlining.
This commit is contained in:
parent
6bc5eafbce
commit
fb36440b7a
@ -1,4 +1,6 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
#[inline(never)]
|
||||
#[track_caller]
|
||||
@ -13,13 +15,13 @@ macro_rules! caller_location_from_macro {
|
||||
fn main() {
|
||||
let loc = codegen_caller_loc();
|
||||
assert_eq!(loc.file(), file!());
|
||||
assert_eq!(loc.line(), 14);
|
||||
assert_eq!(loc.line(), 16);
|
||||
assert_eq!(loc.column(), 15);
|
||||
|
||||
// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
|
||||
// i.e. point to where the macro was invoked, instead of the macro itself.
|
||||
let loc2 = caller_location_from_macro!();
|
||||
assert_eq!(loc2.file(), file!());
|
||||
assert_eq!(loc2.line(), 21);
|
||||
assert_eq!(loc2.line(), 23);
|
||||
assert_eq!(loc2.column(), 16);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
#![feature(const_caller_location, const_fn)]
|
||||
|
||||
@ -24,18 +26,18 @@ const fn contained() -> &'static Location<'static> {
|
||||
|
||||
fn main() {
|
||||
assert_eq!(LOCATION.file(), file!());
|
||||
assert_eq!(LOCATION.line(), 7);
|
||||
assert_eq!(LOCATION.line(), 9);
|
||||
assert_eq!(LOCATION.column(), 29);
|
||||
|
||||
assert_eq!(TRACKED.file(), file!());
|
||||
assert_eq!(TRACKED.line(), 9);
|
||||
assert_eq!(TRACKED.line(), 11);
|
||||
assert_eq!(TRACKED.column(), 28);
|
||||
|
||||
assert_eq!(NESTED.file(), file!());
|
||||
assert_eq!(NESTED.line(), 17);
|
||||
assert_eq!(NESTED.line(), 19);
|
||||
assert_eq!(NESTED.column(), 5);
|
||||
|
||||
assert_eq!(CONTAINED.file(), file!());
|
||||
assert_eq!(CONTAINED.line(), 22);
|
||||
assert_eq!(CONTAINED.line(), 24);
|
||||
assert_eq!(CONTAINED.column(), 5);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
macro_rules! caller_location_from_macro {
|
||||
() => (core::panic::Location::caller());
|
||||
@ -7,13 +9,13 @@ macro_rules! caller_location_from_macro {
|
||||
fn main() {
|
||||
let loc = core::panic::Location::caller();
|
||||
assert_eq!(loc.file(), file!());
|
||||
assert_eq!(loc.line(), 8);
|
||||
assert_eq!(loc.line(), 10);
|
||||
assert_eq!(loc.column(), 15);
|
||||
|
||||
// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
|
||||
// i.e. point to where the macro was invoked, instead of the macro itself.
|
||||
let loc2 = caller_location_from_macro!();
|
||||
assert_eq!(loc2.file(), file!());
|
||||
assert_eq!(loc2.line(), 15);
|
||||
assert_eq!(loc2.line(), 17);
|
||||
assert_eq!(loc2.column(), 16);
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
#[track_caller]
|
||||
fn f() {}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
// run-pass
|
||||
// ignore-wasm32-bare compiled with panic=abort by default
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
#![feature(option_expect_none, option_unwrap_none)]
|
||||
#![allow(unconditional_panic)]
|
||||
|
@ -1,4 +1,6 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
use std::panic::Location;
|
||||
|
||||
@ -18,21 +20,21 @@ fn nested_tracked() -> &'static Location<'static> {
|
||||
fn main() {
|
||||
let location = Location::caller();
|
||||
assert_eq!(location.file(), file!());
|
||||
assert_eq!(location.line(), 19);
|
||||
assert_eq!(location.line(), 21);
|
||||
assert_eq!(location.column(), 20);
|
||||
|
||||
let tracked = tracked();
|
||||
assert_eq!(tracked.file(), file!());
|
||||
assert_eq!(tracked.line(), 24);
|
||||
assert_eq!(tracked.line(), 26);
|
||||
assert_eq!(tracked.column(), 19);
|
||||
|
||||
let nested = nested_intrinsic();
|
||||
assert_eq!(nested.file(), file!());
|
||||
assert_eq!(nested.line(), 11);
|
||||
assert_eq!(nested.line(), 13);
|
||||
assert_eq!(nested.column(), 5);
|
||||
|
||||
let contained = nested_tracked();
|
||||
assert_eq!(contained.file(), file!());
|
||||
assert_eq!(contained.line(), 15);
|
||||
assert_eq!(contained.line(), 17);
|
||||
assert_eq!(contained.column(), 5);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
fn pass_to_ptr_call<T>(f: fn(T), x: T) {
|
||||
f(x);
|
||||
|
@ -1,4 +1,6 @@
|
||||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
fn ptr_call(f: fn()) {
|
||||
f();
|
||||
|
Loading…
Reference in New Issue
Block a user