Remove need for &format!(...) or &&"" dances in span_label
calls
This commit is contained in:
parent
70198a0a44
commit
dd87eabd83
@ -43,7 +43,7 @@ impl<'a> CheckAttrVisitor<'a> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ impl<'a> CheckAttrVisitor<'a> {
|
||||
_ => 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 {
|
||||
|
@ -668,9 +668,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -680,12 +680,12 @@ pub trait LintContext<'tcx>: Sized {
|
||||
"{}({}) 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")
|
||||
|
@ -197,7 +197,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||
{
|
||||
match self.description() {
|
||||
ConstEvalErrDescription::Simple(message) => {
|
||||
diag.span_label(self.span, &message);
|
||||
diag.span_label(self.span, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
|
||||
struct_span_err!(
|
||||
self.tcx.sess, span, E0133,
|
||||
"{} requires unsafe function or block", description)
|
||||
.span_label(span, &description)
|
||||
.span_label(span, description)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
|
||||
} 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();
|
||||
}
|
||||
},
|
||||
@ -141,8 +141,8 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
|
||||
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();
|
||||
}
|
||||
},
|
||||
|
@ -92,7 +92,7 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
||||
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;
|
||||
}
|
||||
@ -126,7 +126,7 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
||||
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();
|
||||
|
@ -574,9 +574,9 @@ fn signal_shadowing_problem(sess: &Session, name: ast::Name, orig: Original, sha
|
||||
{} 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();
|
||||
}
|
||||
|
||||
@ -919,7 +919,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
@ -1328,7 +1328,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
} 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 {
|
||||
@ -1438,7 +1438,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -1452,9 +1452,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
}
|
||||
|
@ -484,12 +484,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
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,
|
||||
@ -582,7 +582,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
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()));
|
||||
@ -738,11 +738,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
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
|
||||
@ -765,12 +765,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
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" }));
|
||||
}
|
||||
@ -789,7 +789,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
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)));
|
||||
@ -808,7 +808,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
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 {
|
||||
@ -1043,7 +1043,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
"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();
|
||||
|
@ -181,7 +181,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
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)));
|
||||
|
@ -469,13 +469,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
|
||||
@ -486,13 +486,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
|
||||
@ -503,13 +503,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
|
||||
@ -520,13 +520,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
|
||||
@ -542,17 +542,17 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
@ -562,7 +562,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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));
|
||||
}
|
||||
_ => { }
|
||||
}
|
||||
@ -571,7 +571,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
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));
|
||||
}
|
||||
_ => { }
|
||||
@ -633,11 +633,11 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
@ -662,12 +662,12 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
&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
|
||||
}
|
||||
@ -679,12 +679,12 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
&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
|
||||
@ -857,10 +857,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<Move
|
||||
}
|
||||
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();
|
||||
|
||||
@ -147,7 +147,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
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
|
||||
}
|
||||
@ -160,7 +160,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
"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) => {
|
||||
@ -177,7 +177,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
"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
|
||||
},
|
||||
_ => {
|
||||
@ -198,12 +198,12 @@ fn note_move_destination(mut err: DiagnosticBuilder,
|
||||
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
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
"{} 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;
|
||||
@ -616,12 +616,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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
|
||||
};
|
||||
|
||||
@ -657,9 +657,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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();
|
||||
@ -821,7 +821,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
};
|
||||
@ -914,7 +914,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
db.span_label(
|
||||
let_span,
|
||||
&format!("consider changing this to `mut {}`", snippet)
|
||||
format!("consider changing this to `mut {}`", snippet)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -927,7 +927,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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 "))
|
||||
);
|
||||
}
|
||||
@ -936,7 +936,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -950,7 +950,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -975,10 +975,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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 {} \
|
||||
@ -1029,15 +1029,15 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
};
|
||||
@ -1049,7 +1049,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
(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) => {
|
||||
@ -1057,29 +1057,29 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
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 => {
|
||||
@ -1092,7 +1092,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
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(
|
||||
@ -1162,23 +1162,23 @@ before rustc 1.16, this temporary lived longer - see issue #39283 \
|
||||
}
|
||||
_ => {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||
"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();
|
||||
});
|
||||
}
|
||||
@ -328,7 +328,7 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
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;
|
||||
}
|
||||
@ -355,7 +355,7 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
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!(),
|
||||
@ -369,7 +369,7 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
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,
|
||||
@ -426,7 +426,7 @@ fn check_exhaustive<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
"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();
|
||||
},
|
||||
_ => {
|
||||
@ -453,7 +453,7 @@ fn check_exhaustive<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
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();
|
||||
},
|
||||
}
|
||||
@ -485,18 +485,18 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
|
||||
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();
|
||||
}
|
||||
};
|
||||
@ -546,7 +546,7 @@ impl<'a, 'gcx, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'gcx> {
|
||||
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 => {}
|
||||
@ -557,7 +557,7 @@ impl<'a, 'gcx, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'gcx> {
|
||||
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 => {}
|
||||
@ -588,7 +588,7 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,8 @@ impl Diagnostic {
|
||||
/// 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
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,10 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
/// 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,
|
||||
|
@ -154,7 +154,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||
None => {
|
||||
self.tcx.sess.span_fatal(
|
||||
attr.span,
|
||||
&format!("missing DepNode variant"));
|
||||
"missing DepNode variant");
|
||||
}
|
||||
};
|
||||
self.then_this_would_need.push((attr.span,
|
||||
@ -201,7 +201,7 @@ fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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;
|
||||
@ -219,7 +219,7 @@ fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
} else {
|
||||
tcx.sess.span_err(
|
||||
target_span,
|
||||
&format!("OK"));
|
||||
"OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ fn check_config(tcx: TyCtxt, attr: &Attribute) -> bool {
|
||||
|
||||
tcx.sess.span_fatal(
|
||||
attr.span,
|
||||
&format!("no cfg attribute"));
|
||||
"no cfg attribute");
|
||||
}
|
||||
|
||||
fn expect_associated_value(tcx: TyCtxt, item: &NestedMetaItem) -> ast::Name {
|
||||
|
@ -215,7 +215,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedUnsafe {
|
||||
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));
|
||||
|
@ -88,7 +88,7 @@ fn register_native_lib(sess: &Session,
|
||||
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 => {
|
||||
@ -1029,7 +1029,7 @@ impl<'a> CrateLoader<'a> {
|
||||
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
|
||||
@ -1042,7 +1042,7 @@ impl<'a> CrateLoader<'a> {
|
||||
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")
|
||||
}
|
||||
};
|
||||
|
@ -367,7 +367,7 @@ impl<'a> Context<'a> {
|
||||
&& 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
|
||||
};
|
||||
|
||||
|
@ -242,9 +242,9 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
|
||||
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();
|
||||
@ -291,8 +291,8 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
|
||||
"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.
|
||||
@ -529,7 +529,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
}
|
||||
@ -645,7 +645,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||
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();
|
||||
}
|
||||
@ -713,7 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||
self.mode)
|
||||
.span_label(
|
||||
self.span,
|
||||
&format!("comparing raw pointers in static"))
|
||||
"comparing raw pointers in static")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
@ -724,7 +724,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ impl<'a> AstValidator<'a> {
|
||||
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);
|
||||
@ -80,7 +80,7 @@ impl<'a> AstValidator<'a> {
|
||||
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();
|
||||
}
|
||||
_ => {}
|
||||
@ -272,7 +272,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
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");
|
||||
|
@ -180,7 +180,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
||||
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) => {}
|
||||
|
@ -118,7 +118,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
||||
"`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();
|
||||
}
|
||||
}
|
||||
@ -154,12 +154,12 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -169,7 +169,7 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ impl<'a, 'b: 'a, 'hir: 'b> CheckItemRecursionVisitor<'a, 'b, 'hir> {
|
||||
});
|
||||
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;
|
||||
|
@ -433,7 +433,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -926,7 +926,7 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
|
||||
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,
|
||||
@ -961,7 +961,7 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
|
||||
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 {
|
||||
|
@ -183,7 +183,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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 => {
|
||||
@ -199,8 +199,8 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
"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_) => {
|
||||
@ -210,7 +210,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
"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_) => {
|
||||
@ -220,7 +220,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
"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_) => {
|
||||
@ -230,7 +230,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
"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) => {
|
||||
@ -239,11 +239,11 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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
|
||||
}
|
||||
@ -255,8 +255,8 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
"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) => {
|
||||
@ -265,7 +265,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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) => {
|
||||
@ -274,7 +274,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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) => {
|
||||
@ -283,7 +283,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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 => {
|
||||
@ -313,14 +313,14 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
};
|
||||
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 => {
|
||||
@ -336,7 +336,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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) => {
|
||||
@ -345,9 +345,9 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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
|
||||
}
|
||||
@ -355,7 +355,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
||||
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
|
||||
}
|
||||
@ -2256,13 +2256,13 @@ impl<'a> Resolver<'a> {
|
||||
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;
|
||||
}
|
||||
@ -2294,18 +2294,18 @@ impl<'a> Resolver<'a> {
|
||||
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;
|
||||
@ -2316,7 +2316,7 @@ impl<'a> Resolver<'a> {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -2324,21 +2324,21 @@ impl<'a> Resolver<'a> {
|
||||
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;
|
||||
}
|
||||
@ -2349,12 +2349,12 @@ impl<'a> Resolver<'a> {
|
||||
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;
|
||||
}
|
||||
@ -2364,7 +2364,7 @@ impl<'a> Resolver<'a> {
|
||||
|
||||
// Fallback label.
|
||||
if !levenshtein_worked {
|
||||
err.span_label(base_span, &fallback_label);
|
||||
err.span_label(base_span, fallback_label);
|
||||
}
|
||||
err
|
||||
};
|
||||
@ -3374,9 +3374,9 @@ impl<'a> Resolver<'a> {
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
|
@ -630,7 +630,7 @@ impl<'a> Resolver<'a> {
|
||||
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?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||
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
|
||||
@ -701,7 +701,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||
} 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 {
|
||||
@ -794,7 +794,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||
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();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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, |_, _| {
|
||||
@ -294,7 +294,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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();
|
||||
@ -635,7 +635,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -684,7 +684,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
"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();
|
||||
}
|
||||
@ -730,7 +730,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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();
|
||||
@ -784,7 +784,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
"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);
|
||||
}
|
||||
@ -797,7 +797,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
"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| {
|
||||
@ -806,7 +806,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
.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 {
|
||||
@ -951,7 +951,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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;
|
||||
}
|
||||
@ -959,7 +959,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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;
|
||||
}
|
||||
@ -973,7 +973,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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.
|
||||
@ -1214,7 +1214,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
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
|
||||
@ -1426,7 +1426,7 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
|
||||
"wrong number of type arguments: {} {}, found {}",
|
||||
expected, required, supplied)
|
||||
.span_label(span,
|
||||
&format!("{} {} type argument{}",
|
||||
format!("{} {} type argument{}",
|
||||
expected,
|
||||
required,
|
||||
arguments_plural))
|
||||
@ -1444,7 +1444,7 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
|
||||
expected, supplied)
|
||||
.span_label(
|
||||
span,
|
||||
&format!("{} type argument{}",
|
||||
format!("{} type argument{}",
|
||||
if accepted == 0 { "expected no" } else { &expected },
|
||||
arguments_plural)
|
||||
)
|
||||
@ -1470,7 +1470,7 @@ fn report_lifetime_number_error(tcx: TyCtxt, span: Span, number: usize, expected
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
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();
|
||||
@ -263,7 +263,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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)
|
||||
@ -274,7 +274,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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)
|
||||
}
|
||||
@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
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)
|
||||
@ -379,7 +379,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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
|
||||
}
|
||||
@ -593,7 +593,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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();
|
||||
};
|
||||
|
||||
@ -642,7 +642,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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();
|
||||
@ -683,8 +683,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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
|
||||
}
|
||||
@ -703,7 +703,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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))
|
||||
@ -732,7 +732,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
|
||||
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))
|
||||
|
@ -27,7 +27,7 @@ use rustc::hir;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
||||
},
|
||||
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) {
|
||||
@ -200,7 +200,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||
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);
|
||||
|
@ -402,7 +402,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
"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);
|
||||
}
|
||||
@ -534,9 +534,9 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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);
|
||||
@ -552,9 +552,9 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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);
|
||||
@ -606,7 +606,7 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
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 {
|
||||
@ -617,7 +617,7 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
err.span_label(span,
|
||||
&format!("found {}{}",
|
||||
format!("found {}{}",
|
||||
&if num_impl_m_type_params != 1 {
|
||||
format!("{} type parameters", num_impl_m_type_params)
|
||||
} else {
|
||||
@ -696,7 +696,7 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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 {
|
||||
@ -704,7 +704,7 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}));
|
||||
}
|
||||
err.span_label(impl_span,
|
||||
&format!("expected {}, found {}",
|
||||
format!("expected {}, found {}",
|
||||
&if trait_number_args != 1 {
|
||||
format!("{} parameters", trait_number_args)
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
"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,
|
||||
@ -101,7 +101,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, '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;
|
||||
}
|
||||
@ -305,7 +305,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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;
|
||||
}
|
||||
@ -505,7 +505,7 @@ fn match_intrinsic_type_to_type<'a, 'tcx>(
|
||||
}
|
||||
}
|
||||
_ => simple_error(&format!("`{}`", t),
|
||||
&format!("tuple")),
|
||||
"tuple"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||
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,
|
||||
@ -296,7 +296,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||
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))
|
||||
|
@ -209,9 +209,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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;
|
||||
}
|
||||
@ -272,7 +272,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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();
|
||||
|
@ -1130,7 +1130,7 @@ fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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();
|
||||
}
|
||||
@ -1146,12 +1146,12 @@ fn report_forbidden_specialization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
"`{}` 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));
|
||||
}
|
||||
@ -1226,11 +1226,11 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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()
|
||||
}
|
||||
@ -1262,9 +1262,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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()
|
||||
}
|
||||
@ -1280,9 +1280,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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()
|
||||
}
|
||||
@ -1331,13 +1331,13 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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,
|
||||
@ -1377,7 +1377,7 @@ fn check_representable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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
|
||||
@ -1399,7 +1399,7 @@ pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId
|
||||
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;
|
||||
}
|
||||
@ -1471,7 +1471,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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();
|
||||
}
|
||||
|
||||
@ -1505,8 +1505,8 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
};
|
||||
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);
|
||||
@ -2401,12 +2401,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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();
|
||||
}
|
||||
@ -2938,10 +2938,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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(..) => {
|
||||
@ -3076,15 +3076,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
&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));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -3149,10 +3149,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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();
|
||||
@ -3199,7 +3199,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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();
|
||||
@ -3266,7 +3266,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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
|
||||
}
|
||||
@ -3625,7 +3625,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"invalid left-hand side expression")
|
||||
.span_label(
|
||||
expr.span,
|
||||
&format!("left-hand of expression not valid"))
|
||||
"left-hand of expression not valid")
|
||||
.emit();
|
||||
}
|
||||
|
||||
@ -4517,7 +4517,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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());
|
||||
@ -4526,7 +4526,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
|
||||
@ -4551,7 +4551,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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
|
||||
@ -4565,7 +4565,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
|
||||
@ -4654,7 +4654,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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
|
||||
@ -203,7 +203,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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 {
|
||||
@ -278,7 +278,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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) {
|
||||
|
@ -684,7 +684,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast:
|
||||
-> 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
|
||||
}
|
||||
|
||||
@ -692,7 +692,7 @@ fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: ast::Name) {
|
||||
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();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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();
|
||||
}
|
||||
_ => {
|
||||
@ -130,7 +130,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
"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) => {
|
||||
@ -145,7 +145,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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) => {
|
||||
@ -154,7 +154,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")));
|
||||
err.span_label(span, &format!("requires multiple coercions"));
|
||||
err.span_label(span, "requires multiple coercions");
|
||||
err.emit();
|
||||
return err_info;
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
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();
|
||||
@ -296,7 +296,7 @@ impl<'a, 'tcx> InherentCollect<'a, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
|
@ -56,9 +56,9 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
|
||||
"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();
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d
|
||||
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;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||
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")
|
||||
@ -153,7 +153,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||
"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;
|
||||
|
@ -60,9 +60,9 @@ pub fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
|
||||
|
||||
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))));
|
||||
|
@ -220,7 +220,7 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
|
||||
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
|
||||
}
|
||||
@ -568,7 +568,7 @@ fn convert_enum_variant_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
} 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))
|
||||
@ -604,8 +604,8 @@ fn convert_struct_variant<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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);
|
||||
|
@ -166,7 +166,7 @@ fn report_unused_parameter(tcx: TyCtxt,
|
||||
"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();
|
||||
}
|
||||
|
||||
@ -188,9 +188,9 @@ fn enforce_impl_items_are_distinct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
"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) => {
|
||||
|
@ -143,7 +143,7 @@ fn require_c_abi_if_variadic(tcx: TyCtxt,
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -190,7 +190,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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;
|
||||
}
|
||||
@ -240,7 +240,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
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;
|
||||
}
|
||||
|
@ -687,9 +687,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
||||
}
|
||||
}
|
||||
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 => {
|
||||
|
@ -2412,7 +2412,7 @@ mod tests {
|
||||
|
||||
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());
|
||||
|
@ -511,8 +511,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Symb
|
||||
} 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
|
||||
}
|
||||
|
@ -602,10 +602,10 @@ impl<'a> Parser<'a> {
|
||||
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)
|
||||
}
|
||||
@ -1512,10 +1512,10 @@ impl<'a> Parser<'a> {
|
||||
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();
|
||||
@ -2556,7 +2556,7 @@ impl<'a> Parser<'a> {
|
||||
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,
|
||||
@ -2708,7 +2708,7 @@ impl<'a> Parser<'a> {
|
||||
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))
|
||||
@ -4792,7 +4792,7 @@ impl<'a> Parser<'a> {
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user