-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Investigate representing slices with 3 words, just like vectors #10295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Going further, I am now thinking we should guarantee that |
If On Sat, Nov 9, 2013 at 2:35 PM, Niko Matsakis [email protected]:
|
IIUC |
No, because it would only be 3 words for types like Niko |
How would this interact with trait objects, e.g. given trait Foo {}
impl Foo for [int] {}
impl Foo for int {}
fn main() {
let v = (&[1i,2]) as &Foo;
let w = &1i as &Foo;
} wouldn't |
Afaik, without making trait objects take always 4 words, you just wouldn't be able to make such a trait object (such as is the case today) |
I have been assuming that trait objects can never hide a dynamically sized type in any case. In other words, even if you implement trait |
cc me |
Triage bump, carry on. |
I...think this is basically a settled question now. |
…ious-to-owned, r=Jarcho fix(suspicious_to_owned): use span_suggestions to suggest both intents fixes rust-lang#10294 changelog: [`suspicious_to_owned`]: suggestions now produce valid Rust code
Assuming #8981 is completed (which it looks like it will be), I think we should consider representing slices using 3 words. The goal would be to have an invariant that every instance of the type
~T
has the same representation as&T
, for allT
(in a DST world,T
includes types like[U]
).This would simplify trans, but it would also enable us to write a function like
borrow_all
:The main sticking point is that it would require an extra unused word in slices that takes the place of "capacity" (aka "alloc") for normal vectors. It's unclear what performance impact this would have and presumably merits some investigation.
I envisioned this "deep borrowing" as explicit, though it's conceivable we could integrate this into coercion. But in general I sort of want to remove autocoercion wherever possible.
The text was updated successfully, but these errors were encountered: