fn check_inline(&self, attr: &ast::Attribute, target: Target) {
if target != Target::Fn {
struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function")
- .span_label(attr.span, &format!("requires a function"))
+ .span_label(attr.span, "requires a function")
.emit();
}
}
_ => continue,
};
struct_span_err!(self.sess, attr.span, E0517, "{}", message)
- .span_label(attr.span, &format!("requires {}", label))
+ .span_label(attr.span, format!("requires {}", label))
.emit();
}
if conflicting_reprs > 1 {
}
}
- diag.span_label(span, &terr);
+ diag.span_label(span, terr.to_string());
if let Some((sp, msg)) = secondary_span {
- diag.span_label(sp, &msg);
+ diag.span_label(sp, msg);
}
self.note_error_origin(diag, &cause);
"{}({}) overruled by outer forbid({})",
level.as_str(), lint_name,
lint_name);
- diag_builder.span_label(span, &format!("overruled by previous forbid"));
+ diag_builder.span_label(span, "overruled by previous forbid");
match now_source {
LintSource::Default => &mut diag_builder,
LintSource::Node(_, forbid_source_span) => {
diag_builder.span_label(forbid_source_span,
- &format!("`forbid` level set here"))
+ "`forbid` level set here")
},
LintSource::CommandLine(_) => {
diag_builder.note("`forbid` lint level was set on command line")
{
match self.description() {
ConstEvalErrDescription::Simple(message) => {
- diag.span_label(self.span, &message);
+ diag.span_label(self.span, message);
}
}
struct_span_err!(
self.tcx.sess, span, E0133,
"{} requires unsafe function or block", description)
- .span_label(span, &description)
+ .span_label(span, description)
.emit();
}
}
} else {
struct_span_err!(ctxt.session, item.span, E0137,
"multiple functions with a #[main] attribute")
- .span_label(item.span, &format!("additional #[main] function"))
- .span_label(ctxt.attr_main_fn.unwrap().1, &format!("first #[main] function"))
+ .span_label(item.span, "additional #[main] function")
+ .span_label(ctxt.attr_main_fn.unwrap().1, "first #[main] function")
.emit();
}
},
ctxt.session, item.span, E0138,
"multiple 'start' functions")
.span_label(ctxt.start_fn.unwrap().1,
- &format!("previous `start` function here"))
- .span_label(item.span, &format!("multiple `start` functions"))
+ "previous `start` function here")
+ .span_label(item.span, "multiple `start` functions")
.emit();
}
},
struct_span_err!(self.infcx.tcx.sess, span, E0591,
"`{}` is zero-sized and can't be transmuted to `{}`",
from, to)
- .span_note(span, &format!("cast with `as` to a pointer instead"))
+ .span_note(span, "cast with `as` to a pointer instead")
.emit();
return;
}
from, skeleton_string(from, sk_from),
to, skeleton_string(to, sk_to))
.span_label(span,
- &format!("transmuting between {} and {}",
+ format!("transmuting between {} and {}",
skeleton_string(from, sk_from),
skeleton_string(to, sk_to)))
.emit();
{} name that is already in scope",
shadower.kind.desc(), name, orig.kind.desc()))
};
- err.span_label(orig.span, &"first declared here");
+ err.span_label(orig.span, "first declared here");
err.span_label(shadower.span,
- &format!("lifetime {} already in scope", name));
+ format!("lifetime {} already in scope", name));
err.emit();
}
} else {
struct_span_err!(self.sess, lifetime_ref.span, E0261,
"use of undeclared lifetime name `{}`", lifetime_ref.name)
- .span_label(lifetime_ref.span, &format!("undeclared lifetime"))
+ .span_label(lifetime_ref.span, "undeclared lifetime")
.emit();
}
}
} else {
format!("expected lifetime parameter")
};
- err.span_label(span, &msg);
+ err.span_label(span, msg);
if let Some(params) = error {
if lifetime_refs.len() == 1 {
let mut err = struct_span_err!(self.sess, lifetime.span, E0262,
"invalid lifetime parameter name: `{}`", lifetime.name);
err.span_label(lifetime.span,
- &format!("{} is a reserved lifetime name", lifetime.name));
+ format!("{} is a reserved lifetime name", lifetime.name));
err.emit();
}
}
"lifetime name `{}` declared twice in the same scope",
lifetime_j.lifetime.name)
.span_label(lifetime_j.lifetime.span,
- &format!("declared twice"))
+ "declared twice")
.span_label(lifetime_i.lifetime.span,
- &format!("previous declaration here"))
+ "previous declaration here")
.emit();
}
}
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
let span = self.tcx.sess.codemap().def_span(trait_item_span);
- err.span_label(span, &format!("definition of `{}` from trait", item_name));
+ err.span_label(span, format!("definition of `{}` from trait", item_name));
}
err.span_label(
error_span,
- &format!("impl has extra requirement {}", requirement));
+ format!("impl has extra requirement {}", requirement));
if let Some(node_id) = lint_id {
self.tcx.sess.add_lint_diagnostic(EXTRA_REQUIREMENT_IN_IMPL,
}
err.span_label(span,
- &format!("{}the trait `{}` is not implemented for `{}`",
+ format!("{}the trait `{}` is not implemented for `{}`",
pre_message,
trait_ref,
trait_ref.self_ty()));
expected_ref,
found_ref);
- err.span_label(span, &format!("{}", type_error));
+ err.span_label(span, format!("{}", type_error));
if let Some(sp) = found_span {
- err.span_label(span, &format!("requires `{}`", found_ref));
- err.span_label(sp, &format!("implements `{}`", expected_ref));
+ err.span_label(span, format!("requires `{}`", found_ref));
+ err.span_label(sp, format!("implements `{}`", expected_ref));
}
err
if expected == 1 { "" } else { "s" },
if expected == 1 { "is" } else { "are" });
- err.span_label(span, &format!("expected {} that takes {} argument{}",
+ err.span_label(span, format!("expected {} that takes {} argument{}",
if is_closure { "closure" } else { "function" },
expected,
if expected == 1 { "" } else { "s" }));
if let Some(span) = found_span {
- err.span_label(span, &format!("takes {} argument{}",
+ err.span_label(span, format!("takes {} argument{}",
found,
if found == 1 { "" } else { "s" }));
}
let mut err = struct_span_err!(self.sess, span, E0072,
"recursive type `{}` has infinite size",
self.item_path_str(type_def_id));
- err.span_label(span, &format!("recursive type has infinite size"));
+ err.span_label(span, "recursive type has infinite size");
err.help(&format!("insert indirection (e.g., a `Box`, `Rc`, or `&`) \
at some point to make `{}` representable",
self.item_path_str(type_def_id)));
self.sess, span, E0038,
"the trait `{}` cannot be made into an object",
trait_str);
- err.span_label(span, &format!("the trait `{}` cannot be made into an object", trait_str));
+ err.span_label(span, format!("the trait `{}` cannot be made into an object", trait_str));
let mut reported_violations = FxHashSet();
for violation in violations {
"type annotations needed");
for (target_span, label_message) in labels {
- err.span_label(target_span, &label_message);
+ err.span_label(target_span, label_message);
}
err.emit();
let mut err =
struct_span_err!(self.sess, span, E0391,
"unsupported cyclic reference between types/traits detected");
- err.span_label(span, &format!("cyclic reference"));
+ err.span_label(span, "cyclic reference");
err.span_note(stack[0].0, &format!("the cycle begins when {}...",
stack[0].1.describe(self)));
nl, new_loan_msg);
err.span_label(
old_loan.span,
- &format!("first mutable borrow occurs here{}", old_loan_msg));
+ format!("first mutable borrow occurs here{}", old_loan_msg));
err.span_label(
new_loan.span,
- &format!("second mutable borrow occurs here{}", new_loan_msg));
+ format!("second mutable borrow occurs here{}", new_loan_msg));
err.span_label(
previous_end_span,
- &format!("first borrow ends here"));
+ "first borrow ends here");
err
}
nl);
err.span_label(
old_loan.span,
- &format!("first closure is constructed here"));
+ "first closure is constructed here");
err.span_label(
new_loan.span,
- &format!("second closure is constructed here"));
+ "second closure is constructed here");
err.span_label(
previous_end_span,
- &format!("borrow from first closure ends here"));
+ "borrow from first closure ends here");
err
}
nl, ol_pronoun, old_loan_msg);
err.span_label(
new_loan.span,
- &format!("closure construction occurs here{}", new_loan_msg));
+ format!("closure construction occurs here{}", new_loan_msg));
err.span_label(
old_loan.span,
- &format!("borrow occurs here{}", old_loan_msg));
+ format!("borrow occurs here{}", old_loan_msg));
err.span_label(
previous_end_span,
- &format!("borrow ends here"));
+ "borrow ends here");
err
}
nl, new_loan_msg, new_loan.kind.to_user_str());
err.span_label(
new_loan.span,
- &format!("borrow occurs here{}", new_loan_msg));
+ format!("borrow occurs here{}", new_loan_msg));
err.span_label(
old_loan.span,
- &format!("closure construction occurs here{}", old_loan_msg));
+ format!("closure construction occurs here{}", old_loan_msg));
err.span_label(
previous_end_span,
- &format!("borrow from closure ends here"));
+ "borrow from closure ends here");
err
}
old_loan_msg);
err.span_label(
new_loan.span,
- &format!("{} borrow occurs here{}",
+ format!("{} borrow occurs here{}",
new_loan.kind.to_user_str(),
new_loan_msg));
err.span_label(
old_loan.span,
- &format!("{} borrow occurs here{}",
+ format!("{} borrow occurs here{}",
old_loan.kind.to_user_str(),
old_loan_msg));
err.span_label(
previous_end_span,
- &format!("{} borrow ends here",
+ format!("{} borrow ends here",
old_loan.kind.to_user_str()));
err
}
euv::ClosureCapture(span) => {
err.span_label(
span,
- &format!("borrow occurs due to use of `{}` in closure", nl));
+ format!("borrow occurs due to use of `{}` in closure", nl));
}
_ => { }
}
euv::ClosureCapture(span) => {
err.span_label(
span,
- &format!("previous borrow occurs due to use of `{}` in closure",
+ format!("previous borrow occurs due to use of `{}` in closure",
ol));
}
_ => { }
"cannot use `{}` because it was mutably borrowed",
&self.bccx.loan_path_to_string(copy_path))
.span_label(loan_span,
- &format!("borrow of `{}` occurs here",
+ format!("borrow of `{}` occurs here",
&self.bccx.loan_path_to_string(&loan_path))
)
.span_label(span,
- &format!("use of borrowed `{}`",
+ format!("use of borrowed `{}`",
&self.bccx.loan_path_to_string(&loan_path)))
.emit();
}
&self.bccx.loan_path_to_string(move_path));
err.span_label(
loan_span,
- &format!("borrow of `{}` occurs here",
+ format!("borrow of `{}` occurs here",
&self.bccx.loan_path_to_string(&loan_path))
);
err.span_label(
span,
- &format!("move into closure occurs here")
+ "move into closure occurs here"
);
err
}
&self.bccx.loan_path_to_string(move_path));
err.span_label(
loan_span,
- &format!("borrow of `{}` occurs here",
+ format!("borrow of `{}` occurs here",
&self.bccx.loan_path_to_string(&loan_path))
);
err.span_label(
span,
- &format!("move out of `{}` occurs here",
+ format!("move out of `{}` occurs here",
&self.bccx.loan_path_to_string(move_path))
);
err
"cannot assign to `{}` because it is borrowed",
self.bccx.loan_path_to_string(loan_path))
.span_label(loan.span,
- &format!("borrow of `{}` occurs here",
+ format!("borrow of `{}` occurs here",
self.bccx.loan_path_to_string(loan_path)))
.span_label(span,
- &format!("assignment to borrowed `{}` occurs here",
+ format!("assignment to borrowed `{}` occurs here",
self.bccx.loan_path_to_string(loan_path)))
.emit();
}
}
if let NoteClosureEnv(upvar_id) = error.move_from.note {
err.span_label(bccx.tcx.hir.span(upvar_id.var_id),
- &"captured outer variable");
+ "captured outer variable");
}
err.emit();
move_from.descriptive_string(bccx.tcx));
err.span_label(
move_from.span,
- &format!("cannot move out of {}", move_from.descriptive_string(bccx.tcx))
+ format!("cannot move out of {}", move_from.descriptive_string(bccx.tcx))
);
err
}
"cannot move out of type `{}`, \
a non-copy array",
b.ty);
- err.span_label(move_from.span, &format!("cannot move out of here"));
+ err.span_label(move_from.span, "cannot move out of here");
err
}
(_, Kind::Pattern) => {
"cannot move out of type `{}`, \
which implements the `Drop` trait",
b.ty);
- err.span_label(move_from.span, &format!("cannot move out of here"));
+ err.span_label(move_from.span, "cannot move out of here");
err
},
_ => {
if is_first_note {
err.span_label(
move_to_span,
- &format!("hint: to prevent move, use `ref {0}` or `ref mut {0}`",
+ format!("hint: to prevent move, use `ref {0}` or `ref mut {0}`",
pat_name));
err
} else {
err.span_label(move_to_span,
- &format!("...and here (use `ref {0}` or `ref mut {0}`)",
+ format!("...and here (use `ref {0}` or `ref mut {0}`)",
pat_name));
err
}
"{} of possibly uninitialized variable: `{}`",
verb,
self.loan_path_to_string(lp))
- .span_label(use_span, &format!("use of possibly uninitialized `{}`",
+ .span_label(use_span, format!("use of possibly uninitialized `{}`",
self.loan_path_to_string(lp)))
.emit();
return;
err = if use_span == move_span {
err.span_label(
use_span,
- &format!("value moved{} here in previous iteration of loop",
+ format!("value moved{} here in previous iteration of loop",
move_note));
err
} else {
- err.span_label(use_span, &format!("value {} here after move", verb_participle))
- .span_label(move_span, &format!("value moved{} here", move_note));
+ err.span_label(use_span, format!("value {} here after move", verb_participle))
+ .span_label(move_span, format!("value moved{} here", move_note));
err
};
self.tcx.sess, span, E0384,
"re-assignment of immutable variable `{}`",
self.loan_path_to_string(lp));
- err.span_label(span, &format!("re-assignment of immutable variable"));
+ err.span_label(span, "re-assignment of immutable variable");
if span != assign.span {
- err.span_label(assign.span, &format!("first assignment to `{}`",
+ err.span_label(assign.span, format!("first assignment to `{}`",
self.loan_path_to_string(lp)));
}
err.emit();
let mut err = struct_span_err!(
self.tcx.sess, span, E0389,
"{} in a `&` reference", prefix);
- err.span_label(span, &"assignment into an immutable reference");
+ err.span_label(span, "assignment into an immutable reference");
err
}
};
}
db.span_label(
let_span,
- &format!("consider changing this to `mut {}`", snippet)
+ format!("consider changing this to `mut {}`", snippet)
);
}
}
if let Ok(snippet) = snippet {
db.span_label(
let_span,
- &format!("consider changing this to `{}`",
+ format!("consider changing this to `{}`",
snippet.replace("ref ", "ref mut "))
);
}
if let (Some(local_ty), is_implicit_self) = self.local_ty(node_id) {
if let Some(msg) =
self.suggest_mut_for_immutable(local_ty, is_implicit_self) {
- db.span_label(local_ty.span, &msg);
+ db.span_label(local_ty.span, msg);
}
}
}
if let hir_map::Node::NodeField(ref field) = self.tcx.hir.get(node_id) {
if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) {
- db.span_label(field.ty.span, &msg);
+ db.span_label(field.ty.span, msg);
}
}
}
which is owned by the current function",
cmt_path_or_string)
.span_label(capture_span,
- &format!("{} is borrowed here",
+ format!("{} is borrowed here",
cmt_path_or_string))
.span_label(err.span,
- &format!("may outlive borrowed value {}",
+ format!("may outlive borrowed value {}",
cmt_path_or_string))
.span_suggestion(err.span,
&format!("to force the closure to take ownership of {} \
match db.span.primary_span() {
Some(primary) => {
db.span = MultiSpan::from_span(s);
- db.span_label(primary, &format!("capture occurs here"));
- db.span_label(s, &"does not live long enough");
+ db.span_label(primary, "capture occurs here");
+ db.span_label(s, "does not live long enough");
true
}
None => false
}
}
_ => {
- db.span_label(error_span, &"does not live long enough");
+ db.span_label(error_span, "does not live long enough");
false
}
};
(Some(s1), Some(s2)) if s1 == s2 => {
if !is_closure {
db.span = MultiSpan::from_span(s1);
- db.span_label(error_span, &value_msg);
+ db.span_label(error_span, value_msg);
let msg = match opt_loan_path(&err.cmt) {
None => value_kind.to_string(),
Some(lp) => {
}
};
db.span_label(s1,
- &format!("{} dropped here while still borrowed", msg));
+ format!("{} dropped here while still borrowed", msg));
} else {
- db.span_label(s1, &format!("{} dropped before borrower", value_kind));
+ db.span_label(s1, format!("{} dropped before borrower", value_kind));
}
db.note("values in a scope are dropped in the opposite order \
they are created");
}
(Some(s1), Some(s2)) if !is_closure => {
db.span = MultiSpan::from_span(s2);
- db.span_label(error_span, &value_msg);
+ db.span_label(error_span, value_msg);
let msg = match opt_loan_path(&err.cmt) {
None => value_kind.to_string(),
Some(lp) => {
format!("`{}`", self.loan_path_to_string(&lp))
}
};
- db.span_label(s2, &format!("{} dropped here while still borrowed", msg));
- db.span_label(s1, &format!("{} needs to live until here", value_kind));
+ db.span_label(s2, format!("{} dropped here while still borrowed", msg));
+ db.span_label(s1, format!("{} needs to live until here", value_kind));
}
_ => {
match sub_span {
Some(s) => {
- db.span_label(s, &format!("{} needs to live until here",
+ db.span_label(s, format!("{} needs to live until here",
value_kind));
}
None => {
}
match super_span {
Some(s) => {
- db.span_label(s, &format!("{} only lives until here", value_kind));
+ db.span_label(s, format!("{} only lives until here", value_kind));
}
None => {
self.tcx.note_and_explain_region(
}
_ => {
if let Categorization::Deref(..) = err.cmt.cat {
- db.span_label(*error_span, &"cannot borrow as mutable");
+ db.span_label(*error_span, "cannot borrow as mutable");
} else if let Categorization::Local(local_id) = err.cmt.cat {
let span = self.tcx.hir.span(local_id);
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
- db.span_label(*error_span, &format!("cannot reborrow mutably"));
- db.span_label(*error_span, &format!("try removing `&mut` here"));
+ db.span_label(*error_span, "cannot reborrow mutably");
+ db.span_label(*error_span, "try removing `&mut` here");
} else {
- db.span_label(*error_span, &format!("cannot borrow mutably"));
+ db.span_label(*error_span, "cannot borrow mutably");
}
} else {
- db.span_label(*error_span, &format!("cannot borrow mutably"));
+ db.span_label(*error_span, "cannot borrow mutably");
}
} else if let Categorization::Interior(ref cmt, _) = err.cmt.cat {
if let mc::MutabilityCategory::McImmutable = cmt.mutbl {
db.span_label(*error_span,
- &"cannot mutably borrow immutable field");
+ "cannot mutably borrow immutable field");
}
}
}
"refutable pattern in {}: `{}` not covered",
origin, pattern_string
);
- diag.span_label(pat.span, &format!("pattern `{}` not covered", pattern_string));
+ diag.span_label(pat.span, format!("pattern `{}` not covered", pattern_string));
diag.emit();
});
}
let span = first_pat.0.span;
struct_span_err!(cx.tcx.sess, span, E0162,
"irrefutable if-let pattern")
- .span_label(span, &format!("irrefutable pattern"))
+ .span_label(span, "irrefutable pattern")
.emit();
printed_if_let_err = true;
}
1 => {
struct_span_err!(cx.tcx.sess, span, E0165,
"irrefutable while-let pattern")
- .span_label(span, &format!("irrefutable pattern"))
+ .span_label(span, "irrefutable pattern")
.emit();
},
_ => bug!(),
diagnostic.set_span(pat.span);
// if we had a catchall pattern, hint at that
if let Some(catchall) = catchall {
- diagnostic.span_label(pat.span, &"this is an unreachable pattern");
+ diagnostic.span_label(pat.span, "this is an unreachable pattern");
diagnostic.span_note(catchall, "this pattern matches any value");
}
cx.tcx.sess.add_lint_diagnostic(lint::builtin::UNREACHABLE_PATTERNS,
"refutable pattern in `for` loop binding: \
`{}` not covered",
pattern_string)
- .span_label(sp, &format!("pattern `{}` not covered", pattern_string))
+ .span_label(sp, format!("pattern `{}` not covered", pattern_string))
.emit();
},
_ => {
create_e0004(cx.tcx.sess, sp,
format!("non-exhaustive patterns: {} not covered",
joined_patterns))
- .span_label(sp, &label_text)
+ .span_label(sp, label_text)
.emit();
},
}
if sub.map_or(false, |p| p.contains_bindings()) {
struct_span_err!(cx.tcx.sess, p.span, E0007,
"cannot bind by-move with sub-bindings")
- .span_label(p.span, &format!("binds an already bound by-move value by moving it"))
+ .span_label(p.span, "binds an already bound by-move value by moving it")
.emit();
} else if has_guard {
struct_span_err!(cx.tcx.sess, p.span, E0008,
"cannot bind by-move into a pattern guard")
- .span_label(p.span, &format!("moves value into pattern guard"))
+ .span_label(p.span, "moves value into pattern guard")
.emit();
} else if by_ref_span.is_some() {
struct_span_err!(cx.tcx.sess, p.span, E0009,
"cannot bind by-move and by-ref in the same pattern")
- .span_label(p.span, &format!("by-move pattern here"))
- .span_label(by_ref_span.unwrap(), &format!("both by-ref and by-move used"))
+ .span_label(p.span, "by-move pattern here")
+ .span_label(by_ref_span.unwrap(), "both by-ref and by-move used")
.emit();
}
};
ty::MutBorrow => {
struct_span_err!(self.cx.tcx.sess, span, E0301,
"cannot mutably borrow in a pattern guard")
- .span_label(span, &format!("borrowed mutably in pattern guard"))
+ .span_label(span, "borrowed mutably in pattern guard")
.emit();
}
ty::ImmBorrow | ty::UniqueImmBorrow => {}
match mode {
MutateMode::JustWrite | MutateMode::WriteAndRead => {
struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
- .span_label(span, &format!("assignment in pattern guard"))
+ .span_label(span, "assignment in pattern guard")
.emit();
}
MutateMode::Init => {}
if !self.bindings_allowed {
struct_span_err!(self.cx.tcx.sess, pat.span, E0303,
"pattern bindings are not allowed after an `@`")
- .span_label(pat.span, &format!("not allowed after `@`"))
+ .span_label(pat.span, "not allowed after `@`")
.emit();
}
/// all, and you just supplied a `Span` to create the diagnostic,
/// then the snippet will just include that `Span`, which is
/// called the primary span.
- pub fn span_label(&mut self, span: Span, label: &fmt::Display)
- -> &mut Self {
- self.span.push_span_label(span, format!("{}", label));
+ pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self {
+ self.span.push_span_label(span, label.into());
self
}
/// all, and you just supplied a `Span` to create the diagnostic,
/// then the snippet will just include that `Span`, which is
/// called the primary span.
- forward!(pub fn span_label(&mut self, span: Span, label: &fmt::Display)
- -> &mut Self);
+ pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self {
+ self.diagnostic.span_label(span, label);
+ self
+ }
forward!(pub fn note_expected_found(&mut self,
label: &fmt::Display,
None => {
self.tcx.sess.span_fatal(
attr.span,
- &format!("missing DepNode variant"));
+ "missing DepNode variant");
}
};
self.then_this_would_need.push((attr.span,
for &(target_span, _, _, _) in then_this_would_need {
tcx.sess.span_err(
target_span,
- &format!("no #[rustc_if_this_changed] annotation detected"));
+ "no #[rustc_if_this_changed] annotation detected");
}
return;
} else {
tcx.sess.span_err(
target_span,
- &format!("OK"));
+ "OK");
}
}
}
tcx.sess.span_fatal(
attr.span,
- &format!("no cfg attribute"));
+ "no cfg attribute");
}
fn expect_associated_value(tcx: TyCtxt, item: &NestedMetaItem) -> ast::Name {
let mut db = cx.struct_span_lint(UNUSED_UNSAFE, blk.span,
"unnecessary `unsafe` block");
- db.span_label(blk.span, &"unnecessary `unsafe` block");
+ db.span_label(blk.span, "unnecessary `unsafe` block");
if let Some((kind, id)) = is_enclosed(cx, blk.id) {
db.span_note(cx.tcx.hir.span(id),
&format!("because it's nested under this `unsafe` {}", kind));
Some(span) => {
struct_span_err!(sess, span, E0454,
"#[link(name = \"\")] given with empty name")
- .span_label(span, &format!("empty name given"))
+ .span_label(span, "empty name given")
.emit();
}
None => {
Some(k) => {
struct_span_err!(self.sess, m.span, E0458,
"unknown kind: `{}`", k)
- .span_label(m.span, &format!("unknown kind")).emit();
+ .span_label(m.span, "unknown kind").emit();
cstore::NativeUnknown
}
None => cstore::NativeUnknown
None => {
struct_span_err!(self.sess, m.span, E0459,
"#[link(...)] specified without `name = \"foo\"`")
- .span_label(m.span, &format!("missing `name` argument")).emit();
+ .span_label(m.span, "missing `name` argument").emit();
Symbol::intern("foo")
}
};
&& self.triple != config::host_triple() {
err.note(&format!("the `{}` target may not be installed", self.triple));
}
- err.span_label(self.span, &format!("can't find crate"));
+ err.span_label(self.span, "can't find crate");
err
};
to the crate attributes to enable");
} else {
self.find_drop_implementation_method_span()
- .map(|span| err.span_label(span, &format!("destructor defined here")));
+ .map(|span| err.span_label(span, "destructor defined here"));
- err.span_label(self.span, &format!("constants cannot have destructors"));
+ err.span_label(self.span, "constants cannot have destructors");
}
err.emit();
"cannot refer to statics by value, use a constant instead"
};
struct_span_err!(self.tcx.sess, self.span, E0394, "{}", msg)
- .span_label(self.span, &format!("referring to another static by value"))
- .note(&format!("use the address-of operator or a constant instead"))
+ .span_label(self.span, "referring to another static by value")
+ .note("use the address-of operator or a constant instead")
.emit();
// Replace STATIC with NOT_CONST to avoid further errors.
"raw pointers cannot be dereferenced in {}s",
this.mode)
.span_label(this.span,
- &format!("dereference of raw pointer in constant"))
+ "dereference of raw pointer in constant")
.emit();
}
}
struct_span_err!(self.tcx.sess, self.span, E0017,
"references in {}s may only refer \
to immutable values", self.mode)
- .span_label(self.span, &format!("{}s require immutable values",
+ .span_label(self.span, format!("{}s require immutable values",
self.mode))
.emit();
}
self.mode)
.span_label(
self.span,
- &format!("comparing raw pointers in static"))
+ "comparing raw pointers in static")
.emit();
}
}
if self.mode != Mode::Fn {
struct_span_err!(self.tcx.sess, self.span, E0010,
"allocations are not allowed in {}s", self.mode)
- .span_label(self.span, &format!("allocation not allowed in {}s", self.mode))
+ .span_label(self.span, format!("allocation not allowed in {}s", self.mode))
.emit();
}
}
E0449,
"unnecessary visibility qualifier");
if vis == &Visibility::Public {
- err.span_label(span, &format!("`pub` not needed here"));
+ err.span_label(span, "`pub` not needed here");
}
if let Some(note) = note {
err.note(note);
Constness::Const => {
struct_span_err!(self.session, constness.span, E0379,
"trait fns cannot be declared const")
- .span_label(constness.span, &format!("trait fns cannot be const"))
+ .span_label(constness.span, "trait fns cannot be const")
.emit();
}
_ => {}
E0130,
"patterns aren't allowed in foreign function \
declarations");
- err.span_label(span, &format!("pattern not allowed in foreign function"));
+ err.span_label(span, "pattern not allowed in foreign function");
if is_recent {
err.span_note(span,
"this is a recent error, see issue #35203 for more details");
Ok(Ordering::Greater) => {
struct_span_err!(self.tcx.sess, start.span, E0030,
"lower range bound must be less than or equal to upper")
- .span_label(start.span, &format!("lower bound larger than upper bound"))
+ .span_label(start.span, "lower bound larger than upper bound")
.emit();
}
Err(ErrorReported) => {}
"`break` with value from a `{}` loop",
kind.name())
.span_label(e.span,
- &format!("can only break with a value inside `loop`"))
+ "can only break with a value inside `loop`")
.emit();
}
}
Loop(_) => {}
Closure => {
struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name)
- .span_label(span, &format!("cannot break inside of a closure"))
+ .span_label(span, "cannot break inside of a closure")
.emit();
}
Normal => {
struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name)
- .span_label(span, &format!("cannot break outside of a loop"))
+ .span_label(span, "cannot break outside of a loop")
.emit();
}
}
struct_span_err!(self.sess, span, E0590,
"`break` or `continue` with no label in the condition of a `while` loop")
.span_label(span,
- &format!("unlabeled `{}` in the condition of a `while` loop", cf_type))
+ format!("unlabeled `{}` in the condition of a `while` loop", cf_type))
.emit();
}
}
});
if !any_static {
struct_span_err!(self.sess, span, E0265, "recursive constant")
- .span_label(span, &format!("recursion not allowed in constant"))
+ .span_label(span, "recursion not allowed in constant")
.emit();
}
return;
if !def.is_enum() && !field.vis.is_accessible_from(self.current_item, self.tcx) {
struct_span_err!(self.tcx.sess, span, E0451, "field `{}` of {} `{}` is private",
field.name, def.variant_descr(), self.tcx.item_path_str(def.did))
- .span_label(span, &format!("field `{}` is private", field.name))
+ .span_label(span, format!("field `{}` is private", field.name))
.emit();
}
}
if self.has_pub_restricted || self.has_old_errors {
let mut err = struct_span_err!(self.tcx.sess, self.span, E0446,
"private type `{}` in public interface", ty);
- err.span_label(self.span, &format!("can't leak private type"));
+ err.span_label(self.span, "can't leak private type");
err.emit();
} else {
self.tcx.sess.add_lint(lint::builtin::PRIVATE_IN_PUBLIC,
if self.has_pub_restricted || self.has_old_errors {
struct_span_err!(self.tcx.sess, self.span, E0445,
"private trait `{}` in public interface", trait_ref)
- .span_label(self.span, &format!(
+ .span_label(self.span, format!(
"private trait can't be public"))
.emit();
} else {
E0401,
"can't use type parameters from outer function; \
try using a local type parameter instead");
- err.span_label(span, &format!("use of type variable from outer function"));
+ err.span_label(span, "use of type variable from outer function");
err
}
ResolutionError::OuterTypeParameterContext => {
"the name `{}` is already used for a type parameter \
in this type parameter list",
name);
- err.span_label(span, &format!("already used"));
- err.span_label(first_use_span.clone(), &format!("first use of `{}`", name));
+ err.span_label(span, "already used");
+ err.span_label(first_use_span.clone(), format!("first use of `{}`", name));
err
}
ResolutionError::MethodNotMemberOfTrait(method, trait_) => {
"method `{}` is not a member of trait `{}`",
method,
trait_);
- err.span_label(span, &format!("not a member of trait `{}`", trait_));
+ err.span_label(span, format!("not a member of trait `{}`", trait_));
err
}
ResolutionError::TypeNotMemberOfTrait(type_, trait_) => {
"type `{}` is not a member of trait `{}`",
type_,
trait_);
- err.span_label(span, &format!("not a member of trait `{}`", trait_));
+ err.span_label(span, format!("not a member of trait `{}`", trait_));
err
}
ResolutionError::ConstNotMemberOfTrait(const_, trait_) => {
"const `{}` is not a member of trait `{}`",
const_,
trait_);
- err.span_label(span, &format!("not a member of trait `{}`", trait_));
+ err.span_label(span, format!("not a member of trait `{}`", trait_));
err
}
ResolutionError::VariableNotBoundInPattern(binding_error) => {
let msg = format!("variable `{}` is not bound in all patterns", binding_error.name);
let mut err = resolver.session.struct_span_err_with_code(msp, &msg, "E0408");
for sp in target_sp {
- err.span_label(sp, &format!("pattern doesn't bind `{}`", binding_error.name));
+ err.span_label(sp, format!("pattern doesn't bind `{}`", binding_error.name));
}
let origin_sp = binding_error.origin.iter().map(|x| *x).collect::<Vec<_>>();
for sp in origin_sp {
- err.span_label(sp, &"variable not in all patterns");
+ err.span_label(sp, "variable not in all patterns");
}
err
}
"variable `{}` is bound in inconsistent \
ways within the same match arm",
variable_name);
- err.span_label(span, &format!("bound in different ways"));
- err.span_label(first_binding_span, &format!("first binding"));
+ err.span_label(span, "bound in different ways");
+ err.span_label(first_binding_span, "first binding");
err
}
ResolutionError::IdentifierBoundMoreThanOnceInParameterList(identifier) => {
E0415,
"identifier `{}` is bound more than once in this parameter list",
identifier);
- err.span_label(span, &format!("used as parameter more than once"));
+ err.span_label(span, "used as parameter more than once");
err
}
ResolutionError::IdentifierBoundMoreThanOnceInSamePattern(identifier) => {
E0416,
"identifier `{}` is bound more than once in the same pattern",
identifier);
- err.span_label(span, &format!("used in a pattern more than once"));
+ err.span_label(span, "used in a pattern more than once");
err
}
ResolutionError::UndeclaredLabel(name) => {
E0426,
"use of undeclared label `{}`",
name);
- err.span_label(span, &format!("undeclared label `{}`",&name));
+ err.span_label(span, format!("undeclared label `{}`", name));
err
}
ResolutionError::SelfImportsOnlyAllowedWithin => {
};
let mut err = struct_span_err!(resolver.session, span, E0432, "{}", msg);
if let Some((_, p)) = name {
- err.span_label(span, &p);
+ err.span_label(span, p);
}
err
}
ResolutionError::FailedToResolve(msg) => {
let mut err = struct_span_err!(resolver.session, span, E0433,
"failed to resolve. {}", msg);
- err.span_label(span, &msg);
+ err.span_label(span, msg);
err
}
ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => {
span,
E0435,
"attempt to use a non-constant value in a constant");
- err.span_label(span, &format!("non-constant used with constant"));
+ err.span_label(span, "non-constant used with constant");
err
}
ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => {
span,
E0530,
"{}s cannot shadow {}s", what_binding, shadows_what);
- err.span_label(span, &format!("cannot be named the same as a {}", shadows_what));
+ err.span_label(span, format!("cannot be named the same as a {}", shadows_what));
let participle = if binding.is_import() { "imported" } else { "defined" };
- let msg = &format!("a {} `{}` is {} here", shadows_what, name, participle);
+ let msg = format!("a {} `{}` is {} here", shadows_what, name, participle);
err.span_label(binding.span, msg);
err
}
let mut err = struct_span_err!(resolver.session, span, E0128,
"type parameters with a default cannot use \
forward declared identifiers");
- err.span_label(span, &format!("defaulted type parameters \
+ err.span_label(span, format!("defaulted type parameters \
cannot be forward declared"));
err
}
if is_self_type(path, ns) {
__diagnostic_used!(E0411);
err.code("E0411".into());
- err.span_label(span, &format!("`Self` is only available in traits and impls"));
+ err.span_label(span, "`Self` is only available in traits and impls");
return err;
}
if is_self_value(path, ns) {
__diagnostic_used!(E0424);
err.code("E0424".into());
- err.span_label(span, &format!("`self` value is only available in \
+ err.span_label(span, format!("`self` value is only available in \
methods with `self` parameter"));
return err;
}
let self_is_available = this.self_value_is_available(path[0].ctxt);
match candidate {
AssocSuggestion::Field => {
- err.span_label(span, &format!("did you mean `self.{}`?", path_str));
+ err.span_label(span, format!("did you mean `self.{}`?", path_str));
if !self_is_available {
- err.span_label(span, &format!("`self` value is only available in \
+ err.span_label(span, format!("`self` value is only available in \
methods with `self` parameter"));
}
}
AssocSuggestion::MethodWithSelf if self_is_available => {
- err.span_label(span, &format!("did you mean `self.{}(...)`?",
+ err.span_label(span, format!("did you mean `self.{}(...)`?",
path_str));
}
AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => {
- err.span_label(span, &format!("did you mean `Self::{}`?", path_str));
+ err.span_label(span, format!("did you mean `Self::{}`?", path_str));
}
}
return err;
// Try Levenshtein.
if let Some(candidate) = this.lookup_typo_candidate(path, ns, is_expected) {
- err.span_label(ident_span, &format!("did you mean `{}`?", candidate));
+ err.span_label(ident_span, format!("did you mean `{}`?", candidate));
levenshtein_worked = true;
}
if let Some(def) = def {
match (def, source) {
(Def::Macro(..), _) => {
- err.span_label(span, &format!("did you mean `{}!(...)`?", path_str));
+ err.span_label(span, format!("did you mean `{}!(...)`?", path_str));
return err;
}
(Def::TyAlias(..), PathSource::Trait) => {
- err.span_label(span, &format!("type aliases cannot be used for traits"));
+ err.span_label(span, "type aliases cannot be used for traits");
return err;
}
(Def::Mod(..), PathSource::Expr(Some(parent))) => match parent.node {
ExprKind::Field(_, ident) => {
- err.span_label(parent.span, &format!("did you mean `{}::{}`?",
+ err.span_label(parent.span, format!("did you mean `{}::{}`?",
path_str, ident.node));
return err;
}
ExprKind::MethodCall(ident, ..) => {
- err.span_label(parent.span, &format!("did you mean `{}::{}(...)`?",
+ err.span_label(parent.span, format!("did you mean `{}::{}(...)`?",
path_str, ident.node));
return err;
}
if let Some((ctor_def, ctor_vis))
= this.struct_constructors.get(&def_id).cloned() {
if is_expected(ctor_def) && !this.is_accessible(ctor_vis) {
- err.span_label(span, &format!("constructor is not visible \
+ err.span_label(span, format!("constructor is not visible \
here due to private fields"));
}
}
}
- err.span_label(span, &format!("did you mean `{} {{ /* fields */ }}`?",
+ err.span_label(span, format!("did you mean `{} {{ /* fields */ }}`?",
path_str));
return err;
}
// Fallback label.
if !levenshtein_worked {
- err.span_label(base_span, &fallback_label);
+ err.span_label(base_span, fallback_label);
}
err
};
},
};
- err.span_label(span, &format!("`{}` already {}", name, participle));
+ err.span_label(span, format!("`{}` already {}", name, participle));
if old_binding.span != syntax_pos::DUMMY_SP {
- err.span_label(old_binding.span, &format!("previous {} of `{}` here", noun, name));
+ err.span_label(old_binding.span, format!("previous {} of `{}` here", noun, name));
}
err.emit();
self.name_already_seen.insert(name, span);
err.help(&format!("did you mean `{}`?", suggestion));
}
} else {
- err.help(&format!("have you added the `#[macro_use]` on the module/import?"));
+ err.help("have you added the `#[macro_use]` on the module/import?");
}
}
}
Ok(binding) if !binding.is_importable() => {
let msg = format!("`{}` is not directly importable", target);
struct_span_err!(this.session, directive.span, E0253, "{}", &msg)
- .span_label(directive.span, &format!("cannot be imported directly"))
+ .span_label(directive.span, "cannot be imported directly")
.emit();
// Do not import this illegal binding. Import a dummy binding and pretend
// everything is fine
} else if ns == TypeNS {
struct_span_err!(self.session, directive.span, E0365,
"`{}` is private, and cannot be reexported", ident)
- .span_label(directive.span, &format!("reexport of private `{}`", ident))
+ .span_label(directive.span, format!("reexport of private `{}`", ident))
.note(&format!("consider declaring type or module `{}` with `pub`", ident))
.emit();
} else {
let msg =
format!("a macro named `{}` has already been exported", ident);
self.session.struct_span_err(span, &msg)
- .span_label(span, &format!("`{}` already exported", ident))
+ .span_label(span, format!("`{}` already exported", ident))
.span_note(binding.span, "previous macro export here")
.emit();
}
hir::ParenthesizedParameters(..) => {
struct_span_err!(tcx.sess, span, E0214,
"parenthesized parameters may only be used with a trait")
- .span_label(span, &format!("only traits may use parentheses"))
+ .span_label(span, "only traits may use parentheses")
.emit();
return Substs::for_item(tcx, def_id, |_, _| {
struct_span_err!(tcx.sess, span, E0393,
"the type parameter `{}` must be explicitly specified",
def.name)
- .span_label(span, &format!("missing reference to `{}`", def.name))
+ .span_label(span, format!("missing reference to `{}`", def.name))
.note(&format!("because of the default `Self` reference, \
type parameters must be specified on object types"))
.emit();
let span = b.trait_ref.path.span;
struct_span_err!(self.tcx().sess, span, E0225,
"only Send/Sync traits can be used as additional traits in a trait object")
- .span_label(span, &format!("non-Send/Sync additional trait"))
+ .span_label(span, "non-Send/Sync additional trait")
.emit();
}
"the value of the associated type `{}` (from the trait `{}`) must be specified",
name,
tcx.item_path_str(trait_def_id))
- .span_label(span, &format!(
+ .span_label(span, format!(
"missing associated type `{}` value", name))
.emit();
}
trait_str: &str,
name: &str) {
struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type")
- .span_label(span, &format!("ambiguous associated type"))
+ .span_label(span, "ambiguous associated type")
.note(&format!("specify the type using the syntax `<{} as {}>::{}`",
type_str, trait_str, name))
.emit();
"associated type `{}` not found for `{}`",
assoc_name,
ty_param_name)
- .span_label(span, &format!("associated type `{}` not found", assoc_name))
+ .span_label(span, format!("associated type `{}` not found", assoc_name))
.emit();
return Err(ErrorReported);
}
"ambiguous associated type `{}` in bounds of `{}`",
assoc_name,
ty_param_name);
- err.span_label(span, &format!("ambiguous associated type `{}`", assoc_name));
+ err.span_label(span, format!("ambiguous associated type `{}`", assoc_name));
for bound in bounds {
let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| {
.and_then(|item| self.tcx().hir.span_if_local(item.def_id));
if let Some(span) = bound_span {
- err.span_label(span, &format!("ambiguous `{}` from `{}`",
+ err.span_label(span, format!("ambiguous `{}` from `{}`",
assoc_name,
bound));
} else {
for typ in segment.parameters.types() {
struct_span_err!(self.tcx().sess, typ.span, E0109,
"type parameters are not allowed on this type")
- .span_label(typ.span, &format!("type parameter not allowed"))
+ .span_label(typ.span, "type parameter not allowed")
.emit();
break;
}
struct_span_err!(self.tcx().sess, lifetime.span, E0110,
"lifetime parameters are not allowed on this type")
.span_label(lifetime.span,
- &format!("lifetime parameter not allowed on this type"))
+ "lifetime parameter not allowed on this type")
.emit();
break;
}
pub fn prohibit_projection(&self, span: Span) {
let mut err = struct_span_err!(self.tcx().sess, span, E0229,
"associated type bindings are not allowed here");
- err.span_label(span, &format!("associate type not allowed here")).emit();
+ err.span_label(span, "associate type not allowed here").emit();
}
// Check a type Path and convert it to a Ty.
hir::TyTypeof(ref _e) => {
struct_span_err!(tcx.sess, ast_ty.span, E0516,
"`typeof` is a reserved keyword but unimplemented")
- .span_label(ast_ty.span, &format!("reserved keyword"))
+ .span_label(ast_ty.span, "reserved keyword")
.emit();
tcx.types.err
"wrong number of type arguments: {} {}, found {}",
expected, required, supplied)
.span_label(span,
- &format!("{} {} type argument{}",
+ format!("{} {} type argument{}",
expected,
required,
arguments_plural))
expected, supplied)
.span_label(
span,
- &format!("{} type argument{}",
+ format!("{} type argument{}",
if accepted == 0 { "expected no" } else { &expected },
arguments_plural)
)
struct_span_err!(tcx.sess, span, E0107,
"wrong number of lifetime parameters: expected {}, found {}",
expected, number)
- .span_label(span, &label)
+ .span_label(span, label)
.emit();
}
struct_span_err!(tcx.sess, span, E0029,
"only char and numeric types are allowed in range patterns")
- .span_label(span, &format!("ranges require char or numeric types"))
+ .span_label(span, "ranges require char or numeric types")
.note(&format!("start type: {}", self.ty_to_string(lhs_ty)))
.note(&format!("end type: {}", self.ty_to_string(rhs_ty)))
.emit();
tcx.sess, pat.span, E0527,
"pattern requires {} elements but array has {}",
min_len, size)
- .span_label(pat.span, &format!("expected {} elements",size))
+ .span_label(pat.span, format!("expected {} elements",size))
.emit();
}
(inner_ty, tcx.types.err)
"pattern requires at least {} elements but array has {}",
min_len, size)
.span_label(pat.span,
- &format!("pattern cannot match array of {} elements", size))
+ format!("pattern cannot match array of {} elements", size))
.emit();
(inner_ty, tcx.types.err)
}
}
err.span_label( pat.span,
- &format!("pattern cannot match with input type `{}`", expected_ty)
+ format!("pattern cannot match with input type `{}`", expected_ty)
).emit();
}
(tcx.types.err, tcx.types.err)
let type_str = self.ty_to_string(expected);
struct_span_err!(self.tcx.sess, span, E0033,
"type `{}` cannot be dereferenced", type_str)
- .span_label(span, &format!("type `{}` cannot be dereferenced", type_str))
+ .span_label(span, format!("type `{}` cannot be dereferenced", type_str))
.emit();
return false
}
def.kind_name(),
hir::print::to_string(&tcx.hir, |s| s.print_qpath(qpath, false)));
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
- .span_label(pat.span, &format!("not a tuple variant or struct")).emit();
+ .span_label(pat.span, "not a tuple variant or struct").emit();
on_error();
};
"this pattern has {} field{}, but the corresponding {} has {} field{}",
subpats.len(), subpats_ending, def.kind_name(),
variant.fields.len(), fields_ending)
- .span_label(pat.span, &format!("expected {} field{}, found {}",
+ .span_label(pat.span, format!("expected {} field{}, found {}",
variant.fields.len(), fields_ending, subpats.len()))
.emit();
on_error();
in the pattern",
field.name)
.span_label(span,
- &format!("multiple uses of `{}` in pattern", field.name))
- .span_label(*occupied.get(), &format!("first use of `{}`", field.name))
+ format!("multiple uses of `{}` in pattern", field.name))
+ .span_label(*occupied.get(), format!("first use of `{}`", field.name))
.emit();
tcx.types.err
}
tcx.item_path_str(variant.did),
field.name)
.span_label(span,
- &format!("{} `{}` does not have field `{}`",
+ format!("{} `{}` does not have field `{}`",
kind_name,
tcx.item_path_str(variant.did),
field.name))
struct_span_err!(tcx.sess, span, E0027,
"pattern does not mention field `{}`",
field.name)
- .span_label(span, &format!("missing field `{}`", field.name))
+ .span_label(span, format!("missing field `{}`", field.name))
.emit();
}
}
E0055,
"reached the recursion limit while auto-dereferencing {:?}",
self.cur_ty)
- .span_label(self.span, &format!("deref recursion limit reached"))
+ .span_label(self.span, "deref recursion limit reached")
.help(&format!(
"consider adding a `#[recursion_limit=\"{}\"]` attribute to your crate",
suggested_limit))
pub fn check_legal_trait_for_method_call(tcx: TyCtxt, span: Span, trait_id: DefId) {
if tcx.lang_items.drop_trait() == Some(trait_id) {
struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method")
- .span_label(span, &format!("explicit destructor calls not allowed"))
+ .span_label(span, "explicit destructor calls not allowed")
.emit();
}
}
},
self.expr_ty);
err.span_label(error_span,
- &format!("cannot cast `{}` as `{}`",
+ format!("cannot cast `{}` as `{}`",
fcx.ty_to_string(self.expr_ty),
cast_ty));
if let Ok(snippet) = fcx.sess().codemap().span_to_snippet(self.expr.span) {
}
CastError::CastToBool => {
struct_span_err!(fcx.tcx.sess, self.span, E0054, "cannot cast as `bool`")
- .span_label(self.span, &format!("unsupported cast"))
+ .span_label(self.span, "unsupported cast")
.help("compare with zero instead")
.emit();
}
db = struct_span_err!(
fcx.tcx.sess, cause.span, E0069,
"`return;` in a function whose return type is not `()`");
- db.span_label(cause.span, &format!("return type is not ()"));
+ db.span_label(cause.span, "return type is not ()");
}
_ => {
db = fcx.report_mismatched_types(cause, expected, found, err);
"lifetime parameters or bounds on method `{}` do not match the \
trait declaration",
impl_m.name)
- .span_label(span, &format!("lifetimes do not match trait"))
+ .span_label(span, "lifetimes do not match trait")
.emit();
return Err(ErrorReported);
}
not in the trait",
trait_m.name,
self_descr);
- err.span_label(impl_m_span, &format!("`{}` used in impl", self_descr));
+ err.span_label(impl_m_span, format!("`{}` used in impl", self_descr));
if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) {
- err.span_label(span, &format!("trait declared without `{}`", self_descr));
+ err.span_label(span, format!("trait declared without `{}`", self_descr));
}
err.emit();
return Err(ErrorReported);
trait_m.name,
self_descr);
err.span_label(impl_m_span,
- &format!("expected `{}` in impl", self_descr));
+ format!("expected `{}` in impl", self_descr));
if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) {
- err.span_label(span, &format!("`{}` used in trait", self_descr));
+ err.span_label(span, format!("`{}` used in trait", self_descr));
}
err.emit();
return Err(ErrorReported);
if let Some(span) = trait_item_span {
err.span_label(span,
- &format!("expected {}",
+ format!("expected {}",
&if num_trait_m_type_params != 1 {
format!("{} type parameters", num_trait_m_type_params)
} else {
}
err.span_label(span,
- &format!("found {}{}",
+ format!("found {}{}",
&if num_impl_m_type_params != 1 {
format!("{} type parameters", num_impl_m_type_params)
} else {
trait_number_args);
if let Some(trait_span) = trait_span {
err.span_label(trait_span,
- &format!("trait requires {}",
+ format!("trait requires {}",
&if trait_number_args != 1 {
format!("{} parameters", trait_number_args)
} else {
}));
}
err.span_label(impl_span,
- &format!("expected {}, found {}",
+ format!("expected {}, found {}",
&if trait_number_args != 1 {
format!("{} parameters", trait_number_args)
} else {
"intrinsic has wrong number of type \
parameters: found {}, expected {}",
i_n_tps, n_tps)
- .span_label(span, &format!("expected {} type parameter", n_tps))
+ .span_label(span, format!("expected {} type parameter", n_tps))
.emit();
} else {
require_same_types(tcx,
op => {
struct_span_err!(tcx.sess, it.span, E0092,
"unrecognized atomic operation function: `{}`", op)
- .span_label(it.span, &format!("unrecognized atomic operation"))
+ .span_label(it.span, "unrecognized atomic operation")
.emit();
return;
}
struct_span_err!(tcx.sess, it.span, E0093,
"unrecognized intrinsic function: `{}`",
*other)
- .span_label(it.span, &format!("unrecognized intrinsic"))
+ .span_label(it.span, "unrecognized intrinsic")
.emit();
return;
}
}
}
_ => simple_error(&format!("`{}`", t),
- &format!("tuple")),
+ "tuple"),
}
}
}
self.span,
E0035,
"does not take type parameters")
- .span_label(self.span, &"called with unneeded type parameters")
+ .span_label(self.span, "called with unneeded type parameters")
.emit();
} else {
struct_span_err!(self.tcx.sess,
num_method_types,
num_supplied_types)
.span_label(self.span,
- &format!("Passed {} type argument{}, expected {}",
+ format!("Passed {} type argument{}, expected {}",
num_supplied_types,
if num_supplied_types != 1 { "s" } else { "" },
num_method_types))
expr_string,
item_name));
}
- err.span_label(span, &"field, not a method");
+ err.span_label(span, "field, not a method");
} else {
- err.span_label(span, &"private field, not a method");
+ err.span_label(span, "private field, not a method");
}
break;
}
span,
E0034,
"multiple applicable items in scope");
- err.span_label(span, &format!("multiple `{}` found", item_name));
+ err.span_label(span, format!("multiple `{}` found", item_name));
report_candidates(&mut err, sources);
err.emit();
struct_span_err!(
tcx.sess, attr.span, E0232,
"this attribute must have a value")
- .span_label(attr.span, &format!("attribute requires a value"))
+ .span_label(attr.span, "attribute requires a value")
.note(&format!("eg `#[rustc_on_unimplemented = \"foo\"]`"))
.emit();
}
"`{}` specializes an item from a parent `impl`, but \
that item is not marked `default`",
impl_item.name);
- err.span_label(impl_item.span, &format!("cannot specialize default item `{}`",
+ err.span_label(impl_item.span, format!("cannot specialize default item `{}`",
impl_item.name));
match tcx.span_of_impl(parent_impl) {
Ok(span) => {
- err.span_label(span, &"parent `impl` is here");
+ err.span_label(span, "parent `impl` is here");
err.note(&format!("to specialize, `{}` in the parent `impl` must be marked `default`",
impl_item.name));
}
which doesn't match its trait `{}`",
ty_impl_item.name,
impl_trait_ref);
- err.span_label(impl_item.span, &format!("does not match trait"));
+ err.span_label(impl_item.span, "does not match trait");
// We can only get the spans from local trait definition
// Same for E0324 and E0325
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
- err.span_label(trait_span, &format!("item in trait"));
+ err.span_label(trait_span, "item in trait");
}
err.emit()
}
which doesn't match its trait `{}`",
ty_impl_item.name,
impl_trait_ref);
- err.span_label(impl_item.span, &format!("does not match trait"));
+ err.span_label(impl_item.span, "does not match trait");
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
- err.span_label(trait_span, &format!("item in trait"));
+ err.span_label(trait_span, "item in trait");
}
err.emit()
}
which doesn't match its trait `{}`",
ty_impl_item.name,
impl_trait_ref);
- err.span_label(impl_item.span, &format!("does not match trait"));
+ err.span_label(impl_item.span, "does not match trait");
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
- err.span_label(trait_span, &format!("item in trait"));
+ err.span_label(trait_span, "item in trait");
}
err.emit()
}
missing_items.iter()
.map(|trait_item| trait_item.name.to_string())
.collect::<Vec<_>>().join("`, `"));
- err.span_label(impl_span, &format!("missing `{}` in implementation",
+ err.span_label(impl_span, format!("missing `{}` in implementation",
missing_items.iter()
.map(|trait_item| trait_item.name.to_string())
.collect::<Vec<_>>().join("`, `")));
for trait_item in missing_items {
if let Some(span) = tcx.hir.span_if_local(trait_item.def_id) {
- err.span_label(span, &format!("`{}` from trait", trait_item.name));
+ err.span_label(span, format!("`{}` from trait", trait_item.name));
} else {
err.note(&format!("`{}` from trait: `{}`",
trait_item.name,
Representability::SelfRecursive(spans) => {
let mut err = tcx.recursive_type_with_infinite_size_error(item_def_id);
for span in spans {
- err.span_label(span, &"recursive without indirection");
+ err.span_label(span, "recursive without indirection");
}
err.emit();
return false
let e = fields[0].ty(tcx, substs);
if !fields.iter().all(|f| f.ty(tcx, substs) == e) {
struct_span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous")
- .span_label(sp, &format!("SIMD elements must have the same type"))
+ .span_label(sp, "SIMD elements must have the same type")
.emit();
return;
}
struct_span_err!(
tcx.sess, sp, E0084,
"unsupported representation for zero-variant enum")
- .span_label(sp, &format!("unsupported enum representation"))
+ .span_label(sp, "unsupported enum representation")
.emit();
}
};
struct_span_err!(tcx.sess, span, E0081,
"discriminant value `{}` already exists", disr_vals[i])
- .span_label(i_span, &format!("first use of `{}`", disr_vals[i]))
- .span_label(span , &format!("enum already has `{}`", disr_vals[i]))
+ .span_label(i_span, format!("first use of `{}`", disr_vals[i]))
+ .span_label(span , format!("enum already has `{}`", disr_vals[i]))
.emit();
}
disr_vals.push(discr);
if arg_count == 1 {" was"} else {"s were"}),
error_code);
- err.span_label(sp, &format!("expected {}{} parameter{}",
+ err.span_label(sp, format!("expected {}{} parameter{}",
if variadic {"at least "} else {""},
expected_count,
if expected_count == 1 {""} else {"s"}));
if let Some(def_s) = def_span {
- err.span_label(def_s, &format!("defined here"));
+ err.span_label(def_s, "defined here");
}
err.emit();
}
if let Some(suggested_field_name) =
Self::suggest_field_name(def.struct_variant(), field, vec![]) {
err.span_label(field.span,
- &format!("did you mean `{}`?", suggested_field_name));
+ format!("did you mean `{}`?", suggested_field_name));
} else {
err.span_label(field.span,
- &format!("unknown field"));
+ "unknown field");
};
}
ty::TyRawPtr(..) => {
&field.name,
skip_fields.collect()) {
err.span_label(field.name.span,
- &format!("field does not exist - did you mean `{}`?", field_name));
+ format!("field does not exist - did you mean `{}`?", field_name));
} else {
match ty.sty {
ty::TyAdt(adt, ..) if adt.is_enum() => {
- err.span_label(field.name.span, &format!("`{}::{}` does not have this field",
+ err.span_label(field.name.span, format!("`{}::{}` does not have this field",
ty, variant.name));
}
_ => {
- err.span_label(field.name.span, &format!("`{}` does not have this field", ty));
+ err.span_label(field.name.span, format!("`{}` does not have this field", ty));
}
}
};
"field `{}` specified more than once",
field.name.node);
- err.span_label(field.name.span, &format!("used more than once"));
+ err.span_label(field.name.span, "used more than once");
if let Some(prev_span) = seen_fields.get(&field.name.node) {
- err.span_label(*prev_span, &format!("first use of `{}`", field.name.node));
+ err.span_label(*prev_span, format!("first use of `{}`", field.name.node));
}
err.emit();
remaining_fields_names,
truncated_fields_error,
adt_ty)
- .span_label(span, &format!("missing {}{}",
+ .span_label(span, format!("missing {}{}",
remaining_fields_names,
truncated_fields_error))
.emit();
struct_span_err!(self.tcx.sess, path_span, E0071,
"expected struct, variant or union type, found {}",
ty.sort_string(self.tcx))
- .span_label(path_span, &format!("not a struct"))
+ .span_label(path_span, "not a struct")
.emit();
None
}
"invalid left-hand side expression")
.span_label(
expr.span,
- &format!("left-hand of expression not valid"))
+ "left-hand of expression not valid")
.emit();
}
"too many lifetime parameters provided: \
expected at most {}, found {}",
expected_text, actual_text)
- .span_label(span, &format!("expected {}", expected_text))
+ .span_label(span, format!("expected {}", expected_text))
.emit();
} else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
let expected_text = count_lifetime_params(lifetime_defs.len());
"too few lifetime parameters provided: \
expected {}, found {}",
expected_text, actual_text)
- .span_label(span, &format!("expected {}", expected_text))
+ .span_label(span, format!("expected {}", expected_text))
.emit();
}
"too many type parameters provided: \
expected at most {}, found {}",
expected_text, actual_text)
- .span_label(span, &format!("expected {}", expected_text))
+ .span_label(span, format!("expected {}", expected_text))
.emit();
// To prevent derived errors to accumulate due to extra
"too few type parameters provided: \
expected {}, found {}",
expected_text, actual_text)
- .span_label(span, &format!("expected {}", expected_text))
+ .span_label(span, format!("expected {}", expected_text))
.emit();
}
struct_span_err!(tcx.sess, param.span, E0091,
"type parameter `{}` is unused",
param.name)
- .span_label(param.span, &format!("unused type parameter"))
+ .span_label(param.span, "unused type parameter")
.emit();
}
}
E0067, "invalid left-hand side expression")
.span_label(
lhs_expr.span,
- &format!("invalid expression for left-hand side"))
+ "invalid expression for left-hand side")
.emit();
}
ty
op.node.as_str(),
lhs_ty)
.span_label(lhs_expr.span,
- &format!("cannot use `{}=` on type `{}`",
+ format!("cannot use `{}=` on type `{}`",
op.node.as_str(), lhs_ty))
.emit();
} else {
if let TyRef(_, r_ty) = rhs_ty.sty {
if l_ty.ty.sty == TyStr && r_ty.ty.sty == TyStr {
err.span_label(expr.span,
- &"`+` can't be used to concatenate two `&str` strings");
+ "`+` can't be used to concatenate two `&str` strings");
let codemap = self.tcx.sess.codemap();
let suggestion =
match codemap.span_to_snippet(lhs_expr.span) {
-> DiagnosticBuilder<'tcx> {
let mut err = struct_span_err!(tcx.sess, span, E0392,
"parameter `{}` is never used", param_name);
- err.span_label(span, &format!("unused type parameter"));
+ err.span_label(span, "unused type parameter");
err
}
struct_span_err!(tcx.sess, span, E0194,
"type parameter `{}` shadows another type parameter of the same name",
name)
- .span_label(span, &format!("shadows another type parameter"))
- .span_label(trait_decl_span, &format!("first `{}` declared here", name))
+ .span_label(span, "shadows another type parameter")
+ .span_label(trait_decl_span, format!("first `{}` declared here", name))
.emit();
}
E0120,
"the Drop trait may only be implemented on \
structures")
- .span_label(span, &format!("implementing Drop requires a struct"))
+ .span_label(span, "implementing Drop requires a struct")
.emit();
}
_ => {
"the trait `Copy` may not be implemented for this type")
.span_label(
tcx.def_span(field.did),
- &"this field does not implement `Copy`")
+ "this field does not implement `Copy`")
.emit()
}
Err(CopyImplementationError::NotAnAdt) => {
span,
E0206,
"the trait `Copy` may not be implemented for this type")
- .span_label(span, &format!("type is not a structure or enumeration"))
+ .span_label(span, "type is not a structure or enumeration")
.emit();
}
Err(CopyImplementationError::HasDestructor) => {
E0184,
"the trait `Copy` may not be implemented for this type; the \
type has a destructor")
- .span_label(span, &format!("Copy not allowed on types with destructors"))
+ .span_label(span, "Copy not allowed on types with destructors")
.emit();
}
}
})
.collect::<Vec<_>>()
.join(", ")));
- err.span_label(span, &format!("requires multiple coercions"));
+ err.span_label(span, "requires multiple coercions");
err.emit();
return err_info;
}
ty.span,
E0118,
"no base type found for inherent implementation")
- .span_label(ty.span, &format!("impl requires a base type"))
+ .span_label(ty.span, "impl requires a base type")
.note(&format!("either implement a trait on it or create a newtype \
to wrap it instead"))
.emit();
"cannot define inherent `impl` for a type outside of the crate \
where the type is defined")
.span_label(item.span,
- &format!("impl for type defined outside of crate."))
+ "impl for type defined outside of crate.")
.note("define and implement a trait or new type instead")
.emit();
}
"duplicate definitions with name `{}`",
name)
.span_label(self.tcx.span_of_impl(item1).unwrap(),
- &format!("duplicate definitions for `{}`", name))
+ format!("duplicate definitions for `{}`", name))
.span_label(self.tcx.span_of_impl(item2).unwrap(),
- &format!("other definition for `{}`", name))
+ format!("other definition for `{}`", name))
.emit();
}
}
span,
E0322,
"explicit impls for the `Sized` trait are not permitted")
- .span_label(span, &format!("impl of 'Sized' not allowed"))
+ .span_label(span, "impl of 'Sized' not allowed")
.emit();
return;
}
E0117,
"only traits defined in the current crate can be \
implemented for arbitrary types")
- .span_label(item.span, &format!("impl doesn't use types inside crate"))
+ .span_label(item.span, "impl doesn't use types inside crate")
.note(&format!("the impl does not reference any types defined in \
this crate"))
.note("define and implement a trait or new type instead")
"cannot create default implementations for traits outside \
the crate they're defined in; define a new trait instead")
.span_label(item_trait_ref.path.span,
- &format!("`{}` trait not defined in this crate",
+ format!("`{}` trait not defined in this crate",
self.tcx.hir.node_to_pretty_string(item_trait_ref.ref_id)))
.emit();
return;
match tcx.span_of_impl(overlap.with_impl) {
Ok(span) => {
- err.span_label(span, &format!("first implementation here"));
+ err.span_label(span, "first implementation here");
err.span_label(tcx.span_of_impl(impl_def_id).unwrap(),
- &format!("conflicting implementation{}",
+ format!("conflicting implementation{}",
overlap.self_desc
.map_or(String::new(),
|ty| format!(" for `{}`", ty))));
span,
E0121,
"the type placeholder `_` is not allowed within types on item signatures"
- ).span_label(span, &format!("not allowed in type signatures"))
+ ).span_label(span, "not allowed in type signatures")
.emit();
self.tcx().types.err
}
} else {
struct_span_err!(tcx.sess, variant.span, E0370,
"enum discriminant overflowed")
- .span_label(variant.span, &format!("overflowed on value after {}",
+ .span_label(variant.span, format!("overflowed on value after {}",
prev_discr.unwrap()))
.note(&format!("explicitly set `{} = {}` if that is desired outcome",
variant.node.name, wrapped_discr))
struct_span_err!(tcx.sess, f.span, E0124,
"field `{}` is already declared",
f.name)
- .span_label(f.span, &"field already declared")
- .span_label(prev_span, &format!("`{}` first declared here", f.name))
+ .span_label(f.span, "field already declared")
+ .span_label(prev_span, format!("`{}` first declared here", f.name))
.emit();
} else {
seen_fields.insert(f.name, f.span);
"the {} parameter `{}` is not constrained by the \
impl trait, self type, or predicates",
kind, name)
- .span_label(span, &format!("unconstrained {} parameter", kind))
+ .span_label(span, format!("unconstrained {} parameter", kind))
.emit();
}
"duplicate definitions with name `{}`:",
impl_item.name);
err.span_label(*entry.get(),
- &format!("previous definition of `{}` here",
+ format!("previous definition of `{}` here",
impl_item.name));
- err.span_label(impl_item.span, &format!("duplicate definition"));
+ err.span_label(impl_item.span, "duplicate definition");
err.emit();
}
Vacant(entry) => {
if decl.variadic && abi != Abi::C {
let mut err = struct_span_err!(tcx.sess, span, E0045,
"variadic function must have C calling convention");
- err.span_label(span, &("variadics require C calling conventions").to_string())
+ err.span_label(span, "variadics require C calling conventions")
.emit();
}
}
struct_span_err!(tcx.sess, generics.span, E0131,
"main function is not allowed to have type parameters")
.span_label(generics.span,
- &format!("main cannot have type parameters"))
+ "main cannot have type parameters")
.emit();
return;
}
struct_span_err!(tcx.sess, ps.span, E0132,
"start function is not allowed to have type parameters")
.span_label(ps.span,
- &format!("start function cannot have type parameters"))
+ "start function cannot have type parameters")
.emit();
return;
}
}
}
clean::Vector(ref t) if is_not_debug => {
- primitive_link(f, PrimitiveType::Slice, &format!("["))?;
+ primitive_link(f, PrimitiveType::Slice, "[")?;
fmt::Display::fmt(t, f)?;
- primitive_link(f, PrimitiveType::Slice, &format!("]"))
+ primitive_link(f, PrimitiveType::Slice, "]")
}
clean::Vector(ref t) => write!(f, "[{:?}]", t),
clean::FixedVector(ref t, ref s) if is_not_debug => {
let tmpdir = tmpdir();
let unicode = tmpdir.path();
- let unicode = unicode.join(&format!("test-각丁ー再见"));
+ let unicode = unicode.join("test-각丁ー再见");
check!(fs::create_dir(&unicode));
assert!(unicode.exists());
assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists());
} else {
struct_span_err!(diag, attr.span, E0558,
"export_name attribute has invalid format")
- .span_label(attr.span,
- &format!("did you mean #[export_name=\"*\"]?"))
+ .span_label(attr.span, "did you mean #[export_name=\"*\"]?")
.emit();
None
}
label_sp
};
if self.span.contains(sp) {
- err.span_label(self.span, &label_exp);
+ err.span_label(self.span, label_exp);
} else {
- err.span_label(sp, &label_exp);
- err.span_label(self.span, &"unexpected token");
+ err.span_label(sp, label_exp);
+ err.span_label(self.span, "unexpected token");
}
Err(err)
}
err.span_suggestion(sum_span, "try adding parentheses:", sum_with_parens);
}
TyKind::Ptr(..) | TyKind::BareFn(..) => {
- err.span_label(sum_span, &"perhaps you forgot parentheses?");
+ err.span_label(sum_span, "perhaps you forgot parentheses?");
}
_ => {
- err.span_label(sum_span, &"expected a path");
+ err.span_label(sum_span, "expected a path");
},
}
err.emit();
let fstr = n.as_str();
let mut err = self.diagnostic().struct_span_err(self.prev_span,
&format!("unexpected token: `{}`", n));
- err.span_label(self.prev_span, &"unexpected token");
+ err.span_label(self.prev_span, "unexpected token");
if fstr.chars().all(|x| "0123456789.".contains(x)) {
let float = match fstr.parse::<f64>().ok() {
Some(f) => f,
let span_of_tilde = lo;
let mut err = self.diagnostic().struct_span_err(span_of_tilde,
"`~` can not be used as a unary operator");
- err.span_label(span_of_tilde, &"did you mean `!`?");
+ err.span_label(span_of_tilde, "did you mean `!`?");
err.help("use `!` instead of `~` if you meant to perform bitwise negation");
err.emit();
(span, self.mk_unary(UnOp::Not, e))
sp,
&format!("missing `fn`, `type`, or `const` for {}-item declaration",
item_type));
- err.span_label(sp, &"missing `fn`, `type`, or `const`");
+ err.span_label(sp, "missing `fn`, `type`, or `const`");
err
}