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
|
@ -2561,7 +2561,7 @@ fn show_candidates(
|
|||
let span = source_span[local_def_id];
|
||||
let span = session.source_map().guess_head_span(span);
|
||||
let mut multi_span = MultiSpan::from_span(span);
|
||||
multi_span.push_span_label(span, "not accessible".to_string());
|
||||
multi_span.push_span_label(span, "not accessible");
|
||||
err.span_note(multi_span, &msg);
|
||||
} else {
|
||||
err.note(&msg);
|
||||
|
|
|
@ -601,10 +601,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
};
|
||||
multi_span.push_span_label(sp, msg);
|
||||
}
|
||||
multi_span.push_span_label(
|
||||
base_error.span,
|
||||
"expected this type to be a trait...".to_string(),
|
||||
);
|
||||
multi_span
|
||||
.push_span_label(base_error.span, "expected this type to be a trait...");
|
||||
err.span_help(
|
||||
multi_span,
|
||||
"`+` is used to constrain a \"trait object\" type with lifetimes or \
|
||||
|
@ -1227,17 +1225,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
let mut m: MultiSpan = non_visible_spans.clone().into();
|
||||
non_visible_spans
|
||||
.into_iter()
|
||||
.for_each(|s| m.push_span_label(s, "private field".to_string()));
|
||||
.for_each(|s| m.push_span_label(s, "private field"));
|
||||
err.span_note(m, "constructor is not visible here due to private fields");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
err.span_label(
|
||||
span,
|
||||
"constructor is not visible here due to private fields".to_string(),
|
||||
);
|
||||
err.span_label(span, "constructor is not visible here due to private fields");
|
||||
}
|
||||
(
|
||||
Res::Def(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue