This repository was archived by the owner on May 28, 2025. It is now read-only.
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
1414parser-forgot-paren = perhaps you forgot parentheses?
1515
1616parser-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 {
286286 } ,
287287}
288288
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+
289298// SnapshotParser is used to create a snapshot of the parser
290299// without causing duplicate errors being emitted when the `Parser`
291300// is dropped.
@@ -1469,15 +1478,10 @@ impl<'a> Parser<'a> {
14691478 path. span = ty_span. to ( self . prev_token . span ) ;
14701479
14711480 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+ } ) ;
14811485
14821486 let path_span = ty_span. shrink_to_hi ( ) ; // Use an empty path since `position == 0`.
14831487 Ok ( P ( T :: recovered ( Some ( QSelf { ty, path_span, position : 0 } ) , path) ) )
You can’t perform that action at this time.
0 commit comments