@@ -328,14 +328,14 @@ fn expr_to_lit(
328
328
match res {
329
329
Ok ( lit) => {
330
330
if token_lit. suffix . is_some ( ) {
331
- should_emit. emit_err_or_delay (
331
+ should_emit. emit_err (
332
332
psess. dcx ( ) . create_err ( SuffixedLiteralInAttribute { span : lit. span } ) ,
333
333
) ;
334
334
None
335
335
} else {
336
336
if !lit. kind . is_unsuffixed ( ) {
337
337
// Emit error and continue, we can still parse the attribute as if the suffix isn't there
338
- should_emit. maybe_emit_err (
338
+ should_emit. emit_err (
339
339
psess. dcx ( ) . create_err ( SuffixedLiteralInAttribute { span : lit. span } ) ,
340
340
) ;
341
341
}
@@ -355,19 +355,19 @@ fn expr_to_lit(
355
355
}
356
356
}
357
357
} else {
358
+ if matches ! ( should_emit, ShouldEmit :: Nothing ) {
359
+ return None ;
360
+ }
361
+
358
362
// Example cases:
359
363
// - `#[foo = 1+1]`: results in `ast::ExprKind::BinOp`.
360
364
// - `#[foo = include_str!("nonexistent-file.rs")]`:
361
365
// results in `ast::ExprKind::Err`. In that case we delay
362
366
// the error because an earlier error will have already
363
367
// been reported.
364
368
let msg = "attribute value must be a literal" ;
365
- let mut err = psess. dcx ( ) . struct_span_err ( span, msg) ;
366
- if let ExprKind :: Err ( _) = expr. kind {
367
- err. downgrade_to_delayed_bug ( ) ;
368
- }
369
-
370
- should_emit. emit_err_or_delay ( err) ;
369
+ let err = psess. dcx ( ) . struct_span_err ( span, msg) ;
370
+ should_emit. emit_err ( err) ;
371
371
None
372
372
}
373
373
}
@@ -400,7 +400,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
400
400
401
401
if !lit. kind . is_unsuffixed ( ) {
402
402
// Emit error and continue, we can still parse the attribute as if the suffix isn't there
403
- self . should_emit . maybe_emit_err (
403
+ self . should_emit . emit_err (
404
404
self . parser . dcx ( ) . create_err ( SuffixedLiteralInAttribute { span : lit. span } ) ,
405
405
) ;
406
406
}
@@ -542,7 +542,7 @@ impl<'a> MetaItemListParser<'a> {
542
542
) {
543
543
Ok ( s) => Some ( s) ,
544
544
Err ( e) => {
545
- should_emit. emit_err_or_delay ( e) ;
545
+ should_emit. emit_err ( e) ;
546
546
None
547
547
}
548
548
}
0 commit comments