File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -14,3 +14,7 @@ parser-add-paren = try adding parentheses
14
14
parser-forgot-paren = perhaps you forgot parentheses?
15
15
16
16
parser-expect-path = expected a path
17
+
18
+ parser-maybe-recover-from-bad-qpath-stage-2 =
19
+ missing angle brackets in associated item path
20
+ .suggestion = try: `{ $ty } `
Original file line number Diff line number Diff line change @@ -286,6 +286,15 @@ pub enum BadTypePlusSub {
286
286
} ,
287
287
}
288
288
289
+ #[ derive( SessionDiagnostic ) ]
290
+ #[ error( slug = "parser-maybe-recover-from-bad-qpath-stage-2" ) ]
291
+ struct BadQPathStage2 {
292
+ #[ primary_span]
293
+ #[ suggestion( applicability = "maybe-incorrect" ) ]
294
+ span : Span ,
295
+ ty : String ,
296
+ }
297
+
289
298
// SnapshotParser is used to create a snapshot of the parser
290
299
// without causing duplicate errors being emitted when the `Parser`
291
300
// is dropped.
@@ -1469,15 +1478,10 @@ impl<'a> Parser<'a> {
1469
1478
path. span = ty_span. to ( self . prev_token . span ) ;
1470
1479
1471
1480
let ty_str = self . span_to_snippet ( ty_span) . unwrap_or_else ( |_| pprust:: ty_to_string ( & ty) ) ;
1472
- self . struct_span_err ( path. span , "missing angle brackets in associated item path" )
1473
- . span_suggestion (
1474
- // This is a best-effort recovery.
1475
- path. span ,
1476
- "try" ,
1477
- format ! ( "<{}>::{}" , ty_str, pprust:: path_to_string( & path) ) ,
1478
- Applicability :: MaybeIncorrect ,
1479
- )
1480
- . emit ( ) ;
1481
+ self . sess . emit_err ( BadQPathStage2 {
1482
+ span : path. span ,
1483
+ ty : format ! ( "<{}>::{}" , ty_str, pprust:: path_to_string( & path) ) ,
1484
+ } ) ;
1481
1485
1482
1486
let path_span = ty_span. shrink_to_hi ( ) ; // Use an empty path since `position == 0`.
1483
1487
Ok ( P ( T :: recovered ( Some ( QSelf { ty, path_span, position : 0 } ) , path) ) )
You can’t perform that action at this time.
0 commit comments