-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Minor changes to IndexVec::ensure_contains_elem
& related methods
#110451
Conversation
This comment has been minimized.
This comment has been minimized.
cd957ca
to
6763e98
Compare
compiler/rustc_index/src/vec.rs
Outdated
} | ||
|
||
#[inline] | ||
pub fn remove(&mut self, index: I) -> Option<T> { | ||
self.ensure_contains_elem(index, || None); | ||
self[index].take() | ||
self.get_mut(index).map(Option::take).unwrap_or(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.
self.get_mut(index).map(Option::take).unwrap_or(None) | |
self.get_mut(index)?.take() |
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.
Agreed, ?
looks much nicer than two combinators here.
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.
r=me, preferably with kadiwa's suggestion.
let min_new_len = elem.index() + 1; | ||
if self.len() < min_new_len { | ||
self.raw.resize_with(min_new_len, fill_value); | ||
} | ||
|
||
&mut self[elem] |
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.
Very nice change!
compiler/rustc_index/src/vec.rs
Outdated
} | ||
|
||
#[inline] | ||
pub fn remove(&mut self, index: I) -> Option<T> { | ||
self.ensure_contains_elem(index, || None); | ||
self[index].take() | ||
self.get_mut(index).map(Option::take).unwrap_or(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.
Agreed, ?
looks much nicer than two combinators here.
6763e98
to
bd1dfce
Compare
@bors r=scottmcm rollup |
@bors ping |
😪 I'm awake I'm awake |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#110432 (Report more detailed reason why `Index` impl is not satisfied) - rust-lang#110451 (Minor changes to `IndexVec::ensure_contains_elem` & related methods) - rust-lang#110476 (Delay a good path bug on drop for `TypeErrCtxt` (instead of a regular delayed bug)) - rust-lang#110498 (Switch to `EarlyBinder` for `collect_return_position_impl_trait_in_trait_tys`) - rust-lang#110507 (boostrap: print output during building tools) - rust-lang#110510 (Fix ICE for transmutability in candidate assembly) - rust-lang#110513 (make `non_upper_case_globals` lint not report trait impls) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…, r=scottmcm Small style improvement in `gvn.rs` Allowed by rust-lang#110451 (comment). :P r? `@scottmcm`
…, r=scottmcm Small style improvement in `gvn.rs` Allowed by rust-lang#110451 (comment). :P r? ``@scottmcm``
…, r=scottmcm Small style improvement in `gvn.rs` Allowed by rust-lang#110451 (comment). :P r? ```@scottmcm```
Rollup merge of rust-lang#126392 - WaffleLapkin:gvn-style-ish-changes, r=scottmcm Small style improvement in `gvn.rs` Allowed by rust-lang#110451 (comment). :P r? ``@scottmcm``
Small style improvement in `gvn.rs` Allowed by rust-lang/rust#110451 (comment). :P r? ``@scottmcm``
r? @scottmcm