avoid &str
/Symbol
to String
conversions
This commit is contained in:
parent
bf1a5e72f4
commit
051e98b7bf
6 changed files with 19 additions and 14 deletions
|
@ -850,13 +850,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
debug!("trait spans found: {:?}", traits);
|
debug!("trait spans found: {:?}", traits);
|
||||||
for span in &traits {
|
for span in &traits {
|
||||||
let mut multi_span: MultiSpan = vec![*span].into();
|
let mut multi_span: MultiSpan = vec![*span].into();
|
||||||
multi_span.push_span_label(
|
multi_span
|
||||||
*span,
|
.push_span_label(*span, "this has an implicit `'static` lifetime requirement");
|
||||||
"this has an implicit `'static` lifetime requirement".to_string(),
|
|
||||||
);
|
|
||||||
multi_span.push_span_label(
|
multi_span.push_span_label(
|
||||||
ident.span,
|
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_note(multi_span, "the used `impl` has a `'static` requirement");
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
|
|
|
@ -951,7 +951,7 @@ fn adt_defined_here<'p, 'tcx>(
|
||||||
let mut span: MultiSpan =
|
let mut span: MultiSpan =
|
||||||
if spans.is_empty() { def_span.into() } else { spans.clone().into() };
|
if spans.is_empty() { def_span.into() } else { spans.clone().into() };
|
||||||
|
|
||||||
span.push_span_label(def_span, String::new());
|
span.push_span_label(def_span, "");
|
||||||
for pat in spans {
|
for pat in spans {
|
||||||
span.push_span_label(pat, "not covered");
|
span.push_span_label(pat, "not covered");
|
||||||
}
|
}
|
||||||
|
|
|
@ -565,8 +565,7 @@ impl<'a> Resolver<'a> {
|
||||||
} else if let Some(sp) = sm.generate_fn_name_span(span) {
|
} else if let Some(sp) = sm.generate_fn_name_span(span) {
|
||||||
err.span_label(
|
err.span_label(
|
||||||
sp,
|
sp,
|
||||||
"try adding a local generic parameter in this method instead"
|
"try adding a local generic parameter in this method instead",
|
||||||
.to_string(),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.help("try using a local generic parameter instead");
|
err.help("try using a local generic parameter instead");
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_middle::ty;
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::lev_distance::find_best_match_for_name;
|
use rustc_span::lev_distance::find_best_match_for_name;
|
||||||
use rustc_span::symbol::{sym, Ident};
|
use rustc_span::symbol::{sym, Ident};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, Symbol, DUMMY_SP};
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
/// the type parameter's name as a placeholder.
|
/// the type parameter's name as a placeholder.
|
||||||
pub(crate) fn complain_about_missing_type_params(
|
pub(crate) fn complain_about_missing_type_params(
|
||||||
&self,
|
&self,
|
||||||
missing_type_params: Vec<String>,
|
missing_type_params: Vec<Symbol>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
span: Span,
|
span: Span,
|
||||||
empty_generic_args: bool,
|
empty_generic_args: bool,
|
||||||
|
|
|
@ -382,7 +382,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
generic_args: &'a GenericArgs<'a>,
|
generic_args: &'a GenericArgs<'a>,
|
||||||
span: Span,
|
span: Span,
|
||||||
missing_type_params: Vec<String>,
|
missing_type_params: Vec<Symbol>,
|
||||||
inferred_params: Vec<Span>,
|
inferred_params: Vec<Span>,
|
||||||
infer_args: bool,
|
infer_args: bool,
|
||||||
is_object: bool,
|
is_object: bool,
|
||||||
|
@ -514,7 +514,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
// defaults. This will lead to an ICE if we are not
|
// defaults. This will lead to an ICE if we are not
|
||||||
// careful!
|
// careful!
|
||||||
if self.default_needs_object_self(param) {
|
if self.default_needs_object_self(param) {
|
||||||
self.missing_type_params.push(param.name.to_string());
|
self.missing_type_params.push(param.name);
|
||||||
tcx.ty_error().into()
|
tcx.ty_error().into()
|
||||||
} else {
|
} else {
|
||||||
// This is a default type parameter.
|
// This is a default type parameter.
|
||||||
|
|
|
@ -244,7 +244,7 @@ pub struct UnconstrainedOpaqueType {
|
||||||
pub struct MissingTypeParams {
|
pub struct MissingTypeParams {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub def_span: Span,
|
pub def_span: Span,
|
||||||
pub missing_type_params: Vec<String>,
|
pub missing_type_params: Vec<Symbol>,
|
||||||
pub empty_generic_args: bool,
|
pub empty_generic_args: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,15 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
self.span,
|
self.span,
|
||||||
rustc_errors::fluent::typeck::suggestion,
|
rustc_errors::fluent::typeck::suggestion,
|
||||||
format!("{}<{}>", snippet, self.missing_type_params.join(", ")),
|
format!(
|
||||||
|
"{}<{}>",
|
||||||
|
snippet,
|
||||||
|
self.missing_type_params
|
||||||
|
.iter()
|
||||||
|
.map(|n| n.to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(", ")
|
||||||
|
),
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
suggested = true;
|
suggested = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue