avoid some &str
to String
conversions
This commit is contained in:
parent
fac8fa5672
commit
bda83e6543
13 changed files with 23 additions and 34 deletions
|
@ -263,7 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
} else if let ExprKind::Block(block, _) = &then_expr.kind
|
||||
&& let Some(expr) = &block.expr
|
||||
{
|
||||
err.span_label(expr.span, "found here".to_string());
|
||||
err.span_label(expr.span, "found here");
|
||||
}
|
||||
err.note("`if` expressions without `else` evaluate to `()`");
|
||||
err.help("consider adding an `else` block that evaluates to the expected type");
|
||||
|
|
|
@ -317,9 +317,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.tcx
|
||||
.is_diagnostic_item(sym::Result, expected_adt.did())
|
||||
{
|
||||
vec!["Ok(())".to_string()]
|
||||
vec!["Ok(())"]
|
||||
} else if self.tcx.is_diagnostic_item(sym::Option, expected_adt.did()) {
|
||||
vec!["None".to_string(), "Some(())".to_string()]
|
||||
vec!["None", "Some(())"]
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -565,9 +565,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.is_ok()
|
||||
{
|
||||
let (variable_snippet, applicability) = if !fn_sig.inputs().is_empty() {
|
||||
("( /* arguments */ )".to_string(), Applicability::HasPlaceholders)
|
||||
("( /* arguments */ )", Applicability::HasPlaceholders)
|
||||
} else {
|
||||
("()".to_string(), Applicability::MaybeIncorrect)
|
||||
("()", Applicability::MaybeIncorrect)
|
||||
};
|
||||
|
||||
err.span_suggestion_verbose(
|
||||
|
|
|
@ -86,7 +86,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
|||
|
||||
let errors = fulfill.select_all_or_error(&infcx);
|
||||
if !errors.is_empty() {
|
||||
tracing::debug!("Wf-check got errors for {:?}: {:?}", ty, errors);
|
||||
debug!("Wf-check got errors for {:?}: {:?}", ty, errors);
|
||||
for error in errors {
|
||||
if error.obligation.predicate == self.predicate {
|
||||
// Save the cause from the greatest depth - this corresponds
|
||||
|
|
|
@ -252,7 +252,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
let mut diag =
|
||||
struct_span_err!(tcx.sess, generics_param_span.unwrap_or(main_span), E0131, "{}", msg);
|
||||
if let Some(generics_param_span) = generics_param_span {
|
||||
let label = "`main` cannot have generic parameters".to_string();
|
||||
let label = "`main` cannot have generic parameters";
|
||||
diag.span_label(generics_param_span, label);
|
||||
}
|
||||
diag.emit();
|
||||
|
@ -307,8 +307,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span);
|
||||
if !return_ty.bound_vars().is_empty() {
|
||||
let msg = "`main` function return type is not allowed to have generic \
|
||||
parameters"
|
||||
.to_owned();
|
||||
parameters";
|
||||
struct_span_err!(tcx.sess, return_ty_span, E0131, "{}", msg).emit();
|
||||
error = true;
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn kind(&self) -> String {
|
||||
if self.missing_lifetimes() { "lifetime".to_string() } else { "generic".to_string() }
|
||||
fn kind(&self) -> &str {
|
||||
if self.missing_lifetimes() { "lifetime" } else { "generic" }
|
||||
}
|
||||
|
||||
fn num_provided_args(&self) -> usize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue