inline format!() args up to and including rustc_codegen_llvm
This commit is contained in:
parent
2e0136a131
commit
3ce90b1649
72 changed files with 411 additions and 481 deletions
|
@ -1001,7 +1001,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
allow_shadowing: bool,
|
||||
) {
|
||||
if self.r.macro_use_prelude.insert(name, binding).is_some() && !allow_shadowing {
|
||||
let msg = format!("`{}` is already in scope", name);
|
||||
let msg = format!("`{name}` is already in scope");
|
||||
let note =
|
||||
"macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)";
|
||||
self.r.tcx.sess.struct_span_err(span, msg).note(note).emit();
|
||||
|
|
|
@ -362,7 +362,7 @@ impl Resolver<'_, '_> {
|
|||
let mut span_snippets = spans
|
||||
.iter()
|
||||
.filter_map(|s| match tcx.sess.source_map().span_to_snippet(*s) {
|
||||
Ok(s) => Some(format!("`{}`", s)),
|
||||
Ok(s) => Some(format!("`{s}`")),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<String>>();
|
||||
|
|
|
@ -243,7 +243,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
(TypeNS, _) => "type",
|
||||
};
|
||||
|
||||
let msg = format!("the name `{}` is defined multiple times", name);
|
||||
let msg = format!("the name `{name}` is defined multiple times");
|
||||
|
||||
let mut err = match (old_binding.is_extern_crate(), new_binding.is_extern_crate()) {
|
||||
(true, true) => struct_span_err!(self.tcx.sess, span, E0259, "{}", msg),
|
||||
|
@ -265,11 +265,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
container
|
||||
));
|
||||
|
||||
err.span_label(span, format!("`{}` re{} here", name, new_participle));
|
||||
err.span_label(span, format!("`{name}` re{new_participle} here"));
|
||||
if !old_binding.span.is_dummy() && old_binding.span != span {
|
||||
err.span_label(
|
||||
self.tcx.sess.source_map().guess_head_span(old_binding.span),
|
||||
format!("previous {} of the {} `{}` here", old_noun, old_kind, name),
|
||||
format!("previous {old_noun} of the {old_kind} `{name}` here"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -358,15 +358,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
binding_span: Span,
|
||||
) {
|
||||
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
|
||||
format!("Other{}", name)
|
||||
format!("Other{name}")
|
||||
} else {
|
||||
format!("other_{}", name)
|
||||
format!("other_{name}")
|
||||
};
|
||||
|
||||
let mut suggestion = None;
|
||||
match import.kind {
|
||||
ImportKind::Single { type_ns_only: true, .. } => {
|
||||
suggestion = Some(format!("self as {}", suggested_name))
|
||||
suggestion = Some(format!("self as {suggested_name}"))
|
||||
}
|
||||
ImportKind::Single { source, .. } => {
|
||||
if let Some(pos) =
|
||||
|
@ -602,11 +602,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let sugg_msg = "try using a local generic parameter instead";
|
||||
let name = self.tcx.item_name(def_id);
|
||||
let (span, snippet) = if span.is_empty() {
|
||||
let snippet = format!("<{}>", name);
|
||||
let snippet = format!("<{name}>");
|
||||
(span, snippet)
|
||||
} else {
|
||||
let span = sm.span_through_char(span, '<').shrink_to_hi();
|
||||
let snippet = format!("{}, ", name);
|
||||
let snippet = format!("{name}, ");
|
||||
(span, snippet)
|
||||
};
|
||||
// Suggest the modification to the user
|
||||
|
@ -667,7 +667,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
name,
|
||||
);
|
||||
for sp in target_sp {
|
||||
err.span_label(sp, format!("pattern doesn't bind `{}`", name));
|
||||
err.span_label(sp, format!("pattern doesn't bind `{name}`"));
|
||||
}
|
||||
for sp in origin_sp {
|
||||
err.span_label(sp, "variable not in all patterns");
|
||||
|
@ -694,8 +694,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if import_suggestions.is_empty() {
|
||||
let help_msg = format!(
|
||||
"if you meant to match on a variant or a `const` item, consider \
|
||||
making the path in the pattern qualified: `path::to::ModOrType::{}`",
|
||||
name,
|
||||
making the path in the pattern qualified: `path::to::ModOrType::{name}`",
|
||||
);
|
||||
err.span_help(span, help_msg);
|
||||
}
|
||||
|
@ -953,8 +952,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let mut err = self.tcx.sess.struct_span_err_with_code(
|
||||
span,
|
||||
format!(
|
||||
"item `{}` is an associated {}, which doesn't match its trait `{}`",
|
||||
name, kind, trait_path,
|
||||
"item `{name}` is an associated {kind}, which doesn't match its trait `{trait_path}`",
|
||||
),
|
||||
code,
|
||||
);
|
||||
|
@ -1427,10 +1425,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
"a function-like macro".to_string()
|
||||
}
|
||||
Res::Def(DefKind::Macro(MacroKind::Attr), _) | Res::NonMacroAttr(..) => {
|
||||
format!("an attribute: `#[{}]`", ident)
|
||||
format!("an attribute: `#[{ident}]`")
|
||||
}
|
||||
Res::Def(DefKind::Macro(MacroKind::Derive), _) => {
|
||||
format!("a derive macro: `#[derive({})]`", ident)
|
||||
format!("a derive macro: `#[derive({ident})]`")
|
||||
}
|
||||
Res::ToolMod => {
|
||||
// Don't confuse the user with tool modules.
|
||||
|
@ -1451,7 +1449,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if !import.span.is_dummy() {
|
||||
err.span_note(
|
||||
import.span,
|
||||
format!("`{}` is imported here, but it is {}", ident, desc),
|
||||
format!("`{ident}` is imported here, but it is {desc}"),
|
||||
);
|
||||
// Silence the 'unused import' warning we might get,
|
||||
// since this diagnostic already covers that import.
|
||||
|
@ -1459,7 +1457,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
}
|
||||
err.note(format!("`{}` is in scope, but it is {}", ident, desc));
|
||||
err.note(format!("`{ident}` is in scope, but it is {desc}"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1597,7 +1595,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
.enumerate()
|
||||
.map(|(i, help_msg)| {
|
||||
let or = if i == 0 { "" } else { "or " };
|
||||
format!("{}{}", or, help_msg)
|
||||
format!("{or}{help_msg}")
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
|
@ -1655,7 +1653,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let descr = get_descr(binding);
|
||||
let mut err =
|
||||
struct_span_err!(self.tcx.sess, ident.span, E0603, "{} `{}` is private", descr, ident);
|
||||
err.span_label(ident.span, format!("private {}", descr));
|
||||
err.span_label(ident.span, format!("private {descr}"));
|
||||
|
||||
if let Some((this_res, outer_ident)) = outermost_res {
|
||||
let import_suggestions = self.lookup_import_candidates(
|
||||
|
@ -1840,7 +1838,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
_ => format!("`{parent}`"),
|
||||
};
|
||||
|
||||
let mut msg = format!("could not find `{}` in {}", ident, parent);
|
||||
let mut msg = format!("could not find `{ident}` in {parent}");
|
||||
if ns == TypeNS || ns == ValueNS {
|
||||
let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
|
||||
let binding = if let Some(module) = module {
|
||||
|
@ -1955,12 +1953,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let suggestion = match_span.map(|span| {
|
||||
(
|
||||
vec![(span, String::from(""))],
|
||||
format!("`{}` is defined here, but is not a type", ident),
|
||||
format!("`{ident}` is defined here, but is not a type"),
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
});
|
||||
|
||||
(format!("use of undeclared type `{}`", ident), suggestion)
|
||||
(format!("use of undeclared type `{ident}`"), suggestion)
|
||||
} else {
|
||||
let mut suggestion = None;
|
||||
if ident.name == sym::alloc {
|
||||
|
@ -1982,7 +1980,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
},
|
||||
)
|
||||
});
|
||||
(format!("use of undeclared crate or module `{}`", ident), suggestion)
|
||||
(format!("use of undeclared crate or module `{ident}`"), suggestion)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2166,16 +2164,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let module_name = crate_module.kind.name().unwrap();
|
||||
let import_snippet = match import.kind {
|
||||
ImportKind::Single { source, target, .. } if source != target => {
|
||||
format!("{} as {}", source, target)
|
||||
format!("{source} as {target}")
|
||||
}
|
||||
_ => format!("{}", ident),
|
||||
_ => format!("{ident}"),
|
||||
};
|
||||
|
||||
let mut corrections: Vec<(Span, String)> = Vec::new();
|
||||
if !import.is_nested() {
|
||||
// Assume this is the easy case of `use issue_59764::foo::makro;` and just remove
|
||||
// intermediate segments.
|
||||
corrections.push((import.span, format!("{}::{}", module_name, import_snippet)));
|
||||
corrections.push((import.span, format!("{module_name}::{import_snippet}")));
|
||||
} else {
|
||||
// Find the binding span (and any trailing commas and spaces).
|
||||
// ie. `use a::b::{c, d, e};`
|
||||
|
@ -2242,11 +2240,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
start_point,
|
||||
if has_nested {
|
||||
// In this case, `start_snippet` must equal '{'.
|
||||
format!("{}{}, ", start_snippet, import_snippet)
|
||||
format!("{start_snippet}{import_snippet}, ")
|
||||
} else {
|
||||
// In this case, add a `{`, then the moved import, then whatever
|
||||
// was there before.
|
||||
format!("{{{}, {}", import_snippet, start_snippet)
|
||||
format!("{{{import_snippet}, {start_snippet}")
|
||||
},
|
||||
));
|
||||
|
||||
|
@ -2663,9 +2661,9 @@ fn show_candidates(
|
|||
"item"
|
||||
};
|
||||
let plural_descr =
|
||||
if descr.ends_with('s') { format!("{}es", descr) } else { format!("{}s", descr) };
|
||||
if descr.ends_with('s') { format!("{descr}es") } else { format!("{descr}s") };
|
||||
|
||||
let mut msg = format!("{}these {} exist but are inaccessible", prefix, plural_descr);
|
||||
let mut msg = format!("{prefix}these {plural_descr} exist but are inaccessible");
|
||||
let mut has_colon = false;
|
||||
|
||||
let mut spans = Vec::new();
|
||||
|
@ -2686,7 +2684,7 @@ fn show_candidates(
|
|||
|
||||
let mut multi_span = MultiSpan::from_spans(spans.iter().map(|(_, sp)| *sp).collect());
|
||||
for (name, span) in spans {
|
||||
multi_span.push_span_label(span, format!("`{}`: not accessible", name));
|
||||
multi_span.push_span_label(span, format!("`{name}`: not accessible"));
|
||||
}
|
||||
|
||||
for note in inaccessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) {
|
||||
|
|
|
@ -1445,12 +1445,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let name_str = if name == kw::PathRoot {
|
||||
"crate root".to_string()
|
||||
} else {
|
||||
format!("`{}`", name)
|
||||
format!("`{name}`")
|
||||
};
|
||||
let label = if segment_idx == 1 && path[0].ident.name == kw::PathRoot {
|
||||
format!("global paths cannot start with {}", name_str)
|
||||
format!("global paths cannot start with {name_str}")
|
||||
} else {
|
||||
format!("{} in paths can only be used in start position", name_str)
|
||||
format!("{name_str} in paths can only be used in start position")
|
||||
};
|
||||
(label, None)
|
||||
});
|
||||
|
|
|
@ -1153,18 +1153,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
ModuleOrUniformRoot::Module(module) => {
|
||||
let module_str = module_to_string(module);
|
||||
if let Some(module_str) = module_str {
|
||||
format!("no `{}` in `{}`", ident, module_str)
|
||||
format!("no `{ident}` in `{module_str}`")
|
||||
} else {
|
||||
format!("no `{}` in the root", ident)
|
||||
format!("no `{ident}` in the root")
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if !ident.is_path_segment_keyword() {
|
||||
format!("no external crate `{}`", ident)
|
||||
format!("no external crate `{ident}`")
|
||||
} else {
|
||||
// HACK(eddyb) this shows up for `self` & `super`, which
|
||||
// should work instead - for now keep the same error message.
|
||||
format!("no `{}` in the root", ident)
|
||||
format!("no `{ident}` in the root")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1212,10 +1212,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let (ns, binding) = reexport_error.unwrap();
|
||||
if pub_use_of_private_extern_crate_hack(import, binding) {
|
||||
let msg = format!(
|
||||
"extern crate `{}` is private, and cannot be \
|
||||
"extern crate `{ident}` is private, and cannot be \
|
||||
re-exported (error E0365), consider declaring with \
|
||||
`pub`",
|
||||
ident
|
||||
`pub`"
|
||||
);
|
||||
self.lint_buffer.buffer_lint(
|
||||
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
|
||||
|
@ -1355,7 +1354,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
UNUSED_IMPORTS,
|
||||
id,
|
||||
import.span,
|
||||
format!("the item `{}` is imported redundantly", ident),
|
||||
format!("the item `{ident}` is imported redundantly"),
|
||||
BuiltinLintDiagnostics::RedundantImport(redundant_spans, ident),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1917,10 +1917,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
candidate: LifetimeElisionCandidate,
|
||||
) {
|
||||
if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) {
|
||||
panic!(
|
||||
"lifetime {:?} resolved multiple times ({:?} before, {:?} now)",
|
||||
id, prev_res, res
|
||||
)
|
||||
panic!("lifetime {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)")
|
||||
}
|
||||
match res {
|
||||
LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static => {
|
||||
|
@ -1936,8 +1933,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
fn record_lifetime_param(&mut self, id: NodeId, res: LifetimeRes) {
|
||||
if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) {
|
||||
panic!(
|
||||
"lifetime parameter {:?} resolved multiple times ({:?} before, {:?} now)",
|
||||
id, prev_res, res
|
||||
"lifetime parameter {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -585,13 +585,13 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
let others = match enum_candidates.len() {
|
||||
1 => String::new(),
|
||||
2 => " and 1 other".to_owned(),
|
||||
n => format!(" and {} others", n),
|
||||
n => format!(" and {n} others"),
|
||||
};
|
||||
format!("there is an enum variant `{}`{}; ", enum_candidates[0].0, others)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let msg = format!("{}try using the variant's enum", preamble);
|
||||
let msg = format!("{preamble}try using the variant's enum");
|
||||
|
||||
err.span_suggestions(
|
||||
span,
|
||||
|
@ -696,7 +696,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
ident.name == path[0].ident.name {
|
||||
err.span_help(
|
||||
ident.span,
|
||||
format!("the binding `{}` is available in a different scope in the same function", path_str),
|
||||
format!("the binding `{path_str}` is available in a different scope in the same function"),
|
||||
);
|
||||
return (true, candidates);
|
||||
}
|
||||
|
@ -858,7 +858,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
for label_rib in &self.label_ribs {
|
||||
for (label_ident, node_id) in &label_rib.bindings {
|
||||
let ident = path.last().unwrap().ident;
|
||||
if format!("'{}", ident) == label_ident.to_string() {
|
||||
if format!("'{ident}") == label_ident.to_string() {
|
||||
err.span_label(label_ident.span, "a label with a similar name exists");
|
||||
if let PathSource::Expr(Some(Expr {
|
||||
kind: ExprKind::Break(None, Some(_)),
|
||||
|
@ -983,7 +983,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
if let Some(ident) = fn_kind.ident() {
|
||||
err.span_label(
|
||||
ident.span,
|
||||
format!("this function {} have a `self` parameter", doesnt),
|
||||
format!("this function {doesnt} have a `self` parameter"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1164,7 +1164,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
};
|
||||
err.span_suggestion_verbose(
|
||||
*where_span,
|
||||
format!("constrain the associated type to `{}`", ident),
|
||||
format!("constrain the associated type to `{ident}`"),
|
||||
where_bound_predicate_to_string(&new_where_bound_predicate),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
@ -1338,8 +1338,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
span, // Note the parentheses surrounding the suggestion below
|
||||
format!(
|
||||
"you might want to surround a struct literal with parentheses: \
|
||||
`({} {{ /* fields */ }})`?",
|
||||
path_str
|
||||
`({path_str} {{ /* fields */ }})`?"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1373,7 +1372,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
.map(|(idx, new)| (new, old_fields.get(idx)))
|
||||
.map(|(new, old)| {
|
||||
let new = new.to_ident_string();
|
||||
if let Some(Some(old)) = old && new != *old { format!("{}: {}", new, old) } else { new }
|
||||
if let Some(Some(old)) = old && new != *old { format!("{new}: {old}") } else { new }
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
} else {
|
||||
|
@ -1390,7 +1389,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
};
|
||||
err.span_suggestion(
|
||||
span,
|
||||
format!("use struct {} syntax instead", descr),
|
||||
format!("use struct {descr} syntax instead"),
|
||||
format!("{path_str} {{{pad}{fields}{pad}}}"),
|
||||
applicability,
|
||||
);
|
||||
|
@ -1584,7 +1583,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
err.span_suggestion(
|
||||
span,
|
||||
"use the tuple variant pattern syntax instead",
|
||||
format!("{}({})", path_str, fields),
|
||||
format!("{path_str}({fields})"),
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
}
|
||||
|
@ -1994,9 +1993,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
|
||||
if !suggestable_variants.is_empty() {
|
||||
let msg = if non_suggestable_variant_count == 0 && suggestable_variants.len() == 1 {
|
||||
format!("try {} the enum's variant", source_msg)
|
||||
format!("try {source_msg} the enum's variant")
|
||||
} else {
|
||||
format!("try {} one of the enum's variants", source_msg)
|
||||
format!("try {source_msg} one of the enum's variants")
|
||||
};
|
||||
|
||||
err.span_suggestions(
|
||||
|
@ -2009,19 +2008,15 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
|
||||
// If the enum has no tuple variants..
|
||||
if non_suggestable_variant_count == variants.len() {
|
||||
err.help(format!("the enum has no tuple variants {}", source_msg));
|
||||
err.help(format!("the enum has no tuple variants {source_msg}"));
|
||||
}
|
||||
|
||||
// If there are also non-tuple variants..
|
||||
if non_suggestable_variant_count == 1 {
|
||||
err.help(format!(
|
||||
"you might have meant {} the enum's non-tuple variant",
|
||||
source_msg
|
||||
));
|
||||
err.help(format!("you might have meant {source_msg} the enum's non-tuple variant"));
|
||||
} else if non_suggestable_variant_count >= 1 {
|
||||
err.help(format!(
|
||||
"you might have meant {} one of the enum's non-tuple variants",
|
||||
source_msg
|
||||
"you might have meant {source_msg} one of the enum's non-tuple variants"
|
||||
));
|
||||
}
|
||||
} else {
|
||||
|
@ -2041,7 +2036,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
.map(|(variant, _, kind)| (path_names_to_string(variant), kind))
|
||||
.map(|(variant, kind)| match kind {
|
||||
CtorKind::Const => variant,
|
||||
CtorKind::Fn => format!("({}())", variant),
|
||||
CtorKind::Fn => format!("({variant}())"),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let no_suggestable_variant = suggestable_variants.is_empty();
|
||||
|
@ -2066,7 +2061,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
.filter(|(_, def_id, kind)| needs_placeholder(*def_id, *kind))
|
||||
.map(|(variant, _, kind)| (path_names_to_string(variant), kind))
|
||||
.filter_map(|(variant, kind)| match kind {
|
||||
CtorKind::Fn => Some(format!("({}(/* fields */))", variant)),
|
||||
CtorKind::Fn => Some(format!("({variant}(/* fields */))")),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -2361,8 +2356,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
err.span_label(
|
||||
span,
|
||||
format!(
|
||||
"lifetime `{}` is missing in item created through this procedural macro",
|
||||
name,
|
||||
"lifetime `{name}` is missing in item created through this procedural macro",
|
||||
),
|
||||
);
|
||||
continue;
|
||||
|
@ -2406,7 +2400,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
);
|
||||
} else if let Some(name) = name {
|
||||
let message =
|
||||
Cow::from(format!("consider introducing lifetime `{}` here", name));
|
||||
Cow::from(format!("consider introducing lifetime `{name}` here"));
|
||||
should_continue = suggest(err, false, span, message, sugg);
|
||||
} else {
|
||||
let message = Cow::from("consider introducing a named lifetime parameter");
|
||||
|
@ -2550,7 +2544,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
}
|
||||
|
||||
let help_name = if let Some(ident) = ident {
|
||||
format!("`{}`", ident)
|
||||
format!("`{ident}`")
|
||||
} else {
|
||||
format!("argument {}", index + 1)
|
||||
};
|
||||
|
@ -2558,7 +2552,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
if lifetime_count == 1 {
|
||||
m.push_str(&help_name[..])
|
||||
} else {
|
||||
m.push_str(&format!("one of {}'s {} lifetimes", help_name, lifetime_count)[..])
|
||||
m.push_str(&format!("one of {help_name}'s {lifetime_count} lifetimes")[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2588,14 +2582,12 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
} else if num_params == 1 {
|
||||
err.help(format!(
|
||||
"this function's return type contains a borrowed value, \
|
||||
but the signature does not say which {} it is borrowed from",
|
||||
m
|
||||
but the signature does not say which {m} it is borrowed from"
|
||||
));
|
||||
} else {
|
||||
err.help(format!(
|
||||
"this function's return type contains a borrowed value, \
|
||||
but the signature does not say whether it is borrowed from {}",
|
||||
m
|
||||
but the signature does not say whether it is borrowed from {m}"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -2614,7 +2606,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
}
|
||||
MissingLifetimeKind::Ampersand => {
|
||||
debug_assert_eq!(lt.count, 1);
|
||||
(lt.span.shrink_to_hi(), format!("{} ", existing_name))
|
||||
(lt.span.shrink_to_hi(), format!("{existing_name} "))
|
||||
}
|
||||
MissingLifetimeKind::Comma => {
|
||||
let sugg: String = std::iter::repeat([existing_name.as_str(), ", "])
|
||||
|
@ -2661,7 +2653,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
}
|
||||
1 => {
|
||||
err.multipart_suggestion_verbose(
|
||||
format!("consider using the `{}` lifetime", existing_name),
|
||||
format!("consider using the `{existing_name}` lifetime"),
|
||||
spans_suggs,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
@ -2778,9 +2770,9 @@ pub(super) fn signal_label_shadowing(sess: &Session, orig: Span, shadower: Ident
|
|||
let shadower = shadower.span;
|
||||
let mut err = sess.struct_span_warn(
|
||||
shadower,
|
||||
format!("label name `{}` shadows a label name that is already in scope", name),
|
||||
format!("label name `{name}` shadows a label name that is already in scope"),
|
||||
);
|
||||
err.span_label(orig, "first declared here");
|
||||
err.span_label(shadower, format!("label `{}` already in scope", name));
|
||||
err.span_label(shadower, format!("label `{name}` already in scope"));
|
||||
err.emit();
|
||||
}
|
||||
|
|
|
@ -1168,7 +1168,7 @@ impl<'tcx> Resolver<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn local_def_id(&self, node: NodeId) -> LocalDefId {
|
||||
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
|
||||
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
|
||||
}
|
||||
|
||||
/// Adds a definition with a parent definition.
|
||||
|
@ -1834,7 +1834,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
fn record_partial_res(&mut self, node_id: NodeId, resolution: PartialRes) {
|
||||
debug!("(recording res) recording {:?} for {}", resolution, node_id);
|
||||
if let Some(prev_res) = self.partial_res_map.insert(node_id, resolution) {
|
||||
panic!("path resolved multiple times ({:?} before, {:?} now)", prev_res, resolution);
|
||||
panic!("path resolved multiple times ({prev_res:?} before, {resolution:?} now)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> {
|
|||
self.tcx
|
||||
.sess
|
||||
.diagnostic()
|
||||
.bug(format!("built-in macro `{}` was already registered", name));
|
||||
.bug(format!("built-in macro `{name}` was already registered"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let mut err = self.tcx.sess.create_err(err);
|
||||
err.span_label(path.span, format!("not {} {}", article, expected));
|
||||
err.span_label(path.span, format!("not {article} {expected}"));
|
||||
|
||||
err.emit();
|
||||
|
||||
|
@ -906,7 +906,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if macro_kind.is_some() && sub_namespace_match(macro_kind, Some(MacroKind::Attr)) {
|
||||
self.tcx.sess.span_err(
|
||||
ident.span,
|
||||
format!("name `{}` is reserved in attribute namespace", ident),
|
||||
format!("name `{ident}` is reserved in attribute namespace"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue