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

More restrictive 2 phase borrows - take 2 #58739

Merged
merged 10 commits into from
Apr 7, 2019

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented Feb 25, 2019

Signal lint diagnostic mutable_borrow_reservation_conflict when borrow-check finds a 2-phase borrow's reservation overlapping with a shared borrow.

(pnkfelix updated description)

cc #56254 , #59159

blocks PR #59114

r? @pnkfelix

cc @RalfJung @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 25, 2019
@matthewjasper
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Feb 25, 2019

⌛ Trying commit 58d9280 with merge d7cd76545183ac4a130654fd5c03b5d3ef1287b2...

@bors
Copy link
Contributor

bors commented Feb 26, 2019

💥 Test timed out

@matthewjasper
Copy link
Contributor Author

@bors retry

@bors
Copy link
Contributor

bors commented Feb 26, 2019

⌛ Trying commit 58d9280 with merge 684d1bd...

bors added a commit that referenced this pull request Feb 26, 2019
More restrictive 2 phase borrows - take 2

Another try at this. Currently changes to a hard error, but we probably want to change it to a lint instead.

cc #56254

r? @pnkfelix

cc @RalfJung @nikomatsakis
@bors
Copy link
Contributor

bors commented Feb 26, 2019

☀️ Test successful - checks-travis
State: approved= try=True

@matthewjasper
Copy link
Contributor Author

@rust-lang/infra can this have a check only crater run?

@pietroalbini
Copy link
Member

You have the perms to request one yourself now 🎉

@matthewjasper

This comment has been minimized.

@craterbot

This comment has been minimized.

@matthewjasper

This comment has been minimized.

@craterbot

This comment has been minimized.

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2019
@matthewjasper

This comment has been minimized.

@craterbot

This comment has been minimized.

@matthewjasper

This comment has been minimized.

@craterbot

This comment has been minimized.

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Feb 26, 2019
@matthewjasper
Copy link
Contributor Author

@craterbot run start=master#fb162e69449b423c5aed0d9c39f6c046fa300c30 end=try#684d1bdaca93437778609f08a04ce6e7e30a894f mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-58739 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2019
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 4, 2019
@bors
Copy link
Contributor

bors commented Apr 4, 2019

⌛ Testing commit cc5088d with merge 3743762f9e7a8307dba17e384bb055948b7fce94...

@bors
Copy link
Contributor

bors commented Apr 5, 2019

💔 Test failed - checks-travis

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-tools 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.
[01:29:01] +For more information about this error, try `rustc --explain E0502`.
[01:29:01] +
[01:29:01] 
[01:29:01] The actual stderr differed from the expected stderr.
[01:29:01] Actual stderr saved to /tmp/compiletest6tBQI2/2phase.stderr
[01:29:01] To update references, run this command from build directory:
[01:29:01] tests/run-pass/update-references.sh '/tmp/compiletest6tBQI2' '2phase.rs'
[01:29:01] error: 1 errors occurred comparing output.
[01:29:01] status: exit code: 1
[01:29:01] status: exit code: 1
[01:29:01] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/miri" "tests/run-pass/2phase.rs" "-L" "/tmp/compiletest6tBQI2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletest6tBQI2/2phase.stage-id" "-Dwarnings" "-Dunused" "--edition" "2018" "-L" "/tmp/compiletest6tBQI2/2phase.stage-id.aux" "-A" "unused"
[01:29:01] ------------------------------------------
[01:29:01] 
[01:29:01] ------------------------------------------
[01:29:01] stderr:
[01:29:01] stderr:
[01:29:01] ------------------------------------------
[01:29:01] {"message":"cannot borrow `x` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"tests/run-pass/2phase.rs","byte_start":844,"byte_end":845,"line_start":57,"line_end":57,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    x","highlight_start":5,"highlight_end":6}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"tests/run-pass/2phase.rs","byte_start":836,"byte_end":838,"line_start":56,"line_end":56,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let l = &x;","highlight_start":13,"highlight_end":15}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"tests/run-pass/2phase.rs","byte_start":904,"byte_end":905,"line_start":60,"line_end":60,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"            l.set(4);","highlight_start":13,"highlight_end":14}],"label":"immutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable\n  --> tests/run-pass/2phase.rs:57:5\n   |\n56 |     let l = &x;\n   |             -- immutable borrow occurs here\n57 |     x\n   |     ^ mutable borrow occurs here\n...\n60 |             l.set(4);\n   |             - immutable borrow later used here\n\n"}
[01:29:01] {"message":"For more information about this error, try `rustc --explain E0502`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0502`.\n"}
[01:29:01] 
[01:29:01] ------------------------------------------
[01:29:01] 
---
travis_time:end:1166d5a6:start=1554425823725180590,finish=1554425823731849153,duration=6668563
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00154c38
$ 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:09eca82e
travis_time:start:09eca82e
$ 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:20d28c16
$ 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)

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

kennytm commented Apr 5, 2019

@bors r-

This has changed the UI output of miri's run-pass/2phase.rs test, causing it to degrade from "test-pass" to "test-fail". As the week before beta release, toolstate regression is prohibited. We need to either update miri again or wait until next week.

@bors bors 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 Apr 5, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Apr 6, 2019

(i wish I had pushed harder for us to land this code with the lint set to default allow (and then focus on just backporting a change to that lint’s default))

@Centril
Copy link
Contributor

Centril commented Apr 6, 2019

We should not wait a week for this. I would prefer to update miri again. If it comes to it and we cannot, then we should introduce an exception which accepts a breakage specifically for miri.

cc @RalfJung @oli-obk -- hopefully y'all can update miri and we shouldn't have to pick between bad choices...

@Centril Centril mentioned this pull request Apr 6, 2019
@Centril
Copy link
Contributor

Centril commented Apr 6, 2019

@bors p=8

@matthewjasper
Copy link
Contributor Author

@bors r=pnkfelix

@bors
Copy link
Contributor

bors commented Apr 7, 2019

📌 Commit cc5088d has been approved by pnkfelix

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 7, 2019
@bors
Copy link
Contributor

bors commented Apr 7, 2019

⌛ Testing commit cc5088d with merge dec0a98...

bors added a commit that referenced this pull request Apr 7, 2019
More restrictive 2 phase borrows - take 2

Signal lint diagnostic `mutable_borrow_reservation_conflict` when borrow-check finds a 2-phase borrow's reservation overlapping with a shared borrow.

(pnkfelix updated description)

cc #56254 , #59159

blocks PR #59114

r? @pnkfelix

cc @RalfJung @nikomatsakis
@bors
Copy link
Contributor

bors commented Apr 7, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: pnkfelix
Pushing dec0a98 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 7, 2019
@bors bors merged commit cc5088d into rust-lang:master Apr 7, 2019
@matthewjasper matthewjasper deleted the more-restrictive-tpb branch April 7, 2019 06:40
@pnkfelix
Copy link
Member

pnkfelix commented Apr 8, 2019

(I'm deliberately not nominating this for beta, due to particularities of how the timing has worked out; it has now landed in nightly, so it will get folded into the beta naturally when the beta-next is cut sometime during the next day or so, and I do not think this change warrants a nomination for beta->stable backport.)

bors added a commit to rust-lang/cargo that referenced this pull request Apr 8, 2019
Fix mutable_borrow_reservation_conflict warning.

nightly-2019-04-08 added a more restrictive borrowing rule (rust-lang/rust#58739).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) 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. 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-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.