Skip to content
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

Trying to shrink_to greater than capacity should be no-op #81335

Merged
merged 1 commit into from
Jan 27, 2021
Merged

Trying to shrink_to greater than capacity should be no-op #81335

merged 1 commit into from
Jan 27, 2021

Conversation

thomwiggers
Copy link
Contributor

@thomwiggers thomwiggers commented Jan 24, 2021

Per the discussion in #56431, shrink_to shouldn't panic if you try to make a vector shrink to a capacity greater than its current capacity.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 24, 2021
@thomwiggers thomwiggers changed the title Trying to shrink_to smaller than capacity should be no-op Trying to shrink_to greater than capacity should be no-op Jan 24, 2021
@jyn514 jyn514 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jan 24, 2021
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.channel         := nightly
configure: rust.debug-assertions := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
skip untracked path cpu-usage.csv during rustfmt invocations
skip untracked path src/doc/book/ during rustfmt invocations
skip untracked path src/doc/rust-by-example/ during rustfmt invocations
skip untracked path src/llvm-project/ during rustfmt invocations
Diff in /checkout/library/alloc/src/collections/vec_deque/mod.rs at line 781:
     pub fn shrink_to(&mut self, min_capacity: usize) {
         // We don't have to worry about an overflow as neither `self.len()` nor `self.capacity()` can ever be `usize::MAX`:
         let min_capacity = cmp::min(min_capacity, self.capacity());
-        let target_cap = cmp::max(
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/library/alloc/src/collections/vec_deque/mod.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
-            cmp::max(min_capacity, self.len()) + 1,
-            MINIMUM_CAPACITY + 1,
-        )
-        .next_power_of_two();
+        let target_cap = cmp::max(cmp::max(min_capacity, self.len()) + 1, MINIMUM_CAPACITY + 1)
+            .next_power_of_two();
 
         if target_cap < self.cap() {
             // There are three cases of interest:
Build completed unsuccessfully in 0:00:20

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with comment restored and commits squashed

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 26, 2021
@thomwiggers
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 26, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Jan 27, 2021

📌 Commit d069c58 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 27, 2021
@Aaron1011
Copy link
Member

@bors retry

@bors
Copy link
Contributor

bors commented Jan 27, 2021

⌛ Testing commit d069c58 with merge a2f8f62...

@bors
Copy link
Contributor

bors commented Jan 27, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing a2f8f62 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 27, 2021
@bors bors merged commit a2f8f62 into rust-lang:master Jan 27, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants