@@ -42,7 +42,7 @@ impl MetaVarExpr {
42
42
let ident = parse_ident ( & mut tts, psess, outer_span) ?;
43
43
let Some ( TokenTree :: Delimited ( .., Delimiter :: Parenthesis , args) ) = tts. next ( ) else {
44
44
let msg = "meta-variable expression parameter must be wrapped in parentheses" ;
45
- return Err ( psess. dcx . struct_span_err ( ident. span , msg) ) ;
45
+ return Err ( psess. dcx ( ) . struct_span_err ( ident. span , msg) ) ;
46
46
} ;
47
47
check_trailing_token ( & mut tts, psess) ?;
48
48
let mut iter = args. trees ( ) ;
@@ -62,12 +62,12 @@ impl MetaVarExpr {
62
62
break ;
63
63
}
64
64
if !try_eat_comma ( & mut iter) {
65
- return Err ( psess. dcx . struct_span_err ( outer_span, "expected comma" ) ) ;
65
+ return Err ( psess. dcx ( ) . struct_span_err ( outer_span, "expected comma" ) ) ;
66
66
}
67
67
}
68
68
if result. len ( ) < 2 {
69
69
return Err ( psess
70
- . dcx
70
+ . dcx ( )
71
71
. struct_span_err ( ident. span , "`concat` must have at least two elements" ) ) ;
72
72
}
73
73
MetaVarExpr :: Concat ( result. into ( ) )
@@ -81,7 +81,7 @@ impl MetaVarExpr {
81
81
"len" => MetaVarExpr :: Len ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
82
82
_ => {
83
83
let err_msg = "unrecognized meta-variable expression" ;
84
- let mut err = psess. dcx . struct_span_err ( ident. span , err_msg) ;
84
+ let mut err = psess. dcx ( ) . struct_span_err ( ident. span , err_msg) ;
85
85
err. span_suggestion (
86
86
ident. span ,
87
87
"supported expressions are count, ignore, index and len" ,
@@ -120,7 +120,7 @@ fn check_trailing_token<'psess>(
120
120
) -> PResult < ' psess , ( ) > {
121
121
if let Some ( tt) = iter. next ( ) {
122
122
let mut diag = psess
123
- . dcx
123
+ . dcx ( )
124
124
. struct_span_err ( tt. span ( ) , format ! ( "unexpected token: {}" , pprust:: tt_to_string( tt) ) ) ;
125
125
diag. span_note ( tt. span ( ) , "meta-variable expression must not have trailing tokens" ) ;
126
126
Err ( diag)
@@ -139,7 +139,7 @@ fn parse_count<'psess>(
139
139
let ident = parse_ident ( iter, psess, span) ?;
140
140
let depth = if try_eat_comma ( iter) {
141
141
if iter. look_ahead ( 0 ) . is_none ( ) {
142
- return Err ( psess. dcx . struct_span_err (
142
+ return Err ( psess. dcx ( ) . struct_span_err (
143
143
span,
144
144
"`count` followed by a comma must have an associated index indicating its depth" ,
145
145
) ) ;
@@ -160,7 +160,7 @@ fn parse_depth<'psess>(
160
160
let Some ( tt) = iter. next ( ) else { return Ok ( 0 ) } ;
161
161
let TokenTree :: Token ( token:: Token { kind : token:: TokenKind :: Literal ( lit) , .. } , _) = tt else {
162
162
return Err ( psess
163
- . dcx
163
+ . dcx ( )
164
164
. struct_span_err ( span, "meta-variable expression depth must be a literal" ) ) ;
165
165
} ;
166
166
if let Ok ( lit_kind) = LitKind :: from_token_lit ( * lit)
@@ -170,7 +170,7 @@ fn parse_depth<'psess>(
170
170
Ok ( n_usize)
171
171
} else {
172
172
let msg = "only unsuffixes integer literals are supported in meta-variable expressions" ;
173
- Err ( psess. dcx . struct_span_err ( span, msg) )
173
+ Err ( psess. dcx ( ) . struct_span_err ( span, msg) )
174
174
}
175
175
}
176
176
@@ -181,20 +181,21 @@ fn parse_ident<'psess>(
181
181
fallback_span : Span ,
182
182
) -> PResult < ' psess , Ident > {
183
183
let Some ( tt) = iter. next ( ) else {
184
- return Err ( psess. dcx . struct_span_err ( fallback_span, "expected identifier" ) ) ;
184
+ return Err ( psess. dcx ( ) . struct_span_err ( fallback_span, "expected identifier" ) ) ;
185
185
} ;
186
186
let TokenTree :: Token ( token, _) = tt else {
187
- return Err ( psess. dcx . struct_span_err ( tt. span ( ) , "expected identifier" ) ) ;
187
+ return Err ( psess. dcx ( ) . struct_span_err ( tt. span ( ) , "expected identifier" ) ) ;
188
188
} ;
189
189
if let Some ( ( elem, is_raw) ) = token. ident ( ) {
190
190
if let IdentIsRaw :: Yes = is_raw {
191
- return Err ( psess. dcx . struct_span_err ( elem. span , RAW_IDENT_ERR ) ) ;
191
+ return Err ( psess. dcx ( ) . struct_span_err ( elem. span , RAW_IDENT_ERR ) ) ;
192
192
}
193
193
return Ok ( elem) ;
194
194
}
195
195
let token_str = pprust:: token_to_string ( token) ;
196
- let mut err =
197
- psess. dcx . struct_span_err ( token. span , format ! ( "expected identifier, found `{token_str}`" ) ) ;
196
+ let mut err = psess
197
+ . dcx ( )
198
+ . struct_span_err ( token. span , format ! ( "expected identifier, found `{token_str}`" ) ) ;
198
199
err. span_suggestion (
199
200
token. span ,
200
201
format ! ( "try removing `{token_str}`" ) ,
@@ -236,7 +237,7 @@ fn eat_dollar<'psess>(
236
237
let _ = iter. next ( ) ;
237
238
return Ok ( ( ) ) ;
238
239
}
239
- Err ( psess. dcx . struct_span_err (
240
+ Err ( psess. dcx ( ) . struct_span_err (
240
241
span,
241
242
"meta-variables within meta-variable expressions must be referenced using a dollar sign" ,
242
243
) )
0 commit comments