diff options
| author | Christian Poveda <git@pvdrz.com> | 2022-05-31 11:22:26 -0500 |
|---|---|---|
| committer | Christian Poveda <git@pvdrz.com> | 2022-05-31 11:22:26 -0500 |
| commit | bd4d1cd7a2edd98a92b85997812e70aee5e740c7 (patch) | |
| tree | 1fdf64bf571207f0538567888268ba8c4589b095 /compiler/rustc_parse/src | |
| parent | 16a0d03698bfc9f93250490797f9a1a870f8bcfe (diff) | |
| download | rust-bd4d1cd7a2edd98a92b85997812e70aee5e740c7.tar.gz rust-bd4d1cd7a2edd98a92b85997812e70aee5e740c7.zip | |
migrate `maybe_recover_from_bad_qpath_stage_2` diagnostic
Diffstat (limited to 'compiler/rustc_parse/src')
| -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))) |
