1
Fork 0

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
commit da182a0fe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;