Skip to content

Commit 6792cf5

Browse files
committed
Call Arc::clone rather than .clone() to make clippy happy
1 parent 82d8890 commit 6792cf5

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,12 @@ pub fn compile_declarative_macro(
628628
// Return the number of rules for unused rule linting, if this is a local macro.
629629
let nrules = if is_defined_in_current_crate(node_id) { rules.len() } else { 0 };
630630

631-
let expander =
632-
Arc::new(MacroRulesMacroExpander { name: ident, span, node_id, transparency, rules });
633-
let opt_attr_ext =
634-
has_attr_rules.then(|| Arc::new(mk_syn_ext(SyntaxExtensionKind::Attr(expander.clone()))));
635-
(mk_bang_ext(expander), opt_attr_ext, nrules)
631+
let exp = Arc::new(MacroRulesMacroExpander { name: ident, span, node_id, transparency, rules });
632+
let opt_attr_ext = has_attr_rules.then(|| {
633+
let exp = Arc::clone(&exp);
634+
Arc::new(mk_syn_ext(SyntaxExtensionKind::Attr(exp)))
635+
});
636+
(mk_bang_ext(exp), opt_attr_ext, nrules)
636637
}
637638

638639
fn check_no_eof(sess: &Session, p: &Parser<'_>, msg: &'static str) -> Option<ErrorGuaranteed> {

compiler/rustc_resolve/src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
835835
_ => None,
836836
},
837837
None => self.get_macro(res).map(|macro_data| match kind {
838-
Some(MacroKind::Attr) if let Some(ref ext) = macro_data.attr_ext => ext.clone(),
839-
_ => macro_data.ext.clone(),
838+
Some(MacroKind::Attr) if let Some(ref ext) = macro_data.attr_ext => Arc::clone(ext),
839+
_ => Arc::clone(&macro_data.ext),
840840
}),
841841
};
842842
Ok((ext, res))

0 commit comments

Comments
 (0)