@@ -35,7 +35,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
35
35
-> Box < base:: MacResult +' static > {
36
36
base:: check_zero_tts ( cx, sp, tts, "line!" ) ;
37
37
38
- let topmost = cx. expansion_cause ( ) ;
38
+ let topmost = cx. expansion_cause ( ) . unwrap_or ( sp ) ;
39
39
let loc = cx. codemap ( ) . lookup_char_pos ( topmost. lo ) ;
40
40
41
41
base:: MacEager :: expr ( cx. expr_u32 ( topmost, loc. line as u32 ) )
@@ -46,7 +46,7 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
46
46
-> Box < base:: MacResult +' static > {
47
47
base:: check_zero_tts ( cx, sp, tts, "column!" ) ;
48
48
49
- let topmost = cx. expansion_cause ( ) ;
49
+ let topmost = cx. expansion_cause ( ) . unwrap_or ( sp ) ;
50
50
let loc = cx. codemap ( ) . lookup_char_pos ( topmost. lo ) ;
51
51
52
52
base:: MacEager :: expr ( cx. expr_u32 ( topmost, loc. col . to_usize ( ) as u32 ) )
@@ -59,7 +59,7 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
59
59
-> Box < base:: MacResult +' static > {
60
60
base:: check_zero_tts ( cx, sp, tts, "file!" ) ;
61
61
62
- let topmost = cx. expansion_cause ( ) ;
62
+ let topmost = cx. expansion_cause ( ) . unwrap_or ( sp ) ;
63
63
let loc = cx. codemap ( ) . lookup_char_pos ( topmost. lo ) ;
64
64
base:: MacEager :: expr ( cx. expr_str ( topmost, Symbol :: intern ( & loc. file . name ) ) )
65
65
}
0 commit comments