File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
src/test/ui/rfc-2091-track-caller Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 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+
511macro_rules! caller_location_from_macro {
6- ( ) => ( core :: panic :: Location :: caller ( ) ) ;
12+ ( ) => ( defeat_const_prop ( ) ) ;
713}
814
915fn 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}
You can’t perform that action at this time.
0 commit comments