inline format!() args up to and including rustc_middle
This commit is contained in:
parent
2e0136a131
commit
23815467a2
87 changed files with 378 additions and 437 deletions
|
@ -369,7 +369,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
let TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _) =
|
||||
orig_trees.next().unwrap().clone()
|
||||
else {
|
||||
panic!("Bad tokens for attribute {:?}", attr);
|
||||
panic!("Bad tokens for attribute {attr:?}");
|
||||
};
|
||||
let pound_span = pound_token.span;
|
||||
|
||||
|
@ -379,7 +379,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) =
|
||||
orig_trees.next().unwrap().clone()
|
||||
else {
|
||||
panic!("Bad tokens for attribute {:?}", attr);
|
||||
panic!("Bad tokens for attribute {attr:?}");
|
||||
};
|
||||
trees.push(AttrTokenTree::Token(bang_token, Spacing::Alone));
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
Delimiter::Bracket,
|
||||
item.tokens
|
||||
.as_ref()
|
||||
.unwrap_or_else(|| panic!("Missing tokens for {:?}", item))
|
||||
.unwrap_or_else(|| panic!("Missing tokens for {item:?}"))
|
||||
.to_attr_token_stream(),
|
||||
);
|
||||
trees.push(bracket_group);
|
||||
|
|
|
@ -803,7 +803,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
&self.cx.sess.parse_sess,
|
||||
sym::proc_macro_hygiene,
|
||||
span,
|
||||
format!("custom attributes cannot be applied to {}", kind),
|
||||
format!("custom attributes cannot be applied to {kind}"),
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
@ -1707,7 +1707,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||
&UNUSED_ATTRIBUTES,
|
||||
attr.span,
|
||||
self.cx.current_expansion.lint_node_id,
|
||||
format!("unused attribute `{}`", attr_name),
|
||||
format!("unused attribute `{attr_name}`"),
|
||||
BuiltinLintDiagnostics::UnusedBuiltinAttribute {
|
||||
attr_name,
|
||||
macro_name: pprust::path_to_string(&call.path),
|
||||
|
|
|
@ -257,7 +257,7 @@ pub(super) fn emit_frag_parse_err(
|
|||
e.span_suggestion_verbose(
|
||||
site_span,
|
||||
"surround the macro invocation with `{}` to interpret the expansion as a statement",
|
||||
format!("{{ {}; }}", snippet),
|
||||
format!("{{ {snippet}; }}"),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -593,7 +593,7 @@ fn check_ops_is_prefix(
|
|||
return;
|
||||
}
|
||||
}
|
||||
buffer_lint(sess, span.into(), node_id, format!("unknown macro variable `{}`", name));
|
||||
buffer_lint(sess, span.into(), node_id, format!("unknown macro variable `{name}`"));
|
||||
}
|
||||
|
||||
/// Returns whether `binder_ops` is a prefix of `occurrence_ops`.
|
||||
|
@ -626,7 +626,7 @@ fn ops_is_prefix(
|
|||
if i >= occurrence_ops.len() {
|
||||
let mut span = MultiSpan::from_span(span);
|
||||
span.push_span_label(binder.span, "expected repetition");
|
||||
let message = format!("variable '{}' is still repeating at this depth", name);
|
||||
let message = format!("variable '{name}' is still repeating at this depth");
|
||||
buffer_lint(sess, span, node_id, message);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ impl Display for MatcherLoc {
|
|||
MatcherLoc::MetaVarDecl { bind, kind, .. } => {
|
||||
write!(f, "meta-variable `${bind}")?;
|
||||
if let Some(kind) = kind {
|
||||
write!(f, ":{}", kind)?;
|
||||
write!(f, ":{kind}")?;
|
||||
}
|
||||
write!(f, "`")?;
|
||||
Ok(())
|
||||
|
@ -723,7 +723,7 @@ impl TtParser {
|
|||
.iter()
|
||||
.map(|mp| match &matcher[mp.idx] {
|
||||
MatcherLoc::MetaVarDecl { bind, kind: Some(kind), .. } => {
|
||||
format!("{} ('{}')", kind, bind)
|
||||
format!("{kind} ('{bind}')")
|
||||
}
|
||||
_ => unreachable!(),
|
||||
})
|
||||
|
@ -736,8 +736,8 @@ impl TtParser {
|
|||
"local ambiguity when calling macro `{}`: multiple parsing options: {}",
|
||||
self.macro_name,
|
||||
match self.next_mps.len() {
|
||||
0 => format!("built-in NTs {}.", nts),
|
||||
n => format!("built-in NTs {} or {n} other option{s}.", nts, s = pluralize!(n)),
|
||||
0 => format!("built-in NTs {nts}."),
|
||||
n => format!("built-in NTs {nts} or {n} other option{s}.", s = pluralize!(n)),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
@ -757,7 +757,7 @@ impl TtParser {
|
|||
match ret_val.entry(MacroRulesNormalizedIdent::new(bind)) {
|
||||
Vacant(spot) => spot.insert(res.next().unwrap()),
|
||||
Occupied(..) => {
|
||||
return Error(span, format!("duplicated bind name: {}", bind));
|
||||
return Error(span, format!("duplicated bind name: {bind}"));
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
|
|
@ -554,7 +554,7 @@ pub fn compile_declarative_macro(
|
|||
let (transparency, transparency_error) = attr::find_transparency(&def.attrs, macro_rules);
|
||||
match transparency_error {
|
||||
Some(TransparencyError::UnknownTransparency(value, span)) => {
|
||||
diag.span_err(span, format!("unknown macro transparency: `{}`", value));
|
||||
diag.span_err(span, format!("unknown macro transparency: `{value}`"));
|
||||
}
|
||||
Some(TransparencyError::MultipleTransparencyAttrs(old_span, new_span)) => {
|
||||
diag.span_err(vec![old_span, new_span], "multiple macro transparency attributes");
|
||||
|
@ -1197,7 +1197,7 @@ fn check_matcher_core<'tt>(
|
|||
may_be = may_be
|
||||
),
|
||||
);
|
||||
err.span_label(sp, format!("not allowed after `{}` fragments", kind));
|
||||
err.span_label(sp, format!("not allowed after `{kind}` fragments"));
|
||||
|
||||
if kind == NonterminalKind::PatWithOr
|
||||
&& sess.edition.at_least_rust_2021()
|
||||
|
@ -1221,8 +1221,7 @@ fn check_matcher_core<'tt>(
|
|||
&[] => {}
|
||||
&[t] => {
|
||||
err.note(format!(
|
||||
"only {} is allowed after `{}` fragments",
|
||||
t, kind,
|
||||
"only {t} is allowed after `{kind}` fragments",
|
||||
));
|
||||
}
|
||||
ts => {
|
||||
|
@ -1407,9 +1406,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
|
|||
fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String {
|
||||
match tt {
|
||||
mbe::TokenTree::Token(token) => pprust::token_to_string(&token).into(),
|
||||
mbe::TokenTree::MetaVar(_, name) => format!("${}", name),
|
||||
mbe::TokenTree::MetaVarDecl(_, name, Some(kind)) => format!("${}:{}", name, kind),
|
||||
mbe::TokenTree::MetaVarDecl(_, name, None) => format!("${}:", name),
|
||||
mbe::TokenTree::MetaVar(_, name) => format!("${name}"),
|
||||
mbe::TokenTree::MetaVarDecl(_, name, Some(kind)) => format!("${name}:{kind}"),
|
||||
mbe::TokenTree::MetaVarDecl(_, name, None) => format!("${name}:"),
|
||||
_ => panic!(
|
||||
"{}",
|
||||
"unexpected mbe::TokenTree::{Sequence or Delimited} \
|
||||
|
|
|
@ -194,7 +194,7 @@ fn parse_tree<'a>(
|
|||
Delimiter::Parenthesis => {}
|
||||
_ => {
|
||||
let tok = pprust::token_kind_to_string(&token::OpenDelim(delim));
|
||||
let msg = format!("expected `(` or `{{`, found `{}`", tok);
|
||||
let msg = format!("expected `(` or `{{`, found `{tok}`");
|
||||
sess.span_diagnostic.span_err(delim_span.entire(), msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ impl base::AttrProcMacro for AttrProcMacro {
|
|||
|e| {
|
||||
let mut err = ecx.struct_span_err(span, "custom attribute panicked");
|
||||
if let Some(s) = e.as_str() {
|
||||
err.help(format!("message: {}", s));
|
||||
err.help(format!("message: {s}"));
|
||||
}
|
||||
err.emit()
|
||||
},
|
||||
|
@ -148,7 +148,7 @@ impl MultiItemModifier for DeriveProcMacro {
|
|||
Err(e) => {
|
||||
let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
|
||||
if let Some(s) = e.as_str() {
|
||||
err.help(format!("message: {}", s));
|
||||
err.help(format!("message: {s}"));
|
||||
}
|
||||
err.emit();
|
||||
return ExpandResult::Ready(vec![]);
|
||||
|
|
|
@ -622,7 +622,7 @@ impl server::SourceFile for Rustc<'_, '_> {
|
|||
impl server::Span for Rustc<'_, '_> {
|
||||
fn debug(&mut self, span: Self::Span) -> String {
|
||||
if self.ecx.ecfg.span_debug {
|
||||
format!("{:?}", span)
|
||||
format!("{span:?}")
|
||||
} else {
|
||||
format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue