Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3c1abf4
apply various clippy lint fixes
cyrgani Aug 20, 2026
7705a93
remove some unneeded `format!` uses
cyrgani Aug 20, 2026
e94980b
create the `Box` inside of `combine_substructure`
cyrgani Aug 20, 2026
a572603
split `format_foreign.rs` into actual file modules
cyrgani Aug 20, 2026
2ea3197
inline `is_staged_api_crate`
cyrgani Aug 20, 2026
21c02fb
remove the `RefCell` from `CombineSubstructureFunc`
cyrgani Aug 20, 2026
745b410
simplify large `match`
cyrgani Aug 20, 2026
e899f2c
use `SmallVec` instead of `Vec` in `TraitDef`
cyrgani Aug 20, 2026
f0cfd1d
misc small cleanups and inlinings
cyrgani Aug 20, 2026
be01a09
remove `path_local!`
cyrgani Aug 20, 2026
0b59610
improve usage and naming of `path[vec]_std!`
cyrgani Aug 20, 2026
b84ba04
inline two trivial functions
cyrgani Aug 21, 2026
bd72f7a
Replace `Allocator + Clone` with `AllocatorClone` in btree
maxdexh Aug 24, 2026
c42b90f
Add codegen test for disjunction fed to unreachable_unchecked
zakrad Aug 25, 2026
2686c8c
Don't list escaping bound regions in nested `for<...>` binders of E03…
Rani367 Jul 13, 2026
8432202
clippy::manual_is_ascii_check
ChrisDenton Aug 12, 2026
563b112
clippy::manual_ignore_case_cmp
ChrisDenton Aug 12, 2026
5fa3b60
clippy::manual_hash_one
ChrisDenton Aug 12, 2026
7cf35bd
clippy::excessive_precision
ChrisDenton Aug 12, 2026
abce09f
clippy::partialeq_ne_impl
ChrisDenton Aug 12, 2026
d867667
clippy::manual_contains
ChrisDenton Aug 13, 2026
b6ef1ff
clippy::single_match
ChrisDenton Aug 13, 2026
fd0a93f
clippy::match_as_ref
ChrisDenton Aug 13, 2026
28f78d4
clippy::default_constructed_unit_structs
ChrisDenton Aug 13, 2026
a7f7b19
clippy::redundant_closure
ChrisDenton Aug 13, 2026
097f843
clippy::derivable_impls
ChrisDenton Aug 13, 2026
ff47e67
clippy::partialeq_to_none
ChrisDenton Aug 13, 2026
8523083
clippy::unnecessary_map_or
ChrisDenton Aug 13, 2026
64393eb
clippy::manual_clear
ChrisDenton Aug 13, 2026
30dc431
clippy::bind_instead_of_map
ChrisDenton Aug 13, 2026
5051bc3
clippy::redundant_slicing
ChrisDenton Aug 13, 2026
0348ed1
clippy::transmutes_expressible_as_ptr_casts
ChrisDenton Aug 13, 2026
4dae4ea
clippy::manual_repeat_n
ChrisDenton Aug 13, 2026
d1f1aae
clippy::to_digit_is_some
ChrisDenton Aug 18, 2026
4b68669
clippy::double_must_use
ChrisDenton Aug 18, 2026
7401901
clippy::seek_from_current
ChrisDenton Aug 18, 2026
641b3e5
clippy::mem_replace_option_with_some
ChrisDenton Aug 18, 2026
836a20f
clippy::mem_replace_option_with_none
ChrisDenton Aug 18, 2026
3fba07b
clippy::map_clone
ChrisDenton Aug 18, 2026
610a48e
clippy::declare_interior_mutable_const
ChrisDenton Aug 18, 2026
f591acd
clippy::assign_op_pattern
ChrisDenton Aug 18, 2026
31f7abc
clippy::chunks_exact_to_as_chunks
ChrisDenton Aug 18, 2026
4bed8e2
clippy::needless_raw_string_hashes
ChrisDenton Aug 19, 2026
428739b
clippy::approx_constant
ChrisDenton Aug 19, 2026
af533a1
clippy::neg_cmp_op_on_partial_ord
ChrisDenton Aug 12, 2026
9fa2a10
Ignore clippy failures in stdarch submodule
ChrisDenton Aug 18, 2026
79c0d27
Enforce even more clippy lints in CI
ChrisDenton Aug 18, 2026
4c8eac0
Allow lints on backtrace-rs
ChrisDenton Aug 19, 2026
aa9fe90
ignore clippy::redundant_pattern_matching
ChrisDenton Aug 19, 2026
f29a880
Rollup merge of #161328 - ChrisDenton:clippy3, r=nia-e
JonathanBrouwer Aug 25, 2026
f6d0a0a
Rollup merge of #161684 - maxdexh:smoke-trees, r=nia-e
JonathanBrouwer Aug 25, 2026
894a7f0
Rollup merge of #159232 - Rani367:fix-nested-hrtb-binder-printing, r=…
JonathanBrouwer Aug 25, 2026
9032e91
Rollup merge of #161464 - cyrgani:builtin_macros_clean, r=mati865
JonathanBrouwer Aug 25, 2026
1075403
Rollup merge of #161774 - zakrad:regr-test-115026, r=JonathanBrouwer
JonathanBrouwer Aug 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fn expand_preparsed_asm(
if let Some(pos) = snippet.find(needle) {
let end = pos
+ snippet[pos..]
.find(|c| matches!(c, '\n' | ';' | '\\' | '"'))
.find(['\n', ';', '\\', '"'])
.unwrap_or(snippet[pos..].len() - 1);
let inner = InnerSpan::new(pos, end);
return template_sp.from_inner(inner);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) fn expand_assert<'cx>(
segments: cx
.std_path(&[sym::panic, sym::panic_2021])
.into_iter()
.map(|ident| PathSegment::from_ident(ident))
.map(PathSegment::from_ident)
.collect(),
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
} else {
format!(
"Assertion failed: {escaped_expr_str}\nWith captures:\n{}",
&self.fmt_string
self.fmt_string
)
}),
suffix: None,
Expand Down
48 changes: 21 additions & 27 deletions compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ mod llvm_enzyme {
let lit = x.lit()?;
match lit.kind {
ast::LitKind::Int(x, _) => Some(x.get()),
_ => return None,
_ => None,
}
}

// Get information about the function the macro is applied to
fn extract_item_info(iitem: &Box<ast::Item>) -> Option<(Visibility, FnSig, Ident, Generics)> {
match &iitem.kind {
ItemKind::Fn(ast::Fn { sig, ident, generics, .. }) => {
Some((iitem.vis.clone(), sig.clone(), ident.clone(), generics.clone()))
Some((iitem.vis.clone(), sig.clone(), *ident, generics.clone()))
}
_ => None,
}
Expand Down Expand Up @@ -115,7 +115,7 @@ mod llvm_enzyme {
let mut activities: Vec<DiffActivity> = vec![];
let mut errors = false;
for x in &meta_item[first_activity..] {
let activity_str = name(&x);
let activity_str = name(x);
let res = DiffActivity::from_str(&activity_str);
match res {
Ok(x) => activities.push(x),
Expand Down Expand Up @@ -158,7 +158,7 @@ mod llvm_enzyme {
let val = first_ident(t);
let t = Token::from_ast_ident(val);
ts.push(TokenTree::Token(t, Spacing::Joint));
ts.push(TokenTree::Token(comma.clone(), Spacing::Alone));
ts.push(TokenTree::Token(comma, Spacing::Alone));
}

pub(crate) fn expand_forward(
Expand Down Expand Up @@ -226,13 +226,9 @@ mod llvm_enzyme {
},
Annotatable::AssocItem(assoc_item, _ctxt @ (Impl { of_trait: _ } | Trait)) => {
match &assoc_item.kind {
ast::AssocItemKind::Fn(ast::Fn { sig, ident, generics, .. }) => Some((
assoc_item.vis.clone(),
sig.clone(),
ident.clone(),
generics.clone(),
true,
)),
ast::AssocItemKind::Fn(ast::Fn { sig, ident, generics, .. }) => {
Some((assoc_item.vis.clone(), sig.clone(), *ident, generics.clone(), true))
}
_ => None,
}
}
Expand All @@ -255,7 +251,7 @@ mod llvm_enzyme {
// create TokenStream from vec elemtents:
// meta_item doesn't have a .tokens field
let mut ts: Vec<TokenTree> = vec![];
if meta_item_vec.len() < 1 {
if meta_item_vec.is_empty() {
// At the bare minimum, we need a fnc name.
dcx.emit_err(diagnostics::AutoDiffMissingConfig { span: item.span() });
return vec![item];
Expand Down Expand Up @@ -294,7 +290,7 @@ mod llvm_enzyme {
let t = Token::new(TokenKind::Literal(l), Span::default());
let comma = Token::new(TokenKind::Comma, Span::default());
ts.push(TokenTree::Token(t, Spacing::Joint));
ts.push(TokenTree::Token(comma.clone(), Spacing::Alone));
ts.push(TokenTree::Token(comma, Spacing::Alone));

for t in meta_item_vec.clone()[start_position..].iter() {
meta_item_inner_to_ts(t, &mut ts);
Expand Down Expand Up @@ -474,7 +470,7 @@ mod llvm_enzyme {
}
};

return vec![orig_annotatable, d_annotatable];
vec![orig_annotatable, d_annotatable]
}

// shadow arguments (the extra ones which were not in the original (primal) function), in reverse mode must be
Expand Down Expand Up @@ -519,10 +515,8 @@ mod llvm_enzyme {
.map(|param| {
let ty = match &param.ty.kind {
TyKind::ImplicitSelf => self_ty(),
TyKind::Ref(lt, mt) if matches!(mt.ty.kind, TyKind::ImplicitSelf) => ecx.ty(
span,
TyKind::Ref(lt.clone(), ast::MutTy { ty: self_ty(), mutbl: mt.mutbl }),
),
TyKind::Ref(lt, mt) if matches!(mt.ty.kind, TyKind::ImplicitSelf) => ecx
.ty(span, TyKind::Ref(*lt, ast::MutTy { ty: self_ty(), mutbl: mt.mutbl })),
TyKind::Ptr(mt) if matches!(mt.ty.kind, TyKind::ImplicitSelf) => {
ecx.ty(span, TyKind::Ptr(ast::MutTy { ty: self_ty(), mutbl: mt.mutbl }))
}
Expand Down Expand Up @@ -603,7 +597,7 @@ mod llvm_enzyme {
let anon_const = AnonConst { id: ast::DUMMY_NODE_ID, value: expr };
Some(AngleBracketedArg::Arg(GenericArg::Const(anon_const)))
}
GenericParamKind::Lifetime { .. } => None,
GenericParamKind::Lifetime => None,
})
.collect::<ThinVec<_>>();

Expand Down Expand Up @@ -722,7 +716,7 @@ mod llvm_enzyme {
for i in 0..x.width {
let mut shadow_arg = arg.clone();
// We += into the shadow in reverse mode.
shadow_arg.ty = Box::new(assure_mut_ref(&arg.ty));
*shadow_arg.ty = assure_mut_ref(&arg.ty);
let old_name = if let PatKind::Ident(_, ident, _) = arg.pat.kind {
ident.name
} else {
Expand All @@ -732,11 +726,11 @@ mod llvm_enzyme {
let name: String = format!("d{}_{}", old_name, i);
new_inputs.push(name.clone());
let ident = Ident::from_str_and_span(&name, shadow_arg.pat.span);
shadow_arg.pat = Box::new(ast::Pat {
*shadow_arg.pat = ast::Pat {
id: ast::DUMMY_NODE_ID,
kind: PatKind::Ident(BindingMode::NONE, ident, None),
span: shadow_arg.pat.span,
});
};
d_inputs.push(shadow_arg.clone());
}
}
Expand All @@ -763,11 +757,11 @@ mod llvm_enzyme {
let name: String = format!("b{}_{}", old_name, i);
new_inputs.push(name.clone());
let ident = Ident::from_str_and_span(&name, shadow_arg.pat.span);
shadow_arg.pat = Box::new(ast::Pat {
*shadow_arg.pat = ast::Pat {
id: ast::DUMMY_NODE_ID,
kind: PatKind::Ident(BindingMode::NONE, ident, None),
span: shadow_arg.pat.span,
});
};
d_inputs.push(shadow_arg.clone());
}
}
Expand All @@ -779,7 +773,7 @@ mod llvm_enzyme {
}
}
if let PatKind::Ident(_, ident, _) = arg.pat.kind {
idents.push(ident.clone());
idents.push(ident);
} else {
panic!("not an ident?");
}
Expand Down Expand Up @@ -891,15 +885,15 @@ mod llvm_enzyme {
if act_ret.len() == 1 {
act_ret[0].clone()
} else {
let kind = TyKind::Tup(act_ret.iter().map(|arg| arg.clone()).collect());
let kind = TyKind::Tup(act_ret);
Box::new(rustc_ast::Ty { kind, id: ast::DUMMY_NODE_ID, span })
}
}
};
d_decl.output = FnRetTy::Ty(ret_ty);
}

let mut d_header = sig.header.clone();
let mut d_header = sig.header;
if unsafe_activities {
d_header.safety = rustc_ast::Safety::Unsafe(span);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(super) fn expand_cfg_select<'cx>(
) {
Ok(mut branches) => {
if let Some((selected_tts, selected_span)) = branches.pop_first_match(|cfg| {
matches!(attr::eval_config_entry(&ecx.sess, cfg), EvalConfigResult::True)
matches!(attr::eval_config_entry(ecx.sess, cfg), EvalConfigResult::True)
}) {
let mac = CfgSelectResult {
ecx,
Expand Down
41 changes: 16 additions & 25 deletions compiler/rustc_builtin_macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,34 @@ impl MultiItemModifier for Expander {
MetaItemKind::List(list) => {
list.iter()
.filter_map(|meta_item_inner| match meta_item_inner {
MetaItemInner::MetaItem(meta) => Some(meta),
MetaItemInner::MetaItem(meta) => {
// Reject `#[derive(Debug = "value", Debug(abc))]`, but recover the
// paths.
report_path_args(sess, meta);
Some(DeriveResolution {
path: meta.path.clone(),
item: dummy_annotatable(),
exts: None,
is_const: self.is_const,
})
}
MetaItemInner::Lit(lit) => {
// Reject `#[derive("Debug")]`.
report_unexpected_meta_item_lit(sess, lit);
None
}
})
.map(|meta| {
// Reject `#[derive(Debug = "value", Debug(abc))]`, but recover the
// paths.
report_path_args(sess, meta);
meta.path.clone()
})
.map(|path| DeriveResolution {
path,
item: dummy_annotatable(),
exts: None,
is_const: self.is_const,
})
.collect()
}
_ => vec![],
};

// Do not configure or clone items unless necessary.
match &mut resolutions[..] {
[] => {}
[first, others @ ..] => {
first.item = cfg_eval(
sess,
features,
item.clone(),
ecx.current_expansion.lint_node_id,
);
for other in others {
other.item = first.item.clone();
}
if let [first, others @ ..] = &mut resolutions {
first.item =
cfg_eval(sess, features, item.clone(), ecx.current_expansion.lint_node_id);
for other in others {
other.item = first.item.clone();
}
}

Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ pub(crate) fn expand_deriving_copy(
path: path_std!(marker::Copy),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: Vec::new(),
additional_bounds: SmallVec::new(),
supports_unions: true,
methods: Vec::new(),
associated_types: Vec::new(),
methods: SmallVec::new(),
associated_types: SmallVec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
safety: Safety::Default,
document: true,
};
Expand All @@ -44,12 +43,11 @@ pub(crate) fn expand_deriving_const_param_ty(
path: path_std!(marker::ConstParamTy_),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
additional_bounds: smallvec![ty::Ty::Path(path_std!(cmp::Eq))],
supports_unions: false,
methods: Vec::new(),
associated_types: Vec::new(),
methods: SmallVec::new(),
associated_types: SmallVec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
safety: Safety::Default,
document: true,
};
Expand Down
Loading
Loading