but it does matter that it’s the type is &mut _ or & _! It’s TBAA done right!
The difference is a bit more subtle than that. As @comex mentioned, and I overlooked, cell types actually could benefit from TBAA.
But more importantly, Rust’s current aliasing rules for references are neither a superset nor a subset of C’s TBAA.
fn foo(bar: &mut T, baz: &mut T) {
In Rust, bar and baz cannot point at the same address
In C, they can point at the same address, and they can be mutably aliased
}
fn foo(bar: &T, baz: &T) {
In Rust, bar and baz can point at the same address, but they can't mutably alias
In C, they can mutably alias
}
fn foo(bar: &T, baz: &U) {
In Rust, bar and baz can point at the same address, but cannot mutably alias
In C, they cannot point at the same address
}
fn foo(bar: &Cell<T>, baz: &Cell<T>) {
In Rust, bar and baz can point at the same address, and can mutably alias
In C, they can also mutably alias
}
fn foo(bar: &Cell<T>, baz: &Cell<U>) {
In Rust, bar and baz can mutably alias
In C, they cannot point at the same address at all
}