[ty] Remove unsafe salsa::Update implementations in tuple.rs (#19880)

This commit is contained in:
Alex Waygood 2025-08-12 15:53:34 +01:00 committed by GitHub
parent ad28b80f96
commit d76fd103ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -452,19 +452,6 @@ impl<'db> FixedLengthTuple<Type<'db>> {
} }
} }
#[allow(unsafe_code)]
unsafe impl<T> salsa::Update for FixedLengthTuple<T>
where
T: salsa::Update,
{
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
unsafe {
let old_value = &mut *old_pointer;
Box::maybe_update(&raw mut old_value.0, new_value.0)
}
}
}
impl<'db> PyIndex<'db> for &FixedLengthTuple<Type<'db>> { impl<'db> PyIndex<'db> for &FixedLengthTuple<Type<'db>> {
type Item = Type<'db>; type Item = Type<'db>;
@ -847,21 +834,6 @@ impl<'db> VariableLengthTuple<Type<'db>> {
} }
} }
#[allow(unsafe_code)]
unsafe impl<T> salsa::Update for VariableLengthTuple<T>
where
T: salsa::Update,
{
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
let old_value = unsafe { &mut *old_pointer };
let mut changed = false;
changed |= unsafe { Box::maybe_update(&raw mut old_value.prefix, new_value.prefix) };
changed |= unsafe { T::maybe_update(&raw mut old_value.variable, new_value.variable) };
changed |= unsafe { Box::maybe_update(&raw mut old_value.suffix, new_value.suffix) };
changed
}
}
impl<'db> PyIndex<'db> for &VariableLengthTuple<Type<'db>> { impl<'db> PyIndex<'db> for &VariableLengthTuple<Type<'db>> {
type Item = Type<'db>; type Item = Type<'db>;
@ -1149,28 +1121,6 @@ impl<T> From<VariableLengthTuple<T>> for Tuple<T> {
} }
} }
#[allow(unsafe_code)]
unsafe impl<T> salsa::Update for Tuple<T>
where
T: salsa::Update,
{
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
let old_value = unsafe { &mut *old_pointer };
match (old_value, new_value) {
(Tuple::Fixed(old), Tuple::Fixed(new)) => unsafe {
FixedLengthTuple::maybe_update(old, new)
},
(Tuple::Variable(old), Tuple::Variable(new)) => unsafe {
VariableLengthTuple::maybe_update(old, new)
},
(old_value, new_value) => {
*old_value = new_value;
true
}
}
}
}
impl<'db> PyIndex<'db> for &Tuple<Type<'db>> { impl<'db> PyIndex<'db> for &Tuple<Type<'db>> {
type Item = Type<'db>; type Item = Type<'db>;