Rollup merge of #57795 - estebank:did-you-mean, r=zackmdavis

Use structured suggestion in stead of notes
This commit is contained in:
Mazdak Farrokhzad
2019-01-24 00:19:55 +01:00
committed by GitHub
12 changed files with 44 additions and 41 deletions

View File

@@ -7349,9 +7349,16 @@ impl<'a> Parser<'a> {
// CONST ITEM
if self.eat_keyword(keywords::Mut) {
let prev_span = self.prev_span;
self.diagnostic().struct_span_err(prev_span, "const globals cannot be mutable")
.help("did you mean to declare a static?")
.emit();
let mut err = self.diagnostic()
.struct_span_err(prev_span, "const globals cannot be mutable");
err.span_label(prev_span, "cannot be mutable");
err.span_suggestion_with_applicability(
const_span,
"you might want to declare a static instead",
"static".to_owned(),
Applicability::MaybeIncorrect,
);
err.emit();
}
let (ident, item_, extra_attrs) = self.parse_item_const(None)?;
let prev_span = self.prev_span;