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

Rename .cap() methods to .capacity() #60340

Merged
merged 2 commits into from
Jul 25, 2019
Merged

Conversation

mgeier
Copy link
Contributor

@mgeier mgeier commented Apr 27, 2019

As mentioned in #60316, there are a few .cap() methods, which seem out-of-place because such methods are called .capacity() in the rest of the code.

This PR renames them to .capacity() but leaves RawVec::cap() in there for backwards compatibility.

I didn't try to mark the old version as "deprecated", because I guess this would cause too much noise.

@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 27, 2019
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@mgeier mgeier force-pushed the cap-vs-capacity branch 2 times, most recently from c8b7629 to 4d5a405 Compare April 27, 2019 19:59
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:027a071e:start=1556396909133286972,finish=1556396909921163385,duration=787876413
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:04:23]    Compiling hashbrown v0.3.0
[00:04:30] error: method is never used: `cap`
[00:04:30]    --> src/libstd/sync/mpsc/sync.rs:479:5
[00:04:30]     |
[00:04:30] 479 |     fn cap(&self) -> usize { self.capacity() }  // For backwards compatibility
[00:04:30]     |
[00:04:30]     = note: `-D dead-code` implied by `-D warnings`
[00:04:30] 
[00:04:30] error: aborting due to previous error
---
travis_time:end:335d9f1b:start=1556397191938661426,finish=1556397191944353508,duration=5692082
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04fdf1c0
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1a9bf30d
travis_time:start:1a9bf30d
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:07f090c2
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

... but leave the old names in there for backwards compatibility.
@mgeier
Copy link
Contributor Author

mgeier commented Apr 28, 2019

Turns out that VecDeque<T> has both methods at the same time: a (public) .capacity() and a (private) .cap() (latter always returns 1 more than former). This is a bit confusing, and probably a potential source for bugs within the implementation.

@Mark-Simulacrum
Copy link
Member

r? @alexcrichton

We don't need to keep the cap method on RawVec around; RawVec is a private internal type so there's no need to preserve compatibility.

I'm uncertain what to do about the VecDeque double-method (i.e., capacity and cap); I suspect better naming for the internal method might be in order, but it's hard to say exactly what the right approach there is.

if mem::size_of::<T>() == 0 {
!0
} else {
self.cap
}
}

// For backwards compatibility
#[inline(always)]
Copy link
Member

Choose a reason for hiding this comment

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

Instead of #[inline(always)] could this be #[doc(hidden)] and #[rustc_deprecated]?

Copy link
Contributor Author

@mgeier mgeier May 21, 2019

Choose a reason for hiding this comment

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

In case you are asking me: I'm a total Rust newbie, and I don't know what should be used here.

Just tell me, and I can change the PR. Or feel free to make any changes yourself.

@Mark-Simulacrum mentioned that RawVec is a private internal type and we don't need to keep compatibility?

@alexcrichton
Copy link
Member

Seems reasonable to me! Just one nit otherwise r=me

@mgeier
Copy link
Contributor Author

mgeier commented May 21, 2019

Thanks @alexcrichton for the review!

What about the private method VecDeque::cap()?
Shall we rename it to something less ambiguous?

@alexcrichton
Copy link
Member

I don't personally have a preference one way or another.

@Dylan-DPC-zz Dylan-DPC-zz 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 Jun 3, 2019
@Dylan-DPC-zz
Copy link

ping from triage @mgeier any updates on this?

@jonas-schievink
Copy link
Contributor

Visiting for triage, @mgeier can you address the review comment?

@mgeier
Copy link
Contributor Author

mgeier commented Jun 25, 2019

Sorry for the long delay!

I've removed RawVec::cap() in abe3bdf, as suggested in #60340 (comment).

I couldn't come up with a better name for the internal function VecDeque::cap(), so I've left that unchanged.

@alexcrichton
Copy link
Member

@bors: r+

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 26, 2019
@Centril
Copy link
Contributor

Centril commented Jun 26, 2019

@bors rollup=never

@joelpalmer
Copy link

Hi @mgeier - ping from Triage. Closing due to inactivity. Please re-open before pushing changes. Thanks for the PR.

@rustbot modify labels to +S-inactive-closed, -S-waiting-on-author

@rustbot rustbot added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 22, 2019
@Dylan-DPC-zz
Copy link

Dylan-DPC-zz commented Jul 22, 2019

@joelpalmer this failed because of another PR in the rollup (check #60340 (comment)) so let's keep it open

oops we can close it due to inactivity

@mgeier
Copy link
Contributor Author

mgeier commented Jul 22, 2019

@joelpalmer

I have made the requested changes and reported the latest status in #60340 (comment).

What is there left to do for me?

@Dylan-DPC-zz
Copy link

@mgeier you need to address the failing tests

@Dylan-DPC-zz Dylan-DPC-zz reopened this Jul 22, 2019
@mgeier
Copy link
Contributor Author

mgeier commented Jul 24, 2019

Thanks @Dylan-DPC, can you please point me to the failing tests?

@Dylan-DPC-zz
Copy link

@mgeier looks to have been due to a spurious issue.

@alexcrichton can you review this?

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. labels Jul 24, 2019
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jul 25, 2019

📌 Commit abe3bdf has been approved by alexcrichton

@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 Jul 25, 2019
@bors
Copy link
Contributor

bors commented Jul 25, 2019

⌛ Testing commit abe3bdf with merge 890881f...

bors added a commit that referenced this pull request Jul 25, 2019
Rename .cap() methods to .capacity()

As mentioned in #60316, there are a few `.cap()` methods, which seem out-of-place because such methods are called `.capacity()` in the rest of the code.

This PR renames them to `.capacity()` but leaves `RawVec::cap()` in there for backwards compatibility.

I didn't try to mark the old version as "deprecated", because I guess this would cause too much noise.
@bors
Copy link
Contributor

bors commented Jul 25, 2019

☀️ Test successful - checks-azure
Approved by: alexcrichton
Pushing 890881f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 25, 2019
@bors bors merged commit abe3bdf into rust-lang:master Jul 25, 2019
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #60340!

Tested on commit 890881f.
Direct link to PR: #60340

💔 rustfmt on windows: test-pass → build-fail (cc @topecongiro, @rust-lang/infra).
💔 rustfmt on linux: test-pass → build-fail (cc @topecongiro, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jul 25, 2019
Tested on commit rust-lang/rust@890881f.
Direct link to PR: <rust-lang/rust#60340>

💔 rustfmt on windows: test-pass → build-fail (cc @topecongiro, @rust-lang/infra).
💔 rustfmt on linux: test-pass → build-fail (cc @topecongiro, @rust-lang/infra).
@mgeier mgeier deleted the cap-vs-capacity branch August 6, 2019 15:34
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.