migrate maybe_recover_from_bad_qpath_stage_2
diagnostic
This commit is contained in:
parent
16a0d03698
commit
bd4d1cd7a2
2 changed files with 17 additions and 9 deletions
|
@ -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)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue