From: Oliver Schneider Date: Thu, 4 May 2017 12:17:23 +0000 (+0200) Subject: Remove need for &format!(...) or &&"" dances in `span_label` calls X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=dd87eabd83296baa4c2214d2cf3aeef24f753ba7;p=rust.git Remove need for &format!(...) or &&"" dances in `span_label` calls --- diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index bf292ccb8d8..f553c03d09b 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -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 @@ fn check_repr(&self, attr: &ast::Attribute, target: Target) { _ => 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 { diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 8f2bdd4e85c..4c27bade0f7 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -668,9 +668,9 @@ pub fn note_type_err(&self, } } - 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); diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 6947e7c3f40..6f3e84247f7 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -680,12 +680,12 @@ fn with_lint_attrs(&mut self, "{}({}) 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") diff --git a/src/librustc/middle/const_val.rs b/src/librustc/middle/const_val.rs index 74026abe64d..3bbaf5c9299 100644 --- a/src/librustc/middle/const_val.rs +++ b/src/librustc/middle/const_val.rs @@ -197,7 +197,7 @@ pub fn note(&self, { match self.description() { ConstEvalErrDescription::Simple(message) => { - diag.span_label(self.span, &message); + diag.span_label(self.span, message); } } diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index d2b8ed8c297..e03948db368 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -74,7 +74,7 @@ fn require_unsafe_ext(&mut self, node_id: ast::NodeId, span: Span, struct_span_err!( self.tcx.sess, span, E0133, "{} requires unsafe function or block", description) - .span_label(span, &description) + .span_label(span, description) .emit(); } } diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 8da7560387f..24748b6cf65 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -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(); } }, diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 435dd05358d..a759a9061f8 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -92,7 +92,7 @@ fn check_transmute(&self, span: Span, from: Ty<'gcx>, to: Ty<'gcx>) { 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 @@ fn check_transmute(&self, span: Span, from: Ty<'gcx>, to: Ty<'gcx>) { 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(); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index a8ba708cc2c..67b8dfb2d8e 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -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 @@ fn resolve_lifetime_ref(&mut self, lifetime_ref: &hir::Lifetime) { } 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 @@ fn resolve_elided_lifetimes(&mut self, lifetime_refs: &[hir::Lifetime]) { } 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 @@ fn check_lifetime_defs(&mut self, old_scope: ScopeRef, lifetimes: &[hir::Lifetim 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 @@ fn check_lifetime_defs(&mut self, old_scope: ScopeRef, lifetimes: &[hir::Lifetim "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(); } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index e846d74febf..152e3353994 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -484,12 +484,12 @@ pub fn report_extra_impl_obligation(&self, 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 @@ pub fn report_selection_error(&self, } 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 @@ fn report_type_argument_mismatch(&self, 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 @@ fn report_arg_count_mismatch(&self, 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 @@ pub fn recursive_type_with_infinite_size_error(self, 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 @@ pub fn report_object_safety_error(self, 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 @@ pub fn need_type_info(&self, body_id: hir::BodyId, span: Span, ty: Ty<'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(); diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index a737e7caa3e..82a4c1e1e62 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -181,7 +181,7 @@ pub fn report_cycle(self, CycleError { span, cycle }: CycleError) { 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))); diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 1c5a6c3985c..adabbe11f5e 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -469,13 +469,13 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, nl, new_loan_msg); err.span_label( old_loan.span, - &format!("first mutable borrow occurs here{}", old_loan_msg)); + format!("first mutable borrow occurs here{}", old_loan_msg)); err.span_label( new_loan.span, - &format!("second mutable borrow occurs here{}", new_loan_msg)); + format!("second mutable borrow occurs here{}", new_loan_msg)); err.span_label( previous_end_span, - &format!("first borrow ends here")); + "first borrow ends here"); err } @@ -486,13 +486,13 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, 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 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, 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 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, 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 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, 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 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, 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 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self, 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 @@ fn check_for_copy_of_frozen_path(&self, "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 @@ fn check_for_move_of_borrowed_path(&self, &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 @@ fn check_for_move_of_borrowed_path(&self, &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 @@ pub fn report_illegal_mutation(&self, "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(); } diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index b7ce9d98233..1ee6d565d0d 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -94,7 +94,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec(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 } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index f8073455bd0..7eb73a87532 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -546,7 +546,7 @@ pub fn report_use_of_moved_value(&self, "{} 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 @@ pub fn report_use_of_moved_value(&self, 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 @@ pub fn report_reassigned_immutable_variable(&self, 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 @@ pub fn report_aliasability_violation(&self, 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 @@ fn note_immutability_blame(&self, } db.span_label( let_span, - &format!("consider changing this to `mut {}`", snippet) + format!("consider changing this to `mut {}`", snippet) ); } } @@ -927,7 +927,7 @@ fn note_immutability_blame(&self, 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 @@ fn note_immutability_blame(&self, 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 @@ fn note_immutability_blame(&self, 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 @@ fn report_out_of_scope_escaping_closure_capture(&self, 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 @@ fn note_and_explain_bckerr(&self, db: &mut DiagnosticBuilder, err: BckError<'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 @@ fn note_and_explain_bckerr(&self, db: &mut DiagnosticBuilder, err: BckError<'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 @@ fn note_and_explain_bckerr(&self, db: &mut DiagnosticBuilder, err: BckError<'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 @@ fn note_and_explain_bckerr(&self, db: &mut DiagnosticBuilder, err: BckError<'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 @@ fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder, err: &BckErro } _ => { 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"); } } } diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 6ec5f38aa5b..cd31290eb55 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -258,7 +258,7 @@ fn check_irrefutable(&self, pat: &Pat, is_fn_arg: bool) { "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 @@ fn borrow(&mut self, 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 @@ fn mutate(&mut self, _: ast::NodeId, span: Span, _: cmt, mode: MutateMode) { 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 @@ fn visit_pat(&mut self, pat: &Pat) { 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(); } diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 38fa35ecb12..0822f713499 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -114,9 +114,8 @@ pub fn is_fatal(&self) -> bool { /// 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>(&mut self, span: Span, label: T) -> &mut Self { + self.span.push_span_label(span, label.into()); self } diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 9dfd47b8464..a9c2bbeba2a 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -112,8 +112,10 @@ pub fn emit(&mut self) { /// all, and you just supplied a `Span` to create the diagnostic, /// then the snippet will just include that `Span`, which is /// called the primary span. - forward!(pub fn span_label(&mut self, span: Span, label: &fmt::Display) - -> &mut Self); + pub fn span_label>(&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, diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 7905128bb6e..39fe2188f68 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -154,7 +154,7 @@ fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { 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"); } } } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index b73b3e161f9..5facfe36efd 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -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 { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 86bf209ccf8..93ff609a280 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -215,7 +215,7 @@ fn is_enclosed(cx: &LateContext, id: ast::NodeId) -> Option<(String, ast::NodeId 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)); diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 966e814e337..325511c9787 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -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 @@ fn process_foreign_mod(&mut self, i: &ast::Item, fm: &ast::ForeignMod, 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 @@ fn process_foreign_mod(&mut self, i: &ast::Item, fm: &ast::ForeignMod, 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") } }; diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index e8bc8b01652..84bb82de370 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -367,7 +367,7 @@ pub fn report_errs(&mut self) -> ! { && 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 }; diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 4b1c82f383f..0d592b4d72b 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -242,9 +242,9 @@ fn deny_drop(&self) { 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 @@ fn try_consume(&mut self) -> bool { "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 @@ fn visit_lvalue(&mut self, "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 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { 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 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { self.mode) .span_label( self.span, - &format!("comparing raw pointers in static")) + "comparing raw pointers in static") .emit(); } } @@ -724,7 +724,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { 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(); } } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 8c45a666945..d7fee7f3110 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -55,7 +55,7 @@ fn invalid_visibility(&self, vis: &Visibility, span: Span, note: Option<&str>) { 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 @@ fn check_trait_fn_not_const(&self, constness: Spanned) { 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 @@ fn visit_foreign_item(&mut self, fi: &'a ForeignItem) { 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"); diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 608238dfe37..a0998b1bd1b 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -180,7 +180,7 @@ fn visit_pat(&mut self, p: &'tcx hir::Pat) { 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) => {} diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 2ea235af103..21a4c007fb1 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -118,7 +118,7 @@ fn visit_expr(&mut self, e: &'hir hir::Expr) { "`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 @@ fn require_loop(&self, name: &str, span: Span) { 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 @@ fn emit_unlabled_cf_in_while_condition(&mut self, span: Span, cf_type: &str) { 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(); } } diff --git a/src/librustc_passes/static_recursion.rs b/src/librustc_passes/static_recursion.rs index d0bf49b7b33..8d455adc23c 100644 --- a/src/librustc_passes/static_recursion.rs +++ b/src/librustc_passes/static_recursion.rs @@ -138,7 +138,7 @@ fn with_item_id_pushed(&mut self, id: ast::NodeId, f: F, span: Span) }); 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; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 82c91727293..f63102433c1 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -433,7 +433,7 @@ fn check_field(&mut self, span: Span, def: &'tcx ty::AdtDef, field: &'tcx ty::Fi 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 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { 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 @@ fn visit_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) -> bool { 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 { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a4e9a8be49f..ac556270886 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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::>(); 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 @@ fn smart_resolve_path_fragment(&mut self, 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 @@ fn smart_resolve_path_fragment(&mut self, 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 @@ fn smart_resolve_path_fragment(&mut self, // 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 @@ fn smart_resolve_path_fragment(&mut self, 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 @@ fn smart_resolve_path_fragment(&mut self, 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 @@ fn smart_resolve_path_fragment(&mut self, // Fallback label. if !levenshtein_worked { - err.span_label(base_span, &fallback_label); + err.span_label(base_span, fallback_label); } err }; @@ -3374,9 +3374,9 @@ fn report_conflict(&mut self, }, }; - 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); diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 030e3936de9..106f421f39e 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -630,7 +630,7 @@ fn suggest_macro_name(&mut self, name: &str, kind: MacroKind, 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?"); } } } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 43654c8ce6f..804e1ea740f 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -539,7 +539,7 @@ fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> bool { 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 @@ fn finalize_import(&mut self, directive: &'b ImportDirective<'b>) -> Option) { 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(); } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 33b0aa3dbff..adcb3d682ca 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -163,7 +163,7 @@ pub fn ast_path_substs_for_ty(&self, 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 @@ fn create_substs_for_ast_path(&self, 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 @@ fn conv_object_ty_poly_trait_ref(&self, 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 @@ fn conv_object_ty_poly_trait_ref(&self, "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 @@ fn report_ambiguous_associated_type(&self, 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 @@ fn one_bound_for_assoc_type(&self, "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 @@ fn one_bound_for_assoc_type(&self, "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 @@ fn one_bound_for_assoc_type(&self, .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 @@ pub fn prohibit_type_params(&self, segments: &[hir::PathSegment]) { 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 @@ pub fn prohibit_type_params(&self, segments: &[hir::PathSegment]) { 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 @@ pub fn prohibit_type_params(&self, segments: &[hir::PathSegment]) { 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 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { 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(); } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index ac10dfd36e2..bbe34f37950 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -97,7 +97,7 @@ pub fn check_pat_arg(&self, pat: &'gcx hir::Pat, expected: Ty<'tcx>, is_arg: boo 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 @@ pub fn check_pat_arg(&self, pat: &'gcx hir::Pat, expected: Ty<'tcx>, is_arg: boo 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 @@ pub fn check_pat_arg(&self, pat: &'gcx hir::Pat, expected: Ty<'tcx>, is_arg: boo "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 @@ pub fn check_pat_arg(&self, pat: &'gcx hir::Pat, expected: Ty<'tcx>, is_arg: boo } 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 @@ pub fn check_dereferencable(&self, span: Span, expected: Ty<'tcx>, inner: &hir:: 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 @@ fn check_pat_tuple_struct(&self, 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 @@ fn check_pat_tuple_struct(&self, "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 @@ fn check_struct_pat_fields(&self, 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 @@ fn check_struct_pat_fields(&self, 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 @@ fn check_struct_pat_fields(&self, 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(); } } diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index c9584f1d9e1..f03451c04ed 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -62,7 +62,7 @@ fn next(&mut self) -> Option { 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)) diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 7a49309e005..dde5f598a68 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -27,7 +27,7 @@ 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(); } } diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 32b363ed755..72ce7d3b5ed 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -155,7 +155,7 @@ fn report_cast_error(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, e: CastError) { }, 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 @@ fn report_cast_error(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, e: CastError) { } 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(); } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index b0b57aee5b2..c228fc6b24a 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1144,7 +1144,7 @@ fn coerce_inner<'a>(&mut self, 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); diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 9ed5528e867..0579bb15fd6 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -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 @@ trait `{}` has {}", 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 @@ trait `{}` has {}", })); } err.span_label(impl_span, - &format!("expected {}, found {}", + format!("expected {}, found {}", &if trait_number_args != 1 { format!("{} parameters", trait_number_args) } else { diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 2a97bc1d98f..60067e6a6ec 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -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"), } } } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index aad14bc975d..fdde4e9fef4 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -285,7 +285,7 @@ fn instantiate_method_substs(&mut self, 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 @@ fn instantiate_method_substs(&mut self, 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)) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 4b975d7b324..c7ec379b0de 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -209,9 +209,9 @@ pub fn report_method_error(&self, 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 @@ macro_rules! report_function { 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(); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 2e29aeeb022..127ffc60cf4 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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::>().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::>().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 @@ fn parameter_count_error<'tcx>(sess: &Session, sp: Span, expected_count: usize, 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 @@ fn check_field(&self, 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 @@ fn report_unknown_field(&self, &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 @@ fn check_expr_struct_fields(&self, "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 @@ fn check_expr_struct_fields(&self, 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 @@ pub fn check_struct_path(&self, 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 @@ fn check_expr_kind(&self, "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 @@ fn check_path_parameter_count(&self, "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 @@ fn check_path_parameter_count(&self, "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 @@ fn check_path_parameter_count(&self, "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 @@ fn check_path_parameter_count(&self, "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(); } } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index d3d65ce4a62..59cb61d9b97 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -50,7 +50,7 @@ pub fn check_binop_assign(&self, 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 @@ fn check_overloaded_binop(&self, 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 @@ fn check_str_addition(&self, 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) { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 1887eaef360..93529aecac0 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -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(); } diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 49785d8850f..743bfbb44ab 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -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::>() .join(", "))); - err.span_label(span, &format!("requires multiple coercions")); + err.span_label(span, "requires multiple coercions"); err.emit(); return err_info; } diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index 238952865c7..f7ebc210442 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -259,7 +259,7 @@ fn visit_item(&mut self, item: &hir::Item) { 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 @@ fn check_def_id(&mut self, item: &hir::Item, def_id: DefId) { "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(); } diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 34aec8ef1ac..2751e1ff38a 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -56,9 +56,9 @@ enum Namespace { "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(); } } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 56ae9d54575..8b9dc20315d 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -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; } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 8ded3003c78..097720adad4 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -48,7 +48,7 @@ fn visit_item(&mut self, item: &hir::Item) { 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 @@ fn visit_item(&mut self, item: &hir::Item) { "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; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 383a9e0e695..f479dc2e6ab 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -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)))); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index f44f74830cb..ec200241ee6 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -220,7 +220,7 @@ fn ty_infer(&self, span: Span) -> Ty<'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); diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 1c44572fbb4..6b4f08d3d4c 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -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) => { diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index c1456e79782..84de4ff2b7b 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -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; } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 0f47265a1aa..5db82e23bbf 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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 => { diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 6b1267d89b6..528d903b8b0 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -2412,7 +2412,7 @@ fn unicode_path_exists() { 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()); diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 82492d97627..0980b73e80c 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -511,8 +511,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option String { 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 @@ fn maybe_recover_from_bad_type_plus(&mut self, allow_plus: bool, ty: &Ty) -> PRe 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 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P, lo: Span) -> PResult<'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::().ok() { Some(f) => f, @@ -2708,7 +2708,7 @@ pub fn parse_prefix_expr(&mut self, 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 @@ fn missing_assoc_item_kind_err(&mut self, item_type: &str, prev_span: Span) 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 }