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

Documents reference equality by address (#54197) #54755

Merged
merged 2 commits into from
Oct 12, 2018

Conversation

lucasloisp
Copy link
Contributor

@lucasloisp lucasloisp commented Oct 2, 2018

Clarification of the use of ptr::eq to test equality of references via address by pointer coercion, Fixes #54197 .

The same example as in ptr::eq docs is shown here to clarify that
PartialEq compares values pointed-to instead of via address (which can be desired in some cases)

Clarification of the use of `ptr::eq` to test equality of references
via address by pointer coercion
@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 @aidanhs (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 Oct 2, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.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.

[00:04:37] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:37] tidy error: /checkout/src/libstd/primitive_docs.rs:912: trailing whitespace
[00:04:37] tidy error: /checkout/src/libstd/primitive_docs.rs:914: trailing whitespace
[00:04:37] tidy error: /checkout/src/libstd/primitive_docs.rs:917: trailing whitespace
[00:04:37] tidy error: /checkout/src/libstd/primitive_docs.rs:933: trailing whitespace
[00:04:37] tidy error: /checkout/src/libstd/primitive_docs.rs:940: trailing whitespace
[00:04:38] some tidy checks failed
[00:04:38] 
[00:04:38] 
[00:04:38] 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:38] 
[00:04:38] 
[00:04:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:38] Build completed unsuccessfully in 0:00:47
[00:04:38] Build completed unsuccessfully in 0:00:47
[00:04:38] Makefile:79: recipe for target 'tidy' failed
[00:04:38] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0e5bb186
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:1a6b3ef0:start=1538498791770823448,finish=1538498791776442676,duration=5619228
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04f6b603
$ 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:0d5b4054
travis_time:start:0d5b4054
$ 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:0342a099
$ 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)

@TimNN
Copy link
Contributor

TimNN commented Oct 9, 2018

Thanks for your PR @lucasloisp! You should hear from @aidanhs or some one else soon.

Ping from triage @aidanhs / @rust-lang/docs: This PR requires your review.

/// let other_five_ref = &other_five;
///
/// assert!(five_ref == same_five_ref);
/// assert!(five_ref == other_five_ref);
Copy link
Member

Choose a reason for hiding this comment

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

Usually we want to demonstrate assert_eq!() instead of assert!() when you're asserting equality like this, but i feel like this gets the point across better if you can see the == being used, since we're talking about the use of == versus ptr::eq in the first place. (Just leaving this comment for posterity.)

@QuietMisdreavus
Copy link
Member

This looks great, thanks so much! Sorry for letting this one slip through the cracks.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 9, 2018

📌 Commit 68236e0 has been approved by QuietMisdreavus

@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 Oct 9, 2018
@QuietMisdreavus
Copy link
Member

Oh, one thing before this gets put in. Can you edit the PR description to add the line "Fixes #54197" so GitHub will automatically close it when it's merged?

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 9, 2018
…ss-eq, r=QuietMisdreavus

Documents reference equality by address (rust-lang#54197)

Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion,  regarding issue rust-lang#54197 .

The same example as in `ptr::eq` docs is shown here to clarify that
`PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 10, 2018
…ss-eq, r=QuietMisdreavus

Documents reference equality by address (rust-lang#54197)

Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion,  regarding issue rust-lang#54197 .

The same example as in `ptr::eq` docs is shown here to clarify that
`PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Oct 11, 2018
…ss-eq, r=QuietMisdreavus

Documents reference equality by address (rust-lang#54197)

Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion,  regarding issue rust-lang#54197 .

The same example as in `ptr::eq` docs is shown here to clarify that
`PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
kennytm added a commit to kennytm/rust that referenced this pull request Oct 12, 2018
…ss-eq, r=QuietMisdreavus

Documents reference equality by address (rust-lang#54197)

Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion,  regarding issue rust-lang#54197 .

The same example as in `ptr::eq` docs is shown here to clarify that
`PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
bors added a commit that referenced this pull request Oct 12, 2018
Rollup of 16 pull requests

Successful merges:

 - #54755 (Documents reference equality by address (#54197))
 - #54811 (During rustc bootstrap, make default for `optimize` independent of `debug`)
 - #54825 (NLL says "borrowed content" instead of more precise "dereference of raw pointer")
 - #54860 (Add doc comments about safest way to initialize a vector of zeros)
 - #54869 (Fix mobile docs)
 - #54891 (Fix tracking issue for Once::is_completed)
 - #54913 (doc fix: it's auto traits that make for automatic implementations)
 - #54920 (Fix handling of #[must_use] on unit and uninhabited types)
 - #54932 (A handful of random string-related improvements)
 - #54936 (impl Eq+Hash for TyLayout)
 - #54950 (std: Synchronize global allocator on wasm32)
 - #54956 ("(using ..." doesn't have the matching ")")
 - #54958 (add a macro for static (compile-time) assertions)
 - #54967 (Remove incorrect span for second label inner macro invocation)
 - #54983 (Fix slice's benchmarks)
 - #54989 (Fix spelling in the documentation to htmldocck.py)

Failed merges:

r? @ghost
@bors bors merged commit 68236e0 into rust-lang:master Oct 12, 2018
@lucasloisp lucasloisp deleted the document-reference-address-eq branch October 12, 2018 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

6 participants