clippy fixes

This commit is contained in:
cyrgani
2026-03-09 09:13:09 +00:00
parent 7db0ab43a7
commit 3fa55e721a
11 changed files with 20 additions and 23 deletions
+1 -1
View File
@@ -898,7 +898,7 @@ pub fn default(kind: SyntaxExtensionKind, edition: Edition) -> SyntaxExtension {
fn get_collapse_debuginfo(sess: &Session, attrs: &[hir::Attribute], ext: bool) -> bool {
let flag = sess.opts.cg.collapse_macro_debuginfo;
let attr = if let Some(info) = find_attr!(attrs, CollapseDebugInfo(info) => info) {
info.clone()
*info
} else if find_attr!(attrs, RustcBuiltinMacro { .. }) {
CollapseMacroDebuginfo::Yes
} else {
+2 -2
View File
@@ -285,7 +285,7 @@ pub(crate) fn expand_cfg_attr(&self, cfg_attr: &Attribute, recursive: bool) -> V
let Some((cfg_predicate, expanded_attrs)) = rustc_attr_parsing::parse_cfg_attr(
cfg_attr,
&self.sess,
self.sess,
self.features,
self.lint_node_id,
) else {
@@ -422,7 +422,7 @@ pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
&& !attr.span.allows_unstable(sym::stmt_expr_attributes)
{
let mut err = feature_err(
&self.sess,
self.sess,
sym::stmt_expr_attributes,
attr.span,
msg!("attributes on expressions are experimental"),
+4 -4
View File
@@ -1050,7 +1050,7 @@ fn gate_proc_macro_attr_item(&self, span: Span, item: &Annotatable) {
return;
}
feature_err(
&self.cx.sess,
self.cx.sess,
sym::proc_macro_hygiene,
span,
format!("custom attributes cannot be applied to {kind}"),
@@ -1085,7 +1085,7 @@ fn visit_item(&mut self, item: &'ast ast::Item) {
}
if !self.cx.ecfg.features.proc_macro_hygiene() {
annotatable.visit_with(&mut GateProcMacroInput { sess: &self.cx.sess });
annotatable.visit_with(&mut GateProcMacroInput { sess: self.cx.sess });
}
}
@@ -1474,7 +1474,7 @@ fn collect_use_tree_leaves(ut: &ast::UseTree, idents: &mut Vec<Ident>) {
}
}
let mut idents = Vec::new();
collect_use_tree_leaves(&ut, &mut idents);
collect_use_tree_leaves(ut, &mut idents);
idents
} else {
self.kind.ident().into_iter().collect()
@@ -1482,7 +1482,7 @@ fn collect_use_tree_leaves(ut: &ast::UseTree, idents: &mut Vec<Ident>) {
}
fn as_target(&self) -> Target {
Target::from_ast_item(&*self)
Target::from_ast_item(self)
}
}
+2 -4
View File
@@ -323,9 +323,7 @@ pub(super) fn emit_frag_parse_err(
} else if bindings_name.contains(&name) {
e.span_label(
parser.token.span,
format!(
"there is an macro metavariable with this name in another macro matcher"
),
"there is an macro metavariable with this name in another macro matcher",
);
} else if let Some(matched_name) =
rustc_span::edit_distance::find_best_match_for_name(&bindings_name[..], name, None)
@@ -343,7 +341,7 @@ pub(super) fn emit_frag_parse_err(
.collect::<Vec<_>>()
.join(", ");
e.span_label(parser.token.span, format!("macro metavariable not found"));
e.span_label(parser.token.span, "macro metavariable not found");
if !matched_rule_bindings_names.is_empty() {
e.note(format!("available metavariable names are: {msg}"));
}
@@ -199,8 +199,8 @@ fn inner(
let idx_seq = idx_first - 1;
inner(&seq.tts, locs, next_metavar, seq_depth + 1);
if let Some(separator) = &seq.separator {
locs.push(MatcherLoc::SequenceSep { separator: separator.clone() });
if let Some(separator) = seq.separator {
locs.push(MatcherLoc::SequenceSep { separator });
locs.push(MatcherLoc::SequenceKleeneOpAfterSep { idx_first });
} else {
locs.push(MatcherLoc::SequenceKleeneOpNoSep { op, idx_first });
+2 -2
View File
@@ -214,7 +214,7 @@ fn parse_tree<'a>(
// during parsing.
let mut next = outer_iter.next();
let mut iter_storage;
let mut iter: &mut TokenStreamIter<'_> = match next {
let iter: &mut TokenStreamIter<'_> = match next {
Some(tokenstream::TokenTree::Delimited(.., delim, tts)) if delim.skip() => {
iter_storage = tts.iter();
next = iter_storage.next();
@@ -284,7 +284,7 @@ fn parse_tree<'a>(
let sequence = parse(tts, part, sess, node_id, features, edition);
// Get the Kleene operator and optional separator
let (separator, kleene) =
parse_sep_and_kleene_op(&mut iter, delim_span.entire(), sess);
parse_sep_and_kleene_op(iter, delim_span.entire(), sess);
// Count the number of captured "names" (i.e., named metavars)
let num_captures =
if part.is_pattern() { count_metavar_decls(&sequence) } else { 0 };
+3 -3
View File
@@ -396,7 +396,7 @@ fn transcribe_sequence<'tx, 'itp>(
// The first time we encounter the sequence we push it to the stack. It
// then gets reused (see the beginning of the loop) until we are done
// repeating.
tscx.stack.push(Frame::new_sequence(seq_rep, seq.separator.clone(), seq.kleene.op));
tscx.stack.push(Frame::new_sequence(seq_rep, seq.separator, seq.kleene.op));
}
}
}
@@ -629,7 +629,7 @@ fn metavar_expr_concat<'tx>(
) -> PResult<'tx, TokenTree> {
let dcx = tscx.psess.dcx();
let mut concatenated = String::new();
for element in elements.into_iter() {
for element in elements {
let symbol = match element {
MetaVarExprConcatElem::Ident(elem) => elem.name,
MetaVarExprConcatElem::Literal(elem) => *elem,
@@ -747,7 +747,7 @@ fn maybe_use_metavar_location(
TokenTree::Token(Token { kind, span }, spacing) => {
let span = metavar_span.with_ctxt(span.ctxt());
with_metavar_spans(|mspans| mspans.insert(span, metavar_span));
TokenTree::Token(Token { kind: kind.clone(), span }, *spacing)
TokenTree::Token(Token { kind: *kind, span }, *spacing)
}
TokenTree::Delimited(dspan, dspacing, delimiter, tts) => {
let open = metavar_span.with_ctxt(dspan.open.ctxt());
+1 -1
View File
@@ -75,7 +75,7 @@ pub(crate) fn parse_external_mod(
Some(span),
));
let (inner_attrs, items, inner_span) =
parser.parse_mod(exp!(Eof)).map_err(|err| ModError::ParserError(err))?;
parser.parse_mod(exp!(Eof)).map_err(ModError::ParserError)?;
attrs.extend(inner_attrs);
(items, inner_span, mp.file_path)
};
+1 -1
View File
@@ -232,7 +232,7 @@ fn enter<F, R>(ecx: &mut ExtCtxt<'_>, client: DeriveClient, f: F) -> R
{
// We need erasure to get rid of the lifetime
let ctx = Self { expansion_ctx: ecx as *mut _ as *mut (), client };
DERIVE_EXPAND_CTX.set(&ctx, || f())
DERIVE_EXPAND_CTX.set(&ctx, f)
}
/// Accesses the thread local value of the derive expansion context.
@@ -110,9 +110,8 @@ fn from_internal(stream: TokenStream) -> Self {
// Estimate the capacity as `stream.len()` rounded up to the next power
// of two to limit the number of required reallocations.
let mut trees = Vec::with_capacity(stream.len().next_power_of_two());
let mut iter = stream.iter();
while let Some(tree) = iter.next() {
for tree in stream.iter() {
let (Token { kind, span }, joint) = match tree.clone() {
tokenstream::TokenTree::Delimited(span, _, mut delim, mut stream) => {
// In `mk_delimited` we avoid nesting invisible delimited
+1 -1
View File
@@ -152,7 +152,7 @@ pub(crate) fn update_macro_stats(
}
// The recorded size is the difference between the input and the output.
let entry = ecx.macro_stats.entry((name, macro_kind)).or_insert(MacroStat::default());
let entry = ecx.macro_stats.entry((name, macro_kind)).or_default();
entry.uses += 1;
entry.lines += num_lines;
entry.bytes += num_bytes;