@@ -21,6 +21,7 @@ use rustc_data_structures::sync::Lrc;
2121/// line!(): expands to the current line number
2222pub fn expand_line ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
2323 -> Box < dyn base:: MacResult +' static > {
24+ let sp = cx. with_def_site_ctxt ( sp) ;
2425 base:: check_zero_tts ( cx, sp, tts, "line!" ) ;
2526
2627 let topmost = cx. expansion_cause ( ) . unwrap_or ( sp) ;
@@ -32,6 +33,7 @@ pub fn expand_line(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
3233/* column!(): expands to the current column number */
3334pub fn expand_column ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
3435 -> Box < dyn base:: MacResult +' static > {
36+ let sp = cx. with_def_site_ctxt ( sp) ;
3537 base:: check_zero_tts ( cx, sp, tts, "column!" ) ;
3638
3739 let topmost = cx. expansion_cause ( ) . unwrap_or ( sp) ;
@@ -45,6 +47,7 @@ pub fn expand_column(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
4547/// out if we wanted.
4648pub fn expand_file ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
4749 -> Box < dyn base:: MacResult +' static > {
50+ let sp = cx. with_def_site_ctxt ( sp) ;
4851 base:: check_zero_tts ( cx, sp, tts, "file!" ) ;
4952
5053 let topmost = cx. expansion_cause ( ) . unwrap_or ( sp) ;
@@ -54,12 +57,14 @@ pub fn expand_file(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
5457
5558pub fn expand_stringify ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
5659 -> Box < dyn base:: MacResult +' static > {
60+ let sp = cx. with_def_site_ctxt ( sp) ;
5761 let s = pprust:: tts_to_string ( tts) ;
5862 base:: MacEager :: expr ( cx. expr_str ( sp, Symbol :: intern ( & s) ) )
5963}
6064
6165pub fn expand_mod ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
6266 -> Box < dyn base:: MacResult +' static > {
67+ let sp = cx. with_def_site_ctxt ( sp) ;
6368 base:: check_zero_tts ( cx, sp, tts, "module_path!" ) ;
6469 let mod_path = & cx. current_expansion . module . mod_path ;
6570 let string = mod_path. iter ( ) . map ( |x| x. to_string ( ) ) . collect :: < Vec < String > > ( ) . join ( "::" ) ;
@@ -72,6 +77,7 @@ pub fn expand_mod(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
7277/// unhygienically.
7378pub fn expand_include < ' cx > ( cx : & ' cx mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
7479 -> Box < dyn base:: MacResult +' cx > {
80+ let sp = cx. with_def_site_ctxt ( sp) ;
7581 let file = match get_single_str_from_tts ( cx, sp, tts, "include!" ) {
7682 Some ( f) => f,
7783 None => return DummyResult :: any ( sp) ,
@@ -125,6 +131,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
125131// include_str! : read the given file, insert it as a literal string expr
126132pub fn expand_include_str ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
127133 -> Box < dyn base:: MacResult +' static > {
134+ let sp = cx. with_def_site_ctxt ( sp) ;
128135 let file = match get_single_str_from_tts ( cx, sp, tts, "include_str!" ) {
129136 Some ( f) => f,
130137 None => return DummyResult :: any ( sp)
@@ -156,6 +163,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
156163
157164pub fn expand_include_bytes ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
158165 -> Box < dyn base:: MacResult +' static > {
166+ let sp = cx. with_def_site_ctxt ( sp) ;
159167 let file = match get_single_str_from_tts ( cx, sp, tts, "include_bytes!" ) {
160168 Some ( f) => f,
161169 None => return DummyResult :: any ( sp)
0 commit comments