-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fallible allocation #48648
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
Fallible allocation #48648
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Kimundi (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I'm thinking if this should be behind a feature gate or not given the RFC was already approved. @Kimundi any idea? |
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.
Looks good!
Got confused by feature gates for new language features there. All new APIs should land as unstable, which automatically gives them the feature gate as written in the unstable attribute. So no extra work is needed, but marking it as a stable directly would be wrong. :)
capacity.checked_mul(size_of_bucket) | ||
.expect("capacity overflow"), | ||
"capacity overflow"); | ||
let size_of_bucket = size_of::<HashUint>().checked_add(size_of::<(K, V)>()) |
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.
You turn a unwrap()
into a return with CollectionAllocErr::CapacityOverflow
here, which I think technically changes the behaviour (or at least the panic message). Is this just a bugfix because this is also technically a capacity overflow?
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.
In my understanding, if bucket allocation size cannot be calculated, it's a sign of capacity overflow
. I don't think there is a regression risk here because the chances of hitting this case are probably very small. There are 2 things that will change here (1) non try_xxxx methods will have a different panic message (empty vs "capacity overflow") (2) the behaviour might change when oom=panic/abort is introduced.
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.
Yeah, makes sense.
|
||
fn main() { | ||
let v = Vec::new(); | ||
v.try_reserve(10); //~ ERROR: attribute is an experimental feature |
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.
This needs to be the error message that the compiler actually outputs. use of unstable library feature "try_reserve" [...]
or something like it.
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.
Thanks, solved!
error[E0658]: the `#[try_reserve]` attribute is an experimental feature | ||
--> $DIR/feature-gate-try_reserve.rs:13:1 | ||
| | ||
LL | #[try_reserve] //~ ERROR: attribute is an experimental feature |
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.
This should also reflect the error gotten from a unstable library feature.
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.
Thanks, solved!
I think this is all we want to do in this PR, I will create a separate one for |
Seems there are still some import issues in the tests. |
r? @Kimundi . Thanks and sorry for all the messed up commits!, I will squash them after your review. |
src/libsyntax/feature_gate.rs
Outdated
@@ -456,6 +456,7 @@ declare_features! ( | |||
|
|||
// Parentheses in patterns | |||
(active, pattern_parentheses, "1.26.0", None), | |||
|
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.
Spurious whitespace
Weird that that failed the tests again... But yeah, feel free to squash :) |
Ok, I'm squashing the changes into one |
Done :). r? @Kimundi |
@bors r+ |
📌 Commit 69c67d6 has been approved by |
⌛ Testing commit 69c67d637065063979405eb6e9a6d2db11159b8a with merge e1bda06a39850023925b8d72aabdc7a56ae13145... |
💔 Test failed - status-travis |
Cannot run
|
a86536f
to
f15bd05
Compare
@bors retry 3 hour timeout |
⌛ Testing commit d4e400407a1c231fcf7f90b020b0e73411a5baec with merge 6319df5ff2bf0c4ef9fb8f95b5c2eae3f237cd90... |
💔 Test failed - status-travis |
Recent UI test changes again has broken UI tests 😠. Please rebase and update
|
4455341
to
06057d9
Compare
@bors r=Kimundi |
📌 Commit 06057d9 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
@snf @Kimundi Is it expected that this PR causes build breakage for some crates? For example mp4parse-rust seems to have stopped building in nightly rust, see https://bugzilla.mozilla.org/show_bug.cgi?id=1446538 |
@staktrace it's because of the conflicting names. I see that Mike commented that #48552 will fix it (and future breakages). |
@snf I don't have any objections but I'm also not the decision maker on this, I just happened to run into the build failure first. Maybe coordinate with the mp4parse-rust owners? |
Implementing RFC#2116 Fallible Allocation .
Work in progress. Initially adding @gankro's try_reserve for Vec.