avoid many &str
to String
conversions with MultiSpan::push_span_label
This commit is contained in:
parent
0e1a6fb463
commit
6212e6b339
17 changed files with 38 additions and 66 deletions
|
@ -194,10 +194,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
if !v.0.is_empty() {
|
||||
span = v.0.clone().into();
|
||||
for sp in v.0 {
|
||||
span.push_span_label(
|
||||
sp,
|
||||
"`'static` requirement introduced here".to_string(),
|
||||
);
|
||||
span.push_span_label(sp, "`'static` requirement introduced here");
|
||||
}
|
||||
add_label = false;
|
||||
}
|
||||
|
@ -205,13 +202,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
if add_label {
|
||||
span.push_span_label(
|
||||
fn_decl.output.span(),
|
||||
"requirement introduced by this return type".to_string(),
|
||||
"requirement introduced by this return type",
|
||||
);
|
||||
}
|
||||
span.push_span_label(
|
||||
cause.span,
|
||||
"because of this returned expression".to_string(),
|
||||
);
|
||||
span.push_span_label(cause.span, "because of this returned expression");
|
||||
err.span_note(
|
||||
span,
|
||||
"`'static` lifetime requirement introduced by the return type",
|
||||
|
@ -523,13 +517,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
hir_v.visit_ty(&self_ty);
|
||||
for span in &traits {
|
||||
let mut multi_span: MultiSpan = vec![*span].into();
|
||||
multi_span.push_span_label(
|
||||
*span,
|
||||
"this has an implicit `'static` lifetime requirement".to_string(),
|
||||
);
|
||||
multi_span
|
||||
.push_span_label(*span, "this has an implicit `'static` lifetime requirement");
|
||||
multi_span.push_span_label(
|
||||
ident.span,
|
||||
"calling this method introduces the `impl`'s 'static` requirement".to_string(),
|
||||
"calling this method introduces the `impl`'s 'static` requirement",
|
||||
);
|
||||
err.span_note(multi_span, "the used `impl` has a `'static` requirement");
|
||||
err.span_suggestion_verbose(
|
||||
|
|
|
@ -128,10 +128,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
}
|
||||
let mut type_param_span: MultiSpan = visitor.types.to_vec().into();
|
||||
for &span in &visitor.types {
|
||||
type_param_span.push_span_label(
|
||||
span,
|
||||
"consider borrowing this type parameter in the trait".to_string(),
|
||||
);
|
||||
type_param_span
|
||||
.push_span_label(span, "consider borrowing this type parameter in the trait");
|
||||
}
|
||||
|
||||
err.note(&format!("expected `{}`\n found `{}`", expected, found));
|
||||
|
|
|
@ -85,8 +85,7 @@ pub fn report_object_safety_error<'tcx>(
|
|||
let has_multi_span = !multi_span.is_empty();
|
||||
let mut note_span = MultiSpan::from_spans(multi_span.clone());
|
||||
if let (Some(trait_span), true) = (trait_span, has_multi_span) {
|
||||
note_span
|
||||
.push_span_label(trait_span, "this trait cannot be made into an object...".to_string());
|
||||
note_span.push_span_label(trait_span, "this trait cannot be made into an object...");
|
||||
}
|
||||
for (span, msg) in iter::zip(multi_span, messages) {
|
||||
note_span.push_span_label(span, msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue