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

stop considering location when computing outlives relationships #50593

Merged
merged 10 commits into from
May 18, 2018

Conversation

nikomatsakis
Copy link
Contributor

This doesn't (yet?) use SEME regions, but it does ignore the location for outlives constraints. This makes (I believe) NLL significantly faster -- but we should do some benchmarks. It regresses the "get-default" family of use cases for NLL, which is a shame, but keeps the other benefits, and thus represents a decent step forward.

r? @pnkfelix

Instead of tracking the "cause" of each bit that gets added, try to
recover that by walking outlives relationships. This is currently
imprecise, since it ignores the "point" where the outlives relationship
is incurred -- but that's ok, since we're about to stop considering that
overall in a later commit. This does seem to affect one error message
negatively, I didn't dig *too* hard to find out why.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 10, 2018
@nikomatsakis
Copy link
Contributor Author

I confess I've not fully run the tests locally btw, and certainly not since rebasing, so we'll see what Travis thinks. =) But at least src/test/ui --test-args nll was passing for a while.

@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented May 10, 2018

⌛ Trying commit 434d59a with merge 121e57e...

bors added a commit that referenced this pull request May 10, 2018
stop considering location when computing outlives relationships

This doesn't (yet?) use SEME regions, but it does ignore the location for outlives constraints. This makes (I believe) NLL significantly faster -- but we should do some benchmarks. It regresses the "get-default" family of use cases for NLL, which is a shame, but keeps the other benefits, and thus represents a decent step forward.

r? @pnkfelix
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:05:11] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:11] tidy error: /checkout/src/librustc_mir/borrow_check/nll/region_infer/mod.rs:844: line longer than 100 chars
[00:05:11] tidy error: /checkout/src/librustc_mir/borrow_check/nll/region_infer/values.rs:236: line longer than 100 chars
[00:05:13] some tidy checks failed
[00:05:13] 
[00:05:13] 
[00:05:13] 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:05:13] 
[00:05:13] 
[00:05:13] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:13] Build completed unsuccessfully in 0:02:12
[00:05:13] Build completed unsuccessfully in 0:02:12
[00:05:13] Makefile:79: recipe for target 'tidy' failed
[00:05:13] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0d94e020
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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
Copy link
Contributor

bors commented May 10, 2018

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

@nikomatsakis
Copy link
Contributor Author

@Mark-Simulacrum you gonna do a perf run?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:46:28] ....................................................................................................
[00:46:34] ....................................................................................................
[00:46:41] ....................................................................................................
[00:46:47] ....................................................................................................
[00:46:54] ..........................................i.........................................F...............
[00:47:06] .....................................ii.............................................................
[00:47:13] ....................................................................................................
[00:47:19] .................i....................................................................
[00:47:19] failures:
[00:47:19] failures:
[00:47:19] 
[00:47:19] ---- [ui (nll)] ui/nll/get_default.rs stdout ----
[00:47:19]  diff of stderr:
[00:47:19] 
[00:47:19] 4 LL |         match map.get() {
[00:47:19] 5    |               --- immutable borrow occurs here
[00:47:19] 6 ...
[00:47:19] - LL |                 map.set(String::new()); // Just AST errors here
[00:47:19] + LL |                 map.set(String::new()); // Ideally, this would not error.
[00:47:19] 8    |                 ^^^ mutable borrow occurs here
[00:47:19] 9 ...
[00:47:19] 10 LL | }
[00:47:19] 
[00:47:19] 11    | - immutable borrow ends he^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[00:47:19] +    |
[00:47:19] + note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...
[00:47:19] +   --> $DIR/get_default.rs:26:1
[00:47:19] +    |
[00:47:19] + LL | / fn ok(map: &mut Map) -> &String {
[00:47:19] + LL | |     loop {
[00:47:19] + LL | |         match map.get() {
[00:47:19] + LL | |             Some(v) => {
[00:47:19] + ...  |
[00:47:19] + LL | |     }
[00:47:19] + LL | | }
[00:47:19] + 
[00:47:19] + 
[00:47:19] + error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
[00:47:19] +   --> $DIR/get_default.rs:45:17
[00:47:19] +    |
[00:47:19] + LL |         match map.get() {
[00:47:19] +    |               --- immutable borrow occurs here
[00:47:19] 42 LL |             Some(v) => {
[00:47:19] 43 LL |                 map.set(String::new()); // Both AST and MIR error here
[00:47:19] 44    |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[00:47:19] 
[00:47:19] 46 LL |                 return v;
[00:47:19] 47    |                        - borrow later used here
[00:47:19] - error: aborting due to 4 previous errors
[00:47:19] - error: aborting due to 4 previous errors
[00:47:19] + error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
[00:47:19] +   --> $DIR/get_default.rs:51:17
[00:47:19] +    |
[00:47:19] + LL |         match map.get() {
[00:47:19] +    |               --- immutable borrow occurs here
[00:47:19] + ...
[00:47:19] + LL |                 map.set(String::new()); // Ideally, just AST would error here
[00:47:19] +    |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[00:47:19] +    |
[00:47:19] + note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
[00:47:19] +   --> $DIR/get_default.rs:41:1
[00:47:19] +    |
[00:47:19] + LL | / fn err(map: &mut Map) -> &String {
[00:47:19] + LL | |     loop {
[00:47:19] + LL | |         match map.get() {
[00:47:19] + LL | |             Some(v) => {
[00:47:19] + ...  |
[00:47:19] + LL | |     }
[00:47:19] + LL | | }
[00:47:19] + 
[00:47:19] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:492:22
[00:47:19] + error: aborting due to 6 previous errors
[00:47:19] 50 
[00:47:19] 50 
[00:47:19] 51 For more information about this error, try `rustc --explain E0502`.
[00:47:19] 52 
[00:47:19] 
[00:47:19] 
[00:47:19] The actual stderr differed from the expected stderr.
[00:47:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/get_default.nll.stderr
[00:47:19] To update references, run this command from build directory:
[00:47:19] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'nll/get_default.rs'
[00:47:19] error: 1 errors occurred comparing output.
[00:47:19] status: exit code: 101
[00:47:19] status: exit code: 101
[00:47:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/get_default.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/get_default.stage2-x86_64-unknown-linux-gnu" "-Zborrowck=mir" "-Ztwo-phase-borrows" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=compare" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/get_default.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
[00:47:19] ------------------------------------------
[00:47:19] 
[00:47:19] ------------------------------------------
[00:47:19] stderr:
[00:47:19] stderr:
[00:47:19] ------------------------------------------
[00:47:19] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)","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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1053,"byte_end":1056,"line_start":33,"limutable.\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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1367,"byte_end":1370,"line_start":45,"line_end":45,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Both AST and MIR error here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1314,"byte_end":1317,"line_start":43,"line_end":43,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1812,"byte_end":1813,"line_start":57,"line_end":57,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"immutable borrow ends here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)\n  --> /checkout/src/test/ui/nll/get_default.rs:45:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\nLL |             Some(v) => {\nLL |                 map.set(String::new()); // Both AST and MIR error here\n   |                 ^^^ mutable borrow occurs here\n...\nLL | }\n   | - immutable borrow ends here\n\n"}
[00:47:19] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)","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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1610,"byte_end":1613,"line_start":51,"line_end":51,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Ideally, just AST would error here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1314,"byte_end":1317,"line_start":43,"line_end":43,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1812,"byte_end":1813,"line_start":57,"line_end":57,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"immutable borrow ends here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)\n  --> /checkout/src/test/ui/nll/get_default.rs:51:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\n...\nLL |                 map.set(String::new()); // Ideally, just AST would error here\n   |                 ^^^ mutable borrow occurs here\n...\nLL | }\n   | - immutable borrow ends here\n\n"}
[00:47:19] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)","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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1053,"byte_end":1075,"line_start":33,"line_end":33,"column_start":17,"column_end":39,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Ideally, this would not error.","highlight_start":17,"highlight_end":39}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":938,"byte_end":941,"line_start":28,"line_end":28,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":879,"byte_end":1252,"line_start":26,"line_end":39,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn ok(map: &mut Map) -> &String {","highlight_start":1,"highlight_end":34},{"text":"    loop {","highlight_start":1,"highlight_end":11},{"text":"        match map.get() {","highlight_start":1,"highlight_end":26},{"text":"            Some(v) => {","highlight_start":1,"highlight_end":25},{"text":"                return v;","highlight_start":1,"highlight_end":26},{"text":"            }","highlight_start":1,"highlight_end":14},{"text":"            None => {","highlight_start":1,"highlight_end":22},{"text":"                map.set(String::new()); // Ideally, this would not error.","highlight_start":1,"highlight_end":74},{"text":"                //~^ ERROR borrowed as immutable (Ast)","highlight_start":1,"highlight_end":55},{"text":"                //~| ERROR borrowed as immutable (Mir)","highlight_start":1,"highlight_end":55},{"text":"            }","highlight_start":1,"highlight_end":14},{"text":"        }","highlight_start":1,"highlight_end":10},{"text":"    }","highlight_start":1,"highlight_end":6},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)\n  --> /checkout/src/test/ui/nll/get_default.rs:33:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\n...\nLL |                 map.set(String::new()); // Ideally, this would not error.\n   |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\n   |\nnote: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...\n  --> /checkout/src/test/ui/nll/get_default.rs:26:1\n   |\nLL | / fn ok(map: &mut Map) -> &String {\nLL | |     loop {\nLL | |         match map.get() {\nLL | |             Some(v) => {\n...  |\nLL | |     }\nLL | | }\n   | |_^\n\n"}
[00:47:19] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)","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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1367,"byte_end":1389,"line_start":45,"line_end":45,"column_start":17,"column_end":39,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Both AST and MIR error here","highlight_start":17,"highlight_end":39}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1314,"byte_end":1317,"line_start":43,"line_end":43,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1555,"byte_end":1556,"line_start":48,"line_end":48,"column_start":24,"column_end":25,"is_primary":false,"text":[{"text":"                return v;","highlight_start":24,"highlight_end":25}],"label":"borrow later used here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)\n  --> /checkout/src/test/ui/nll/get_default.rs:45:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\nLL |             Some(v) => {\nLL |                 map.set(String::new()); // Both AST and MIR error here\n   |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\n...\nLL |                 return v;\n   |                        - borrow later used here\n\n"}
[00:47:19] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)","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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1610,"byte_end":1632,"line_start":51,"line_end":51,"column_start":17,"column_end":39,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Ideally, just AST would error here","highlight_start":17,"highlight_end":39}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1314,"byte_end":1317,"line_start":43,"line_end":43,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1254,"byte_end":1813,"line_start":41,"line_end":57,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn err(map: &mut Map) -> &String {","highlight_start":1,"highlight_end":35},{"text":"    loop {","highlight_start":1,"highlight_end":11},{"text":"        match map.get() {","highlight_start":1,"highlight_end":26},{"text":"            Some(v) => {","highlight_start":1,"highlight_end":25},{"text":"                map.set(String::new()); // Both AST and MIR error here","highlight_start":1,"highlight_end":71},{"text":"                //~^ ERROR borrowed as immutable (Mir)","highlight_start":1,"highlight_end":55},{"text":"                //~| ERROR borrowed as immutable (Ast)","highlight_start":1,"highlight_end":55},{"text":"                return v;","highlight_start":1,"highlight_end":26},{"text":"            }","highlight_start":1,"highlight_end":14},{"text":"            None => {","highlight_start":1,"highlight_end":22},{"text":"                map.set(String::new()); // Ideally, just AST would error here","highlight_start":1,"highlight_end":78},{"text":"                //~^ ERROR borrowed as immutable (Ast)","highlight_start":1,"highlight_end":55},{"text":"                //~| ERROR borrowed as immutable (Mir)","highlight_start":1,"highlight_end":55},{"text":"            }","highlight_start":1,"highlight_end":14},{"text":"        }","highlight_start":1,"highlight_end":10},{"text":"    }","highlight_start":1,"highlight_end":6},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)\n  --> /checkout/src/test/ui/nll/get_default.rs:51:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\n...\nLL |                 map.set(String::new()); // Ideally, just AST would error here\n   |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\n   |\nnote: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...\n  --> /checkout/src/test/ui/nll/get_default.rs:41:1\n   |\nLL | / fn err(map: &mut Map) -> &String {\nLL | |     loop {\nLL | |         match map.get() {\nLL | |             Some(v) => {\n...  |\nLL | |     }\nLL | | }\n   | |_^\n\n"}
[00:47:19] {"message":"aborting due to 6 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 6 previous errors\n\n"}
[00:47:19] {"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"}
[00:47:19] ------------------------------------------
[00:47:19] 
[00:47:19] thread '[ui (nll)] ui/nll/get_default.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3033:9
[00:47:19] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:47:19] test result: FAILED. 1378 passed; 1 failed; 7 ignored; 0 measured; 0 filtered out
[00:47:19] 
[00:47:19] 
[00:47:19] 
[00:47:19] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always" "--compare-mode" "nll"
[00:47:19] 
[00:47:19] 
[00:47:19] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:47:19] Build completed unsuccessfully in 0:03:47
[00:47:19] Build completed unsuccessfully in 0:03:47
[00:47:19] make: *** [check] Error 1
[00:47:19] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0f0095a0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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.
  Downloading https://files.pythonhosted.org/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl
Collecting python-dateutil<3.0.0,>=2.1; python_version >= "2.7" (from botocore==1.10.17->awscli)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
    4% |█▌                              | 10kB 38.5MB/s eta 0:00:01
    9% |███                             | 20kB 37.4MB/s eta 0:00:01
    14% |████▋                           | 30kB 41.8MB/s eta 0:00:01
    19% |██████▏                         | 40kB 42.2MB/s eta 0:00:01
---
[01:02:48] ....................................................................................................
[01:03:00] ....................................................................................................
[01:03:08] ....................................................................................................
[01:03:16] ....................................................................................................
[01:03:24] ..........................................i........................................F................
[01:03:38] .....................................ii.............................................................
[01:03:47] ....................................................................................................
[01:03:55] .................i....................................................................
[01:03:55] failures:
[01:03:55] failures:
[01:03:55] 
[01:03:55] ---- [ui (nll)] ui/nll/get_default.rs stdout ----
[01:03:55]  diff of stderr:
[01:03:55] 
[01:03:55] 41    |               --- immutable borrow occurs here
[01:03:55] 42 ...
[01:03:55] 43 LL |                 map.set(String::new()); // Ideally, this would not error.
[01:03:55] -    |                 ^^^ mutable borrow occurs here
[01:03:55] +    |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[01:03:55] 45    |
[01:03:55] 46 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...
[01:03:55] 
[01:03:55] 56    | |_^
[01:03:55] 57 
[01:03:55] 57 
[01:03:55] 58 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
[01:03:55] +   --> $DIR/get_default.rs:45:17
[01:03:55] +    |
[01:03:55] + LL |         match map.get() {
[01:03:55] +    |               --- immutable borrow occurs here
[01:03:55] + LL |             Some(v) => {
[01:03:55] + LL |                 map.set(String::new()); // Both AST and MIR error here
[01:03:55] +    |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[01:03:55] + ...
[01:03:55] + LL |                 return v;
[01:03:55] +    |                        - borrow later used here
[01:03:55] + 
[01:03:55] + error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
[01:03:55] 60    |
[01:03:55] 60    |
[01:03:55] 61 LL |         match map.get() {
[01:03:55] 
[01:03:55] 62    |               --- immutable borrow occurs here
[01:03:55] 63 ...
[01:03:55] 64 LL |                 map.set(String::new()); // Ideally, just AST would error here
[01:03:55] -    |                 ^^^ mutable borrow occurs here
[01:03:55] +    |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[01:03:55] 66    |
[01:03:55] 67 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
[01:03:55] 
[01:03:55] 
[01:03:55] 75 LL | |     }
[01:03:55] 76 LL | | }
[01:03:55] - 
[01:03:55] - 
[01:03:55] - error[E0502]: cannot borrow `*mapt/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=compare" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/get_default.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
[01:03:55] ------------------------------------------
[01:03:55] 
[01:03:55] ------------------------------------------
[01:03:55] stderr:
[01:03:55] stderr:
[01:03:55] ------------------------------------------
[01:03:55] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)","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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1053,"byte_end":1056,"line_start":33,"line_end":33,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Ideally, this would not error.","highlight_start":17,"herror: 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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1367,"byte_end":1370,"line_start":45,"line_end":45,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Both AST and MIR error here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1314,"byte_end":1317,"line_start":43,"line_end":43,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1812,"byte_end":1813,"line_start":57,"line_end":57,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"immutable borrow ends here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed asuse `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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1053,"byte_end":1075,"line_start":33,"line_end":33,"column_start":17,"column_end":39,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Ideally, this would not error.","highlight_start":17,"highlight_end":39}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":938,"byte_end":941,"line_start":28,"line_end":28,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":879,"byte_end":1252,"line_start":26,"line_end":39,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn ok(map: &mut Map) -> &String {","highlight_start":1,"highlight_end":34},{"text":"    loop {","highlight_starow occurs here\n   |\nnote: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...\n  --> /checkout/src/test/ui/nll/get_default.rs:41:1\n   |\nLL | / fn err(map: &mut Map) -> &String {\nLL | |     loop {\nLL | |         match map.get() {\nLL | |             Some(v) => {\n...  |\nLL | |     }\nLL | | }\n   | |_^\n\n"}
[01:03:55] {"message":"aborting due to 6 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 6 previous errors\n\n"}
[01:03:55] {"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:03:55] ------------------------------------------
[01:03:55] 
[01:03:55] thread '[ui (nll)] ui/nll/get_default.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3033:9
[01:03:55] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[01:03:55] 
[01:03:55] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:492:22
[01:03:55] 
[01:03:55] 
[01:03:55] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lt=1525964117704774564,finish=1525964117753449699,duration=48675135
The command "date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
" exited with 0.
travis_fold:start:after_failure.1
travis_time:start:23470d5d

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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:51:17] ---- [run-pass] run-pass/nll/get_default.rs stdout ----
[00:51:17]  
[00:51:17] error: compilation failed!
[00:51:17] status: exit code: 101
[00:51:17] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/nll/get_default.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/nll/get_default.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/nll/get_default.stage2-x86_64-unknown-linux-gnu.aux"
[00:51:17] ------------------------------------------
[00:51:17] 
[00:51:17] ------------------------------------------
[00:51:17] stderr:
[00:51:17] stderr:
[00:51:17] ------------------------------------------
[00:51:17] error[E0499]: cannot borrow `*map` as mutable more than once at a time
[00:51:17]    |
[00:51:17]    |
[00:51:17] 16 |     match map.get_mut(&key) {
[00:51:17]    |           --- first mutable borrow occurs here
[00:51:17] ...
[00:51:17] 19 |             map.insert(key, "".to_string());
[00:51:17]    |             ^^^ second mutable borrow occurs here
[00:51:17]    |
[00:51:17] note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 15:1...
[00:51:17]    |
[00:51:17]    |
[00:51:17] 15 | / fn get_default(map: &mut HashMap<usize, String>, key: usize) -> &mut String {
[00:51:17] 16 | |     match map.get_mut(&key) {
[00:51:17] 17 | |         Some(value) => value,
[00:51:17] ...  |
[00:51:17] 22 | |     }
[00:51:17] 23 | | }
[00:51:17]    | |_^
[00:51:17]    | |_^
[00:51:17] 
[00:51:17] error[E0499]: cannot borrow `*map` as mutable more than once at a time
[00:51:17]    |
[00:51:17]    |
[00:51:17] 16 |     match map.get_mut(&key) {
[00:51:17]    |           --- first mutable borrow occurs here
[00:51:17] ...
[00:51:17] 20 |             map.get_mut(&key).unwrap()
[00:51:17]    |             ^^^ second mutable borrow occurs here
[00:51:17]    |
[00:51:17] note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 15:1...
[00:51:17]    |
[00:51:17]    |
[00:51:17] 15 | / fn get_default(map: &mut HashMap<usize, String>, key: usize) -> &mut String {
[00:51:17] 16 | |     match map.get_mut(&key) {
[00:51:17] 17 | |         Some(value) => value,
[00:51:17] ...  |
[00:51:17] 22 | |     }
[00:51:17] 23 | | }
[00:51:17]    | |_^
---
[00:51:17] 
[00:51:17] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:492:22
[00:51:17] 
[00:51:17] 
[00:51:17] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:51:17] 
[00:51:17] 
[00:51:17] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:51:17] Build completed unsuccessfully in 0:12:30
[00:51:17] Build completed unsuccessfully in 0:12:30
[00:51:17] Makefile:58: recipe for target 'check' failed
[00:51:17] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:229e8fd0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

It no longer passes, and the ui test subsumes it anyhow.
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:start:test_mir-opt
Check compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:03:31] 
[01:03:31] running 50 tests
[01:03:52] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:492:22
[01:03:52] ...................................F..............
[01:03:52] 
[01:03:52] ---- [mir-opt] mir-opt/nll/region-liveness-two-disjoint-uses.rs stdout ----
[01:03:52] ---- [mir-opt] mir-opt/nll/region-liveness-two-disjoint-uses.rs stdout ----
[01:03:52]  thread '[mir-opt] mir-opt/nll/region-liveness-two-disjoint-uses.rs' panicked at 'Did not find expected line, error: ran out of mir dump to match against
[01:03:52] Expected Line: "| \'_#2r    | {bb2[0..=1], bb3[0..=1]}"
[01:03:52] Test Name: rustc.main.nll.0.mir
[01:03:52] Expected:
[01:03:52] ... (elided)
[01:03:52] | '_#2r    | {bb2[0..=1], bb3[0..=1]}
[01:03:52] ... (elided)
[01:03:52] | '_#4r    | {bb8[1..=4]}
[01:03:52] | '_#5r    | {bb2[1], bb3[0..=1], bb8[2..=4]}
[01:03:52] ... (elided)
[01:03:52] let mut _2: &'_#5r usize;
[01:03:52] ... (elided)
[01:03:52] _2 = &'_#2r _1[_3];
[01:03:52] ... (elided)
[01:03:52] _2 = &'_#4r (*_10);
[01:03:52] Actual:
[01:03:52] | Free Region Mapping
[01:03:52] | '_#0r    | Global   | ['_#0r, '_#1r]
[01:03:52] | '_#1r    | Local    | ['_#1r]
                                 | Live variables on entry to bb0[5]: [_1, _3]
[01:03:52]         _4 = Len(_1);
[01:03:52]                                          | Live variables on entry to bb0[6]: [_1, _3, _4]
[01:03:52]         _5 = Lt(_3, _4);
[01:03:52]                                          | Live variables on entry to bb0[7]: [_1, _3, _4, _5]
[01:03:52]         assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> [success: bb2, unwind: bb1];
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb1: []
[01:03:52]     bb1: {
[01:03:52]                                          | Live variables on entry to bb1[0]: []
[01:03:52]         resume;
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb2: [_1, _3]
[01:03:52]     bb2: {                              
[01:03:52]                                          | Live variables on entry to bb2[0]: [_1, _3]
[01:03:52]         _2 = &'_#2r _1[_3];
[01:03:52]                                          | Live variables on entry to bb2[1]: [_1, _2]
[01:03:52]         switchInt(const true) -> [false: bb4, otherwise: bb3];
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb3: [_1, _2]
[01:03:52]     bb3: {                              
[01:03:52]                                          | Live variables on entry to bb3[0]: [_1, _2]
[01:03:52]         StorageLive(_8);
[01:03:52]                                          | Live variables on entry to bb3[1]: [_1, _2]
[01:03:52]         _8 = (*_2);
[01:03:52]                                          | Live variables on entry to bb3[2]: [_1, _8]
[01:03:52]         _7 = const use_x(move _8) -> [return: bb5, unwind: bb1];
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb4: [_1]
[01:03:52]     bb4: {                              
[01:03:52]                                          | Live variables on entry to bb4[0]: [_1]
[01:03:52]         _9 = const use_x(const 22usize) -> [return: bb6, unwind: bb1];
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb5: [_1]
[01:03:52]     bb5: {                              
[01:03:52]                                          | Live variables on entry to bb5[0]: [_1]
[01:03:52]         StorageDead(_8);
[01:03:52]                                          | Live variables on entry to bb5[1]: [_1]
[01:03:52]         _6 = ();
[01:03:52]                                          | Live variables on entry to bb5[2]: [_1]
[01:03:52]         goto -> bb7;
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb6: [_1]
[01:03:52]     bb6: {                              
[01:03:52]                                          | Live variables on entry to bb6[0]: [_1]
[01:03:52]         _6 = ();
[01:03:52]                                          | Live variables on entry to bb6[1]: [_1]
[01:03:52]         goto -> bb7;
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb7: [_1]
[01:03:52]     bb7: {                              
[01:03:52]                                          | Live variables on entry to bb7[0]: [_1]
[01:03:52]         StorageLive(_10);
[01:03:52]                                          | Live variables on entry to bb7[1]: [_1]
[01:03:52]         StorageLive(_11);
[01:03:52]                                          | Live variables on entry to bb7[2]: [_1]
[01:03:52]         _11 = const 1usize;
[01:03:52]                                          | Live variables on entry to bb7[3]: [_1, _11]
[01:03:52]         _12 = Len(_1);
[01:03:52]                                          | Live variables on entry to bb7[4]: [_1, _11, _12]
[01:03:52]         _13 = Lt(_11, _12);
[01:03:52]                                          | Live variables on entry to bb7[5]: [_1, _11, _12, _13]
[01:03:52]         assert(move _13, "index out of bounds: the len is move _12 but the index is _11") -> [success: bb8, unwind: bb1];
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb8: [_1, _11]
[01:03:52]     bb8: {                              
[01:03:52]                                          | Live variables on entry to bb8[0]: [_1, _11]
[01:03:52]         _10 = &'_#3r _1[_11];
[01:03:52]                                          | Live variables on entry to bb8[1]: [_10]
[01:03:52]         _2 = &'_#4r (*_10);
[01:03:52]                                          | Live variables on entry to bb8[2]: [_2]
[01:03:52]         StorageDead(_10);
[01:03:52]                                          | Live variables on entry to bb8[3]: [_2]
[01:03:52]         StorageLive(_15);
[01:03:52]                                          | Live variables on entry to bb8[4]: [_2]
[01:03:52]         _15 = (*_2);
[01:03:52]                                          | Live variables on entry to bb8[5]: [_15]
[01:03:52]         _14 = const use_x(move _15) -> [return: bb9, unwind: bb1];
[01:03:52]     }
[01:03:52]     | Live variables on entry to bb9: []
[01:03:52]     bb9: {                              
[01:03:52]                                          | Live variables on entry to bb9[0]: []
[01:03:52]         StorageDead(_15);
[01:03:52]                                          | Live variables on entry to bb9[1]: []
[01:03:52]         _0 = ();
[01:03:52]                                          | Live variables on entry to bb9[2]: []
[01:03:52]         nop;
[01:03:52]                                          | Live variables on entry to bb9[3]: []
[01:03:52]         StorageDead(_2);
[01:03:52]                                          | Live variables on entry to bb9[4]: []
[01:03:52]         StorageDead(_1);
[01:03:52]                                          | Live variables on entry to bb9[5]: []
[01:03:52]         return;
[01:03:52] }', tools/compiletest/src/runtest.rs:2801:13
[01:03:52] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:03:52] 
[01:03:52] 
[01:03:52] 
[01:03:52] failures:
[01:03:52]     [mir-opt] mir-opt/nll/region-liveness-two-disjoint-uses.rs
[01:03:52] 
[01:03:52] test result: FAILED. 49 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:03:52] 
[01:03:52] 
[01:03:52] 
[01:03:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu

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)

We no longer get two disjoint uses. =)
@pietroalbini
Copy link
Member

Ping from triage @pnkfelix! This PR needs your review.

@pnkfelix
Copy link
Member

i'll admit I was waiting for the perf run, but I'll take a look

@@ -1095,7 +1097,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {

/// Tries to finds a good span to blame for the fact that `fr1`
Copy link
Member

Choose a reason for hiding this comment

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

might be nice to also fix the comment here to reflect the more general behavior

@@ -1112,7 +1097,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let relevant_constraint = self.constraints
.iter_enumerated()
.filter_map(|(i, constraint)| {
if self.liveness_constraints.contains(constraint.sub, elem) {
if !self.liveness_constraints.contains(constraint.sub, elem) {
Copy link
Member

Choose a reason for hiding this comment

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

(it would be nice if this one-line bugfix were attached to the commit that generalized blame_constraint)

@pnkfelix
Copy link
Member

This seems fine to me. I had very small nits.

I don't want to r+ because I suspect @nikomatsakis may want to rebase it a little first? But if he's happy with the commit series the way it is, then go ahead and r=me it.

@pnkfelix pnkfelix 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 May 17, 2018
@nikomatsakis
Copy link
Contributor Author

@bors r+

@bors
Copy link
Contributor

bors commented May 17, 2018

📌 Commit a64ef13 has been approved by nikomatsakis

@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 May 17, 2018
@nikomatsakis
Copy link
Contributor Author

Normally I would clean up but I'm too busy today

@Mark-Simulacrum
Copy link
Member

@bors p=10

@bors
Copy link
Contributor

bors commented May 17, 2018

⌛ Testing commit a64ef13 with merge 612ca14...

bors added a commit that referenced this pull request May 17, 2018
stop considering location when computing outlives relationships

This doesn't (yet?) use SEME regions, but it does ignore the location for outlives constraints. This makes (I believe) NLL significantly faster -- but we should do some benchmarks. It regresses the "get-default" family of use cases for NLL, which is a shame, but keeps the other benefits, and thus represents a decent step forward.

r? @pnkfelix
@bors
Copy link
Contributor

bors commented May 18, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 612ca14 to master...

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.

6 participants