Rollup merge of #98668 - TaKO8Ki:avoid-many-&str-to-string-conversions, r=Dylan-DPC
Avoid some `&str` to `String` conversions with `MultiSpan::push_span_label` This patch removes some`&str` to `String` conversions with `MultiSpan::push_span_label`.
This commit is contained in:
commit
d34c4ca9be
17 changed files with 38 additions and 66 deletions
|
@ -645,7 +645,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
err.emit();
|
||||
} else {
|
||||
let mut multispan = MultiSpan::from_span(span);
|
||||
multispan.push_span_label(span_late, note.to_string());
|
||||
multispan.push_span_label(span_late, note);
|
||||
tcx.struct_span_lint_hir(
|
||||
LATE_BOUND_LIFETIME_ARGUMENTS,
|
||||
args.args[0].id(),
|
||||
|
|
|
@ -154,18 +154,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ret_span.push_span_label(
|
||||
expr.span,
|
||||
"this could be implicitly returned but it is a statement, not a \
|
||||
tail expression"
|
||||
.to_owned(),
|
||||
);
|
||||
ret_span.push_span_label(
|
||||
ret,
|
||||
"the `match` arms can conform to this return type".to_owned(),
|
||||
tail expression",
|
||||
);
|
||||
ret_span
|
||||
.push_span_label(ret, "the `match` arms can conform to this return type");
|
||||
ret_span.push_span_label(
|
||||
semi_span,
|
||||
"the `match` is a statement because of this semicolon, consider \
|
||||
removing it"
|
||||
.to_owned(),
|
||||
removing it",
|
||||
);
|
||||
err.span_note(
|
||||
ret_span,
|
||||
|
|
|
@ -1580,8 +1580,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> E
|
|||
} else {
|
||||
let mut multispan: MultiSpan = spans.clone().into();
|
||||
for span in spans {
|
||||
multispan
|
||||
.push_span_label(span, "this returned value is of `!` type".to_string());
|
||||
multispan.push_span_label(span, "this returned value is of `!` type");
|
||||
}
|
||||
err.span_note(multispan, "these returned values have a concrete \"never\" type");
|
||||
}
|
||||
|
|
|
@ -1034,7 +1034,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
sp.push_span_label(
|
||||
rcvr.span,
|
||||
"you probably want to use this value after calling the method...".to_string(),
|
||||
"you probably want to use this value after calling the method...",
|
||||
);
|
||||
err.span_note(
|
||||
sp,
|
||||
|
|
|
@ -1813,7 +1813,7 @@ fn label_fn_like<'tcx>(
|
|||
.flat_map(|id| tcx.hir().body(id).params);
|
||||
|
||||
for param in params {
|
||||
spans.push_span_label(param.span, String::new());
|
||||
spans.push_span_label(param.span, "");
|
||||
}
|
||||
|
||||
let def_kind = tcx.def_kind(def_id);
|
||||
|
|
|
@ -638,7 +638,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let parent_trait_ref = data.parent_trait_pred;
|
||||
let path = parent_trait_ref.print_modifiers_and_trait_path();
|
||||
let tr_self_ty = parent_trait_ref.skip_binder().self_ty();
|
||||
let unsatisfied_msg = "unsatisfied trait bound introduced here".to_string();
|
||||
let unsatisfied_msg = "unsatisfied trait bound introduced here";
|
||||
let derive_msg =
|
||||
"unsatisfied trait bound introduced in this `derive` macro";
|
||||
match self.tcx.hir().get_if_local(impl_def_id) {
|
||||
|
@ -655,7 +655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
{
|
||||
let span = ident.span.ctxt().outer_expn_data().call_site;
|
||||
let mut spans: MultiSpan = span.into();
|
||||
spans.push_span_label(span, derive_msg.to_string());
|
||||
spans.push_span_label(span, derive_msg);
|
||||
let entry = spanned_predicates.entry(spans);
|
||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
{
|
||||
let span = self_ty.span.ctxt().outer_expn_data().call_site;
|
||||
let mut spans: MultiSpan = span.into();
|
||||
spans.push_span_label(span, derive_msg.to_string());
|
||||
spans.push_span_label(span, derive_msg);
|
||||
let entry = spanned_predicates.entry(spans);
|
||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
} else {
|
||||
ident.span.into()
|
||||
};
|
||||
spans.push_span_label(ident.span, "in this trait".to_string());
|
||||
spans.push_span_label(ident.span, "in this trait");
|
||||
let entry = spanned_predicates.entry(spans);
|
||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||
}
|
||||
|
@ -747,9 +747,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
spans.into()
|
||||
};
|
||||
if let Some(trait_ref) = of_trait {
|
||||
spans.push_span_label(trait_ref.path.span, String::new());
|
||||
spans.push_span_label(trait_ref.path.span, "");
|
||||
}
|
||||
spans.push_span_label(self_ty.span, String::new());
|
||||
spans.push_span_label(self_ty.span, "");
|
||||
|
||||
let entry = spanned_predicates.entry(spans);
|
||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||
|
|
|
@ -836,7 +836,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
.take(bound)
|
||||
.map(|param| {
|
||||
let span = self.tcx.def_span(param.def_id);
|
||||
spans.push_span_label(span, String::new());
|
||||
spans.push_span_label(span, "");
|
||||
param
|
||||
})
|
||||
.map(|param| format!("`{}`", param.name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue