@@ -549,8 +549,10 @@ impl<'a> Parser<'a> {
549
549
ExprKind :: Binary ( op, _, _) if op. node . is_comparison ( ) => {
550
550
// respan to include both operators
551
551
let op_span = op. span . to ( self . token . span ) ;
552
- let mut err = self . diagnostic ( ) . struct_span_err ( op_span,
553
- "chained comparison operators require parentheses" ) ;
552
+ let mut err = self . struct_span_err (
553
+ op_span,
554
+ "chained comparison operators require parentheses" ,
555
+ ) ;
554
556
if op. node == BinOpKind :: Lt &&
555
557
* outer_op == AssocOp :: Less || // Include `<` to provide this recommendation
556
558
* outer_op == AssocOp :: Greater // even in a case like the following:
@@ -1149,17 +1151,14 @@ impl<'a> Parser<'a> {
1149
1151
crate fn check_for_for_in_in_typo ( & mut self , in_span : Span ) {
1150
1152
if self . eat_keyword ( kw:: In ) {
1151
1153
// a common typo: `for _ in in bar {}`
1152
- let mut err = self . sess . span_diagnostic . struct_span_err (
1153
- self . prev_span ,
1154
- "expected iterable, found keyword `in`" ,
1155
- ) ;
1156
- err. span_suggestion_short (
1157
- in_span. until ( self . prev_span ) ,
1158
- "remove the duplicated `in`" ,
1159
- String :: new ( ) ,
1160
- Applicability :: MachineApplicable ,
1161
- ) ;
1162
- err. emit ( ) ;
1154
+ self . struct_span_err ( self . prev_span , "expected iterable, found keyword `in`" )
1155
+ . span_suggestion_short (
1156
+ in_span. until ( self . prev_span ) ,
1157
+ "remove the duplicated `in`" ,
1158
+ String :: new ( ) ,
1159
+ Applicability :: MachineApplicable ,
1160
+ )
1161
+ . emit ( ) ;
1163
1162
}
1164
1163
}
1165
1164
@@ -1172,12 +1171,12 @@ impl<'a> Parser<'a> {
1172
1171
1173
1172
crate fn eat_incorrect_doc_comment_for_arg_type ( & mut self ) {
1174
1173
if let token:: DocComment ( _) = self . token . kind {
1175
- let mut err = self . diagnostic ( ) . struct_span_err (
1174
+ self . struct_span_err (
1176
1175
self . token . span ,
1177
1176
"documentation comments cannot be applied to a function parameter's type" ,
1178
- ) ;
1179
- err . span_label ( self . token . span , "doc comments are not allowed here" ) ;
1180
- err . emit ( ) ;
1177
+ )
1178
+ . span_label ( self . token . span , "doc comments are not allowed here" )
1179
+ . emit ( ) ;
1181
1180
self . bump ( ) ;
1182
1181
} else if self . token == token:: Pound && self . look_ahead ( 1 , |t| {
1183
1182
* t == token:: OpenDelim ( token:: Bracket )
@@ -1189,12 +1188,12 @@ impl<'a> Parser<'a> {
1189
1188
}
1190
1189
let sp = lo. to ( self . token . span ) ;
1191
1190
self . bump ( ) ;
1192
- let mut err = self . diagnostic ( ) . struct_span_err (
1191
+ self . struct_span_err (
1193
1192
sp,
1194
1193
"attributes cannot be applied to a function parameter's type" ,
1195
- ) ;
1196
- err . span_label ( sp, "attributes are not allowed here" ) ;
1197
- err . emit ( ) ;
1194
+ )
1195
+ . span_label ( sp, "attributes are not allowed here" )
1196
+ . emit ( ) ;
1198
1197
}
1199
1198
}
1200
1199
@@ -1250,18 +1249,19 @@ impl<'a> Parser<'a> {
1250
1249
self . expect ( & token:: Colon ) ?;
1251
1250
let ty = self . parse_ty ( ) ?;
1252
1251
1253
- let mut err = self . diagnostic ( ) . struct_span_err_with_code (
1254
- pat. span ,
1255
- "patterns aren't allowed in methods without bodies" ,
1256
- DiagnosticId :: Error ( "E0642" . into ( ) ) ,
1257
- ) ;
1258
- err. span_suggestion_short (
1259
- pat. span ,
1260
- "give this argument a name or use an underscore to ignore it" ,
1261
- "_" . to_owned ( ) ,
1262
- Applicability :: MachineApplicable ,
1263
- ) ;
1264
- err. emit ( ) ;
1252
+ self . diagnostic ( )
1253
+ . struct_span_err_with_code (
1254
+ pat. span ,
1255
+ "patterns aren't allowed in methods without bodies" ,
1256
+ DiagnosticId :: Error ( "E0642" . into ( ) ) ,
1257
+ )
1258
+ . span_suggestion_short (
1259
+ pat. span ,
1260
+ "give this argument a name or use an underscore to ignore it" ,
1261
+ "_" . to_owned ( ) ,
1262
+ Applicability :: MachineApplicable ,
1263
+ )
1264
+ . emit ( ) ;
1265
1265
1266
1266
// Pretend the pattern is `_`, to avoid duplicate errors from AST validation.
1267
1267
let pat = P ( Pat {
0 commit comments