Use chaining for DiagnosticBuilder
construction and emit
.
To avoid the use of a mutable local variable, and because it reads more nicely.
This commit is contained in:
parent
589591efde
commit
bd4e623485
22 changed files with 193 additions and 183 deletions
|
@ -141,17 +141,18 @@ impl<'a> Parser<'a> {
|
|||
// Parse optional const generics default value.
|
||||
let default = if self.eat(&token::Eq) { Some(self.parse_const_arg()?) } else { None };
|
||||
|
||||
let mut err = self.dcx().struct_span_err(
|
||||
mistyped_const_ident.span,
|
||||
format!("`const` keyword was mistyped as `{}`", mistyped_const_ident.as_str()),
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
mistyped_const_ident.span,
|
||||
"use the `const` keyword",
|
||||
kw::Const.as_str(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
self.dcx()
|
||||
.struct_span_err(
|
||||
mistyped_const_ident.span,
|
||||
format!("`const` keyword was mistyped as `{}`", mistyped_const_ident.as_str()),
|
||||
)
|
||||
.span_suggestion_verbose_mv(
|
||||
mistyped_const_ident.span,
|
||||
"use the `const` keyword",
|
||||
kw::Const.as_str(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
|
||||
Ok(GenericParam {
|
||||
ident,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue