"previous outer attribute"
};
- let mut diagnostic = self.diagnostic().struct_span_err(attr_sp, reason);
+ let mut diagnostic = self.struct_span_err(attr_sp, reason);
if let Some(prev_attr_sp) = prev_attr_sp {
diagnostic
if !lit.kind.is_unsuffixed() {
let msg = "suffixed literals are not allowed in attributes";
- self.diagnostic()
- .struct_span_err(lit.span, msg)
+ self.struct_span_err(lit.span, msg)
.help(
"instead of using a suffixed literal \
(1u8, 1.0f32, etc.), use an unsuffixed version \
let found = pprust::token_to_string(&self.token);
let msg = format!("expected unsuffixed literal or identifier, found `{}`", found);
- Err(self.diagnostic().struct_span_err(self.token.span, &msg))
+ Err(self.struct_span_err(self.token.span, &msg))
}
}
let span = lo.until(self.token.span);
let total_num_of_gt = number_of_gt + number_of_shr * 2;
- self.diagnostic()
- .struct_span_err(
- span,
- &format!("unmatched angle bracket{}", pluralize!(total_num_of_gt)),
- )
- .span_suggestion(
- span,
- &format!("remove extra angle bracket{}", pluralize!(total_num_of_gt)),
- String::new(),
- Applicability::MachineApplicable,
- )
- .emit();
+ self.struct_span_err(
+ span,
+ &format!("unmatched angle bracket{}", pluralize!(total_num_of_gt)),
+ )
+ .span_suggestion(
+ span,
+ &format!("remove extra angle bracket{}", pluralize!(total_num_of_gt)),
+ String::new(),
+ Applicability::MachineApplicable,
+ )
+ .emit();
}
}
path.span = ty_span.to(self.prev_span);
let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty));
- self.diagnostic()
- .struct_span_err(path.span, "missing angle brackets in associated item path")
+ self.struct_span_err(path.span, "missing angle brackets in associated item path")
.span_suggestion(
// This is a best-effort recovery.
path.span,
return;
}
- self.diagnostic()
- .struct_span_err(self.token.span, "expected `:`, found `=`")
+ self.struct_span_err(self.token.span, "expected `:`, found `=`")
.span_suggestion(
field_name.span.shrink_to_hi().to(self.token.span),
"replace equals symbol with a colon",
// possible public struct definition where `struct` was forgotten
let ident = self.parse_ident().unwrap();
let msg = format!("add `struct` here to parse `{}` as a public struct", ident);
- let mut err =
- self.diagnostic().struct_span_err(sp, "missing `struct` for struct definition");
+ let mut err = self.struct_span_err(sp, "missing `struct` for struct definition");
err.span_suggestion_short(
sp,
&msg,
};
let msg = format!("missing `{}` for {} definition", kw, kw_name);
- let mut err = self.diagnostic().struct_span_err(sp, &msg);
+ let mut err = self.struct_span_err(sp, &msg);
if !ambiguous {
self.consume_block(token::Brace, ConsumeClosingDelim::Yes);
let suggestion =
("fn` or `struct", "function or struct", true)
};
let msg = format!("missing `{}` for {} definition", kw, kw_name);
- let mut err = self.diagnostic().struct_span_err(sp, &msg);
+ let mut err = self.struct_span_err(sp, &msg);
if !ambiguous {
err.span_suggestion_short(
sp,
_ => "expected item after attributes",
};
- let mut err = self.diagnostic().struct_span_err(self.prev_span, message);
+ let mut err = self.struct_span_err(self.prev_span, message);
if attrs.last().unwrap().is_doc_comment() {
err.span_label(self.prev_span, "this doc comment doesn't document anything");
}
// ^^ `sp` below will point to this
let sp = prev_span.between(self.prev_span);
let mut err = self
- .diagnostic()
.struct_span_err(sp, &format!("{} for {}-item declaration", expected_kinds, item_type));
err.span_label(sp, expected_kinds);
err
VisibilityKind::Inherited => {}
_ => {
let mut err = if self.token.is_keyword(sym::macro_rules) {
- let mut err = self
- .diagnostic()
- .struct_span_err(sp, "can't qualify macro_rules invocation with `pub`");
+ let mut err =
+ self.struct_span_err(sp, "can't qualify macro_rules invocation with `pub`");
err.span_suggestion(
sp,
"try exporting the macro",
);
err
} else {
- let mut err = self
- .diagnostic()
- .struct_span_err(sp, "can't qualify macro invocation with `pub`");
+ let mut err =
+ self.struct_span_err(sp, "can't qualify macro invocation with `pub`");
err.help("try adjusting the macro to put `pub` inside the invocation");
err
};
DirectoryOwnership::UnownedViaBlock => {
let msg = "Cannot declare a non-inline module inside a block \
unless it has a path attribute";
- let mut err = self.diagnostic().struct_span_err(id_sp, msg);
+ let mut err = self.struct_span_err(id_sp, msg);
if paths.path_exists {
let msg = format!(
"Maybe `use` the module `{}` instead of redeclaring it",
Err(err)
}
DirectoryOwnership::UnownedViaMod => {
- let mut err = self
- .diagnostic()
- .struct_span_err(id_sp, "cannot declare a new module at this location");
+ let mut err =
+ self.struct_span_err(id_sp, "cannot declare a new module at this location");
if !id_sp.is_dummy() {
let src_path = self.sess.source_map().span_to_filename(id_sp);
if let FileName::Real(src_path) = src_path {
let range_span = lo.to(end.span);
let begin = self.mk_expr(range_span, ExprKind::Err, AttrVec::new());
- self.diagnostic()
- .struct_span_err(range_span, &format!("`{}X` range patterns are not supported", form))
+ self.struct_span_err(range_span, &format!("`{}X` range patterns are not supported", form))
.span_suggestion(
range_span,
"try using the minimum value for the type",
// Parsing e.g. `X..`.
let range_span = begin.span.to(self.prev_span);
- self.diagnostic()
- .struct_span_err(
- range_span,
- &format!("`X{}` range patterns are not supported", form),
- )
- .span_suggestion(
- range_span,
- "try using the maximum value for the type",
- format!("{}{}MAX", pprust::expr_to_string(&begin), form),
- Applicability::HasPlaceholders,
- )
- .emit();
+ self.struct_span_err(
+ range_span,
+ &format!("`X{}` range patterns are not supported", form),
+ )
+ .span_suggestion(
+ range_span,
+ "try using the maximum value for the type",
+ format!("{}{}MAX", pprust::expr_to_string(&begin), form),
+ Applicability::HasPlaceholders,
+ )
+ .emit();
Ok(self.mk_expr(range_span, ExprKind::Err, AttrVec::new()))
}
// Make a span over ${unmatched angle bracket count} characters.
let span = lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
- self.diagnostic()
- .struct_span_err(
- span,
- &format!(
- "unmatched angle bracket{}",
- pluralize!(snapshot.unmatched_angle_bracket_count)
- ),
- )
- .span_suggestion(
- span,
- &format!(
- "remove extra angle bracket{}",
- pluralize!(snapshot.unmatched_angle_bracket_count)
- ),
- String::new(),
- Applicability::MachineApplicable,
- )
- .emit();
+ self.struct_span_err(
+ span,
+ &format!(
+ "unmatched angle bracket{}",
+ pluralize!(snapshot.unmatched_angle_bracket_count)
+ ),
+ )
+ .span_suggestion(
+ span,
+ &format!(
+ "remove extra angle bracket{}",
+ pluralize!(snapshot.unmatched_angle_bracket_count)
+ ),
+ String::new(),
+ Applicability::MachineApplicable,
+ )
+ .emit();
// Try again without unmatched angle bracket characters.
self.parse_generic_args()