Skip to content

Commit a75cc61

Browse files
author
Lukas Markeffsky
committed
intern valtrees
1 parent 3a0b1ae commit a75cc61

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clippy_lints/src/non_copy_const.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ impl<'tcx> NonCopyConst<'tcx> {
179179
}
180180

181181
fn is_value_unfrozen_raw_inner(cx: &LateContext<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> bool {
182-
// No branch that we check (yet) should continue if val isn't a ValTree::Branch
183-
let ty::ValTree::Branch(val) = val else { return false };
182+
// No branch that we check (yet) should continue if val isn't a branch
183+
let Some(val) = val.try_to_branch() else { return false };
184184
match *ty.kind() {
185185
// the fact that we have to dig into every structs to search enums
186186
// leads us to the point checking `UnsafeCell` directly is the only option.
@@ -192,9 +192,10 @@ impl<'tcx> NonCopyConst<'tcx> {
192192
.iter()
193193
.any(|field| Self::is_value_unfrozen_raw_inner(cx, *field, ty)),
194194
ty::Adt(def, args) if def.is_enum() => {
195-
let Some((&ty::ValTree::Leaf(variant_index), fields)) = val.split_first() else {
195+
let Some((&variant_valtree, fields)) = val.split_first() else {
196196
return false;
197197
};
198+
let variant_index = variant_valtree.unwrap_leaf();
198199
let variant_index = VariantIdx::from_u32(variant_index.to_u32());
199200
fields
200201
.iter()

0 commit comments

Comments
 (0)