@@ -35,7 +35,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
3535 -> Box < base:: MacResult +' static > {
3636 base:: check_zero_tts ( cx, sp, tts, "line!" ) ;
3737
38- let topmost = cx. expansion_cause ( ) ;
38+ let topmost = cx. expansion_cause ( ) . unwrap_or ( sp ) ;
3939 let loc = cx. codemap ( ) . lookup_char_pos ( topmost. lo ) ;
4040
4141 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])
4646 -> Box < base:: MacResult +' static > {
4747 base:: check_zero_tts ( cx, sp, tts, "column!" ) ;
4848
49- let topmost = cx. expansion_cause ( ) ;
49+ let topmost = cx. expansion_cause ( ) . unwrap_or ( sp ) ;
5050 let loc = cx. codemap ( ) . lookup_char_pos ( topmost. lo ) ;
5151
5252 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])
5959 -> Box < base:: MacResult +' static > {
6060 base:: check_zero_tts ( cx, sp, tts, "file!" ) ;
6161
62- let topmost = cx. expansion_cause ( ) ;
62+ let topmost = cx. expansion_cause ( ) . unwrap_or ( sp ) ;
6363 let loc = cx. codemap ( ) . lookup_char_pos ( topmost. lo ) ;
6464 base:: MacEager :: expr ( cx. expr_str ( topmost, Symbol :: intern ( & loc. file . name ) ) )
6565}
0 commit comments