File tree 1 file changed +10
-4
lines changed
src/test/ui/rfc-2091-track-caller
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
#![ feature( track_caller) ]
4
4
5
+ #[ inline( never) ]
6
+ #[ track_caller]
7
+ fn defeat_const_prop ( ) -> & ' static core:: panic:: Location < ' static > {
8
+ core:: panic:: Location :: caller ( )
9
+ }
10
+
5
11
macro_rules! caller_location_from_macro {
6
- ( ) => ( core :: panic :: Location :: caller ( ) ) ;
12
+ ( ) => ( defeat_const_prop ( ) ) ;
7
13
}
8
14
9
15
fn main ( ) {
10
- let loc = core :: panic :: Location :: caller ( ) ;
16
+ let loc = defeat_const_prop ( ) ;
11
17
assert_eq ! ( loc. file( ) , file!( ) ) ;
12
- assert_eq ! ( loc. line( ) , 10 ) ;
18
+ assert_eq ! ( loc. line( ) , 16 ) ;
13
19
assert_eq ! ( loc. column( ) , 15 ) ;
14
20
15
21
// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
16
22
// i.e. point to where the macro was invoked, instead of the macro itself.
17
23
let loc2 = caller_location_from_macro ! ( ) ;
18
24
assert_eq ! ( loc2. file( ) , file!( ) ) ;
19
- assert_eq ! ( loc2. line( ) , 17 ) ;
25
+ assert_eq ! ( loc2. line( ) , 23 ) ;
20
26
assert_eq ! ( loc2. column( ) , 16 ) ;
21
27
}
You can’t perform that action at this time.
0 commit comments