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 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

@matthewjasper

This comment has been minimized.

Copy link
Contributor Author

matthewjasper commented Feb 25, 2019

@bors try

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 25, 2019

⌛️ Trying commit 58d9280 with merge d7cd765...

bors added a commit that referenced this pull request Feb 25, 2019

Auto merge of #58739 - matthewjasper:more-restrictive-tpb, r=<try>
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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 26, 2019

💥 Test timed out

@matthewjasper

This comment has been minimized.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

@bors retry

@bors

This comment has been minimized.

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

Auto merge of #58739 - matthewjasper:more-restrictive-tpb, r=<try>
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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 26, 2019

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

@matthewjasper

This comment has been minimized.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

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

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented Feb 26, 2019

You have the perms to request one yourself now 🎉

@matthewjasper

This comment was marked as outdated.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

@craterbot run start=master#b57fe74a27590289fd657614b8ad1f3eac8a7ad2
try#d7cd76545183ac4a130654fd5c03b5d3ef1287b2 mode=check-only

@craterbot

This comment was marked as outdated.

Copy link
Collaborator

craterbot commented Feb 26, 2019

🚨 Error: missing end toolchain

🆘 If you have any trouble with Crater please ping @rust-lang/infra!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@matthewjasper

This comment was marked as outdated.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

@craterbot run start=master#b57fe74a27590289fd657614b8ad1f3eac8a7ad2 end=try#d7cd76545183ac4a130654fd5c03b5d3ef1287b2 mode=check-only

@craterbot

This comment was marked as outdated.

Copy link
Collaborator

craterbot commented Feb 26, 2019

👌 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

@matthewjasper

This comment was marked as outdated.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

@craterbot abort pr-58739

@craterbot

This comment was marked as outdated.

Copy link
Collaborator

craterbot commented Feb 26, 2019

🚨 Error: failed to parse the command

🆘 If you have any trouble with Crater please ping @rust-lang/infra!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@matthewjasper

This comment was marked as outdated.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

@craterbot abort name=pr-58739

@craterbot

This comment was marked as outdated.

Copy link
Collaborator

craterbot commented Feb 26, 2019

🗑 Experiment pr-58739 deleted!

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

@matthewjasper

This comment has been minimized.

Copy link
Contributor Author

matthewjasper commented Feb 26, 2019

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

@craterbot

This comment has been minimized.

Copy link
Collaborator

craterbot commented Feb 26, 2019

👌 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

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Apr 4, 2019

⌛️ Testing commit cc5088d with merge 3743762...

bors added a commit that referenced this pull request Apr 4, 2019

Auto merge of #58739 - matthewjasper:more-restrictive-tpb, r=pnkfelix
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

This comment has been minimized.

Copy link
Contributor

bors commented Apr 5, 2019

💔 Test failed - checks-travis

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Apr 5, 2019

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)

@kennytm

This comment has been minimized.

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.

@pnkfelix

This comment has been minimized.

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

This comment has been minimized.

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 referenced this pull request Apr 6, 2019

Merged

Update miri #59755

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Apr 6, 2019

@bors p=8

@matthewjasper

This comment has been minimized.

Copy link
Contributor Author

matthewjasper commented Apr 7, 2019

@bors r=pnkfelix

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Apr 7, 2019

📌 Commit cc5088d has been approved by pnkfelix

@bors

This comment has been minimized.

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

Auto merge of #58739 - matthewjasper:more-restrictive-tpb, r=pnkfelix
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

This comment has been minimized.

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 label Apr 7, 2019

@bors bors merged commit cc5088d into rust-lang:master Apr 7, 2019

1 check passed

homu Test successful
Details

@matthewjasper matthewjasper deleted the matthewjasper:more-restrictive-tpb branch Apr 7, 2019

@pnkfelix

This comment has been minimized.

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

Auto merge of #6829 - ehuss:fix-mutable-borrow, r=alexcrichton
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
You can’t perform that action at this time.