diff options
Diffstat (limited to 'compiler/rustc_parse')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 12302315e90..f57338ae4dd 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -286,6 +286,15 @@ pub enum BadTypePlusSub { }, } +#[derive(SessionDiagnostic)] +#[error(slug = "parser-maybe-recover-from-bad-qpath-stage-2")] +struct BadQPathStage2 { + #[primary_span] + #[suggestion(applicability = "maybe-incorrect")] + span: Span, + ty: String, +} + // SnapshotParser is used to create a snapshot of the parser // without causing duplicate errors being emitted when the `Parser` // is dropped. @@ -1469,15 +1478,10 @@ impl<'a> Parser<'a> { path.span = ty_span.to(self.prev_token.span); let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty)); - self.struct_span_err(path.span, "missing angle brackets in associated item path") - .span_suggestion( - // This is a best-effort recovery. - path.span, - "try", - format!("<{}>::{}", ty_str, pprust::path_to_string(&path)), - Applicability::MaybeIncorrect, - ) - .emit(); + self.sess.emit_err(BadQPathStage2 { + span: path.span, + ty: format!("<{}>::{}", ty_str, pprust::path_to_string(&path)), + }); let path_span = ty_span.shrink_to_hi(); // Use an empty path since `position == 0`. Ok(P(T::recovered(Some(QSelf { ty, path_span, position: 0 }), path))) |
