@@ -21,6 +21,7 @@ use rustc_data_structures::sync::Lrc;
21
21
/// line!(): expands to the current line number
22
22
pub fn expand_line ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
23
23
-> Box < dyn base:: MacResult +' static > {
24
+ let sp = cx. with_def_site_ctxt ( sp) ;
24
25
base:: check_zero_tts ( cx, sp, tts, "line!" ) ;
25
26
26
27
let topmost = cx. expansion_cause ( ) . unwrap_or ( sp) ;
@@ -32,6 +33,7 @@ pub fn expand_line(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
32
33
/* column!(): expands to the current column number */
33
34
pub fn expand_column ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
34
35
-> Box < dyn base:: MacResult +' static > {
36
+ let sp = cx. with_def_site_ctxt ( sp) ;
35
37
base:: check_zero_tts ( cx, sp, tts, "column!" ) ;
36
38
37
39
let topmost = cx. expansion_cause ( ) . unwrap_or ( sp) ;
@@ -45,6 +47,7 @@ pub fn expand_column(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
45
47
/// out if we wanted.
46
48
pub fn expand_file ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
47
49
-> Box < dyn base:: MacResult +' static > {
50
+ let sp = cx. with_def_site_ctxt ( sp) ;
48
51
base:: check_zero_tts ( cx, sp, tts, "file!" ) ;
49
52
50
53
let topmost = cx. expansion_cause ( ) . unwrap_or ( sp) ;
@@ -54,12 +57,14 @@ pub fn expand_file(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
54
57
55
58
pub fn expand_stringify ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
56
59
-> Box < dyn base:: MacResult +' static > {
60
+ let sp = cx. with_def_site_ctxt ( sp) ;
57
61
let s = pprust:: tts_to_string ( tts) ;
58
62
base:: MacEager :: expr ( cx. expr_str ( sp, Symbol :: intern ( & s) ) )
59
63
}
60
64
61
65
pub fn expand_mod ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
62
66
-> Box < dyn base:: MacResult +' static > {
67
+ let sp = cx. with_def_site_ctxt ( sp) ;
63
68
base:: check_zero_tts ( cx, sp, tts, "module_path!" ) ;
64
69
let mod_path = & cx. current_expansion . module . mod_path ;
65
70
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)
72
77
/// unhygienically.
73
78
pub fn expand_include < ' cx > ( cx : & ' cx mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
74
79
-> Box < dyn base:: MacResult +' cx > {
80
+ let sp = cx. with_def_site_ctxt ( sp) ;
75
81
let file = match get_single_str_from_tts ( cx, sp, tts, "include!" ) {
76
82
Some ( f) => f,
77
83
None => return DummyResult :: any ( sp) ,
@@ -125,6 +131,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
125
131
// include_str! : read the given file, insert it as a literal string expr
126
132
pub fn expand_include_str ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
127
133
-> Box < dyn base:: MacResult +' static > {
134
+ let sp = cx. with_def_site_ctxt ( sp) ;
128
135
let file = match get_single_str_from_tts ( cx, sp, tts, "include_str!" ) {
129
136
Some ( f) => f,
130
137
None => return DummyResult :: any ( sp)
@@ -156,6 +163,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream)
156
163
157
164
pub fn expand_include_bytes ( cx : & mut ExtCtxt < ' _ > , sp : Span , tts : TokenStream )
158
165
-> Box < dyn base:: MacResult +' static > {
166
+ let sp = cx. with_def_site_ctxt ( sp) ;
159
167
let file = match get_single_str_from_tts ( cx, sp, tts, "include_bytes!" ) {
160
168
Some ( f) => f,
161
169
None => return DummyResult :: any ( sp)
0 commit comments