This confuses me a bit. [T] is not āunsafeā Rust, right? I guess you mean the various methods that exist (like len()) on [T], which are implemented unsafely? Youāre right that I overlooked those, I considered them part of Rust0 I suppose. =)
Yes, it seems like there are a small number of such functions (similar to len) that are probably a better Rust1 than āaccess to the heapā.
Well, my point was that you can (in Rust0 ā with no unsafe code at all) create a &[T] and dereference into it, like so:
fn foo() {
let x: [i32; 5] = [0, 1, 2, 3, 4];
bar(&x);
}
fn bar(x: &[i32]) {
x[2]
}
Doing this coercion requires implementing the Unsize trait, but that is not unsafe to do. The actual code for performing said coercion is builtin into the core Rust language (Rust0), as is the code for bounds checking and indexing. So it seems to me that you really do have to provide adjacent memory, at least if you want to mirror the current setup. But it seems to me to be a minor point ā and I could imagine some of this code moving out of the compiler, if we ever found a nice way to do it.
Iām confused by a few things here. First, why can you assume T does not contain &mut? Also, how do you address the point I raised in my post: that Rc<T> can be applied to any T, not just T: Clone, and that this cannot be implemented in general without true sharing?
Maybe I donāt really understand your project though =). I guess it is trying to axiomatize a subset of Rust, more than the full Rust language?