-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Phase1 #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of (a ...).as_ref().unwrap_or_else(...)
over &*(a ...)?
Ah, right, none. I just literally forget that you can do that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and I guess Box casts are maybe probably sound due to A and B having compatible Layouts?
While all the unsafe frightens me and threatens to make me spontaniously combust, I'm not seeing any more soundness concerns 👍
@MaulingMonkey there was a request for zeroed boxes without using the stack, so i put that in. |
Co-Authored-By: Daniel Henry-Mantilla <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed new commits... approved pending fix for ZSTs in try_zeroed_box
We could update this to just not allocate in the future but I don't believe that the docs give us assurances in that area.
What about returning |
That puts T::zeroed on the stack, which is exactly what the goal was to avoid. You're the second person to ask that one. Do yall read the doc comments? |
Sorry, I posted a global comment instead of answering to the thread about ZST in |
ahh, hmm, that sounds like a good fix |
#[inline(never)] fn try_zeroed_box_on_stack<T>() -> Box<T> {
Ok(Box::new(T::zeroed()))
} Would help ensure it never gets inlined onto the stack for |
If we only use that for zero sized types it doesn't matter if it is "on the stack" since the size is zero anyway |
Right, I'm just being paranoid about the case where non-executing code isn't fully eliminated (debug builds?), which can still contribute to stack size as I've found out before (last time I overflowed the stack was thanks to conditional logging macros, that had fixed length char buffers for formatting strings... apparently that's enough to blow the stack even when they're not executing....) Or to put it a little more concretely, I'd worry: if size_of::<T>() != 0 {
Ok(Box::new(T::zeroed()))
} else {
...
} Could still put |
TODO: