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

Stabilise weak_ptr_eq #61797

Merged
merged 2 commits into from
Sep 15, 2019
Merged

Stabilise weak_ptr_eq #61797

merged 2 commits into from
Sep 15, 2019

Conversation

Thomasdezeeuw
Copy link
Contributor

Implemented in #55987.

Closes #55981.

@rust-highfive
Copy link
Collaborator

r? @kennytm

(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 Jun 13, 2019
@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:0422dee9:start=1560421574970719878,finish=1560421575726646528,duration=755926650
$ 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
---
travis_time:start:tidy
tidy check
[00:04:44] * 576 error codes
[00:04:44] * highest error code: E0731
[00:04:46] tidy error: /checkout/src/liballoc/rc.rs:1545: malformed stability attribute: missing the `since` key
[00:04:46] tidy error: /checkout/src/liballoc/sync.rs:1379: malformed stability attribute: missing the `since` key
[00:04:49] some tidy checks failed
[00:04:49] 
[00:04:49] 
[00:04:49] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:49] 
[00:04:49] 
[00:04:49] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:49] Build completed unsuccessfully in 0:01:13

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)

@Thomasdezeeuw
Copy link
Contributor Author

I think the failure is unrelated to this pr.

@jonas-schievink jonas-schievink added the relnotes Marks issues that should be documented in the release notes of the next release. label Jun 13, 2019
@jonas-schievink jonas-schievink added this to the 1.37 milestone Jun 13, 2019
src/liballoc/rc.rs Outdated Show resolved Hide resolved
@jonas-schievink jonas-schievink added the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Jun 13, 2019
@Centril Centril added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 13, 2019
@chpio
Copy link
Contributor

chpio commented Jun 13, 2019

Can we first change the method into a normal method (taking &self) instead of an associated function (taking this: &Self)?

@bors
Copy link
Contributor

bors commented Jun 18, 2019

☔ The latest upstream changes (presumably #61915) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril Centril modified the milestones: 1.37, 1.38 Jul 2, 2019
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 10, 2019
@Centril
Copy link
Contributor

Centril commented Jul 30, 2019

r? @sfackler

cc @RalfJung, I'd appreciate a review from you also :)

@Centril Centril assigned sfackler and unassigned kennytm Jul 30, 2019
@RalfJung
Copy link
Member

There's not much code to look at, that seems fine. ;)

The docs could be improved though IMO. It first says "Returns true if the two Weaks point to the same value" only to later (in a separate subsection!) note that it also works for Weak::new that do not point to any value -- which seems to contradict the first statement. And moreover, there is no mention of what happens when comparing a Weak that is "dangling" in the sense that upgrade would fail -- there's no value in that case either.

I think Rc::ptr_eq's doc is similarly confusing. I'd argue e.g. that "5" and "5" are the same value, and still the doctest has assert!(!Rc::ptr_eq(&five, &other_five)). Actually it seems like the entire Rc docs use "value" as word for "RcBox instance". IMO that's a very bad choice of words as Rust already uses the same term for a very different meaning.

A better term might be "reference-counted object".

@Thomasdezeeuw
Copy link
Contributor Author

@RalfJung

The docs could be improved though IMO. It first says "Returns true if the two Weaks point to the same value" only to later (in a separate subsection!) note that it also works for Weak::new that do not point to any value -- which seems to contradict the first statement. And moreover, there is no mention of what happens when comparing a Weak that is "dangling" in the sense that upgrade would fail -- there's no value in that case either.

I mostly copied the documentation from Rc::ptr_eq, which always points to a value to the "dangling" case didn't apply there. For Weak I've added the notes section for this. However you did leave a fairly important part of the docs out in your comment, it says:

Returns true if the two Weaks point to the same value (not just values that compare as equal).

(emphasis mine)

The part in between brackets is arguably the most important part, maybe that should be moved to the forefront of the sentence more.

I think Rc::ptr_eq's doc is similarly confusing. I'd argue e.g. that "5" and "5" are the same value, and still the doctest has assert!(!Rc::ptr_eq(&five, &other_five)). Actually it seems like the entire Rc docs use "value" as word for "RcBox instance". IMO that's a very bad choice of words as Rust already uses the same term for a very different meaning.

I agree with this, what do you suggest as concrete improvement?

@RalfJung
Copy link
Member

However you did leave a fairly important part of the docs out in your comment, it says:

That was deliberate; as I explained above, values that "compare equal but are not the same" is an odd concept. It indicates that the mathematical integer value "5" might have more to its "identity" that the fact that it is 5? Or maybe integers have provenance?

I know what the text means, but I don't think the parenthetical helps. This is the old problem of comparing values vs. comparing locations (addresses) that hold values, except that it uses exactly the wrong term for what this code really does.

@Thomasdezeeuw
Copy link
Contributor Author

I agree with your point. What terminology should be used instead? Should "values" not be mentioned at all perhaps and only talk of pointers? I'm really looking for some concrete documentation changes and any help here would be appreciated.

@RalfJung
Copy link
Member

what do you suggest as concrete improvement?

strawman proposal: "reference-counted object".

@RalfJung
Copy link
Member

Alternatively we could be talking about comparing things "by their address", as we do in ptr::eq. But then the question remains "the address of what", and that's where something like "reference-counted object" would come up again.

@Thomasdezeeuw
Copy link
Contributor Author

@RalfJung what do you think about the following?

    /// Returns `true` if the address of the two reference counted objects (the
    /// `Weaks`) are equal.
    ///
    /// # Notes
    ///
    /// Since this compares addresses it means that `Weak::new()` will always
    /// equal each other.

Also do you want me to make the change to Arc::ptr_eq and Rc::ptr_eq as well?

@RalfJung
Copy link
Member

RalfJung commented Aug 8, 2019

The parenthetical is odd -- the object itself isn't weak, only the reference is.

Also do you want me to make the change to Arc::ptr_eq and Rc::ptr_eq as well?

Yes, this should be done consistently.

@rfcbot
Copy link

rfcbot commented Aug 24, 2019

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Aug 24, 2019
@SimonSapin
Copy link
Contributor

Is the Weak::new question resolved?

@RalfJung
Copy link
Member

The edit I suggested at #61797 (comment) is still outstanding.

@Thomasdezeeuw
Copy link
Contributor Author

I've just messed up this branch, will fix it asap.

@Thomasdezeeuw
Copy link
Contributor Author

I've just rebased on master, update the stable attribute to 1.39 and added the doc changes as requested by @RalfJung.

@Thomasdezeeuw
Copy link
Contributor Author

@SimonSapin I think the Weak::new() question is resolved with the documentation and examples.

Copy link
Member

@RalfJung RalfJung 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: Docs look good enough for me (the entire Rc/Arc "value" terminology could be improved but that's a separate issue).

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 4, 2019
@rfcbot
Copy link

rfcbot commented Sep 4, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Sep 14, 2019
@rfcbot
Copy link

rfcbot commented Sep 14, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@Centril Centril removed I-nominated needs-fcp This change is insta-stable, so needs a completed FCP to proceed. labels Sep 14, 2019
@Centril
Copy link
Contributor

Centril commented Sep 14, 2019

@bors r=RalfJung rollup

@bors
Copy link
Contributor

bors commented Sep 14, 2019

📌 Commit 307804a has been approved by RalfJung

@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-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Sep 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
bors added a commit that referenced this pull request Sep 14, 2019
Rollup of 4 pull requests

Successful merges:

 - #61797 (Stabilise weak_ptr_eq)
 - #64290 (Provide a span if main function is not present in crate)
 - #64406 (Ban non-extern rust intrinsics)
 - #64462 (feature_gate: Remove dead code from attribute checking)

Failed merges:

r? @ghost
@bors bors merged commit 307804a into rust-lang:master Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. relnotes Marks issues that should be documented in the release notes of the next release. 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.

Tracking issue for weak_ptr_eq