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

Erroneous loop diagnostic in nll #56113

Merged
merged 3 commits into from
Feb 22, 2019

Conversation

spastorino
Copy link
Member

Closes #53773

r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 20, 2018
@spastorino
Copy link
Member Author

@nikomatsakis we need to discuss the changed output of the 2 existing tests

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

This I think is why the tests fail

src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs Outdated Show resolved Hide resolved
@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.
travis_time:end:019a5d65:start=1542743550227308912,finish=1542743605389370072,duration=55162061160
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:48:33] 
[00:48:33] running 5043 tests
[00:48:35] .................................................................................................... 100/5043
[00:48:38] .................................................................................................... 200/5043
[00:48:41] .............................ii...........................F................ii...................ii.. 300/5043
[00:48:43] .......................F......................................................................iii... 400/5043
[00:48:46] .....iiiiiiii.iii.........F..................iii...........................................i........ 500/5043
[00:48:53] .................................................................................................... 700/5043
[00:48:59] ..................................................................................i...........i..... 800/5043
[00:49:02] .................................................................................................... 900/5043
[00:49:05] .iiiii..................ii.iiii..................................................................... 1000/5043
---
[00:49:40] .................................................................................................... 2200/5043
[00:49:44] .................................................................................................... 2300/5043
[00:49:47] .................................................................................................... 2400/5043
[00:49:51] .................................................................................................... 2500/5043
[00:49:54] .....................................................................................iiiiiiiii...... 2600/5043
[00:49:57] .................................................................................................... 2700/5043
[00:50:00] .........................F.........................ii............................................... 2800/5043
[00:50:07] .................................................................................................... 3000/5043
[00:50:10] ...............................................i.................................................... 3100/5043
[00:50:13] .................................................................................................... 3200/5043
[00:50:15] ..........ii..i..ii................................................................................. 3300/5043
---
[00:50:27] ..................................................................i................................. 3800/5043
[00:50:29] .................................................................................................... 3900/5043
[00:50:32] .................................................................................................... 4000/5043
[00:50:35] .................................................................................................... 4100/5043
[00:50:37] ...................................................................................................i 4200/5043
[00:50:41] iiii.............F........i......................................................................... 4300/5043
[00:50:45] .................................................................................................... 4400/5043
[00:50:48] .....................................................................................F.F............ 4500/5043
[00:50:54] ..........i......................................................................................... 4700/5043
[00:50:58] .................................................................................................... 4800/5043
[00:51:00] .................................................................................................... 4900/5043
[00:51:00] .................................................................................................... 4900/5043
[00:51:03] .............................................................................F....i................. 5000/5043
[00:51:04] failures:
[00:51:04] 
[00:51:04] ---- [ui (nll)] ui/borrowck/borrowck-for-loop-head-linkage.rs stdout ----
[00:51:04] diff of stderr:
[00:51:04] diff of stderr:
[00:51:04] 
[00:51:04] 5    |               -------
[00:51:04] 6    |               |
[00:51:04] 7    |               immutable borrow occurs here
[00:51:04] -    |               immutable borrow used here, in later iteration of loop
[00:51:04] +    |               immutable borrow later used here
[00:51:04] 9 LL |         let cap = vector.capacity();
[00:51:04] 10 LL |         vector.extend(repeat(0));      //~ ERROR cannot borrow
[00:51:04] 
[00:51:04] 17    |               -------
[00:51:04] 18    |               |
[00:51:04] 19    |               immutable borrow occurs here
[00:51:04] 19    |               immutable borrow occurs here
[00:51:04] -    |               immutable borrow used here, in later iteration of loop
[00:51:04] 21 ...
[00:51:04] 21 ...
[00:51:04] 22 LL |         vector[1] = 5;   //~ ERROR cannot borrow
[00:51:04] 
[00:51:04] 
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-for-loop-head-linkage.nll/borrowck-for-loop-head-linkage.nll.stderr
[00:51:04] To update references, rerun the tests and pass the `--bless` flag
[00:51:04] To only update this specific test, also pass `--test-args borrowck/borrowck-for-loop-head-linkage.rs`
[00:51:04] error: 1 errors occurred comparing output.
[00:51:04] status: exit code: 1
[00:51:04] status: exit code: 1
[00:51:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs" "--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/borrowck/borrowck-for-loop-head-linkage.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/borrowck/borrowck-for-loop-head-linkage.nll/auxiliary" "-A" "unused"
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] ------------------------------------------
[00:51:04] stderr:
[00:51:04] stderr:
[00:51:04] ------------------------------------------
[00:51:04] {"message":"cannot borrow `vector` 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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":605,"byte_end":629,"line_start":17,"line_end":17,"column_start":9,"column_end":33,"is_primary":true,"text":[{"text":"        vector.extend(repeat(0));      //~ ERROR cannot borrow","highlight_start":9,"highlight_end":33}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":550,"byte_end":557,"line_start":15,"line_end":15,"column_start":15,"column_end":22,"is_primary":false,"text":[{"text":"    for &x in &vector {","highlight_start":15,"highlight_end":22}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":550,"byte_end":557,"line_start":15,"line_end":15,"column_start":15,"column_end":22,"is_primary":false,"text":[{"text":"    for &x in &vector {","highlight_start":15,"highlight_end":22}],"label":"immutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs:17:9\n   |\nLL |     for &x in &vector {\n   |               -------\n   |               |\n   |               immutable borrow occurs here\n   |               immutable borrow later used here\nLL |         let cap = vector.capacity();\nLL |         vector.extend(repeat(0));      //~ ERROR cannot borrow\n   |         ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\n\n"}
[00:51:04] {"message":"cannot borrow `vector` 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 ownej/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll/auxiliary" "-A" "unused"
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] ------------------------------------------
[00:51:04] stderr:
[00:51:04] stderr:
[00:51:04] ------------------------------------------
[00:51:04] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":1066,"byte_end":1072,"line_start":27,"line_end":27,"column_start":30,"column_end":36,"is_primary":false,"text":[{"text":"            _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":868,"byte_end":874,"line_se at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":1066,"byte_end":1072,"line_start":27,"line_end":27,"column_start":30,"column_end":36,"is_primary":false,"text":[{"text":"            _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":967,"byte_end":973,"line_start":25,"line_end":25,"column_start":30,"column_end":36,"is_primary":true,"text":[{"text":"            2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":858,"byte_end":862,"line_start":23,"line_end":23,"column_start":20,"column_end":24,"is_primary":false,"text":[{"text":"            1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":20,"highlight_end":24}],"label":"first borrow lline_start":27,"line_end":27,"column_start":30,"column_end":36,"is_primary":true,"text":[{"text":"            _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"mutable borrow starts here in previous iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs:27:30\n   |\nLL |             _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\n   |                              ^^^^^^ mutable borrow starts here in previous iteration of loop\n\n"}
[00:51:04] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:51:04] {"message":"For more information about this error, try `rustc --explain E0499`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0499`.\n"}
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] thread '[ui (nll)] ui/borrowck/borrowck-mut-borrow-linear-errors.rs#ast' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:04] 
[00:51:04] 
[00:51:04] ---- [ui (nll)] ui/borrowck/mut-borrow-outside-loop.rs stdout ----
[00:51:04] diff of stderr:
[00:51:04] 
[00:51:04] 17    |                            ^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:51:04] 18 LL |         inner_second.use_mut();
[00:51:04] 19 LL |         inner{"message":"cannot borrow `void` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":645,"byte_end":654,"line_start":16,"line_end":16,"column_start":17,"column_end":26,"is_primary":false,"text":[{"text":"    let first = &mut void;","highlight_start":17,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":673,"byte_end":682,"line_start":17,"line_end":17,"column_start":18,"column_end":27,"is_primary":true,"text":[{"text":"    let second = &mut void; //~ ERROR cannot borrow","highlight_start":18,"highlight_end":27}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":712,"bne_end":24,"column_start":27,"column_end":42,"is_primary":false,"text":[{"text":"        let inner_first = &mut inner_void;","highlight_start":27,"highlight_end":42}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":867,"byte_end":882,"line_start":25,"line_end":25,"column_start":28,"column_end":43,"is_primary":true,"text":[{"text":"        let inner_second = &mut inner_void; //~ ERROR cannot borrow","highlight_start":28,"highlight_end":43}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":948,"byte_end":959,"line_start":27,"line_end":27,"column_start":9,"column_end":20,"is_primary":false,"text":[{"text":"        inner_first.use_mut();","highlight_start":9,"highlight_end":20}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `inner_void` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs:25:28\n   |\nLL |         let inner_first = &mut inner_void;\n   |                           --------------- first mutable borrow occurs here\nLL |         let inner_second = &mut inner_void; //~ ERROR cannot borrow\n   |                            ^^^^^^^^^^^^^^^ second mutable borrow occurs here\nLL |         inner_second.use_mut();\nLL |         inner_first26-assign-op-invariance.rs`
[00:51:04] error: 1 errors occurred comparing output.
[00:51:04] status: exit code: 1
[00:51:04] status: exit code: 1
[00:51:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs" "--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/issues/issue-52126-assign-op-invariance.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/issues/issue-52126-assign-op-invariance.nll/auxiliary" "-A" "unused"
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] ------------------------------------------
[00:51:04] stderr:
[00:51:04] stderr:
[00:51:04] ------------------------------------------
[00:51:04] {"message":"`line` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs","byte_start":1442,"byte_end":1446,"line_start":44,"line_end":44,"column_start":28,"column_end":32,"is_primary":true,"text":[{"text":"        let v: Vec<&str> = line.split_whitespace().collect();","highlight_start":28,"highlight_end":32}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs","byte_start":2011,"byte_end":2012,"line_start":58,"line_end":58,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"`line` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs","byte_start":1858,"byte_end":1861,"line_start":55,"line_end":55,"column_start":9,"column_end":12,"is_primary":false,"text":[{"text":"        acc += cnt2;","highlight_start":9,"highlight_end":12}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `line` does not live long enough\n  --> /checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs:44:28\n   |\nLL |         let v: Vec<&str> = line.split_whitespace().collect();\n   |                            ^^^rowck-issue-49631.nll/borrowck-issue-49631.nll.stderr
[00:51:04] To update references, rerun the tests and pass the `--bless` flag
[00:51:04] To only update this specific test, also pass `--test-args rfc-2005-default-binding-mode/borrowck-issue-49631.rs`
[00:51:04] error: 1 errors occurred comparing output.
[00:51:04] status: exit code: 1
[00:51:04] status: exit code: 1
[00:51:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs" "--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/rfc-2005-default-binding-mode/borrowck-issue-49631.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll/auxiliary" "-A" "unused"
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] ------------------------------------------
[00:51:04] stderr:
[00:51:04] stderr:
[00:51:04] ------------------------------------------
[00:51:04] {"message":"cannot borrow `foo` 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                   -- borrow used here, in later iteration of loop
[00:51:04] +    |                     -- borrow later used here
[00:51:04] 6 LL |         p = &x;
[00:51:04] 7    |             ^^ borrowed value does not live long enough
[00:51:04] 8 LL |     }
[00:51:04] 
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/regions-escape-loop-via-variable.nll/regions-escape-loop-via-variable.nll.stderr
[00:51:04] To update references, rerun the tests and pass the `--bless` flag
[00:51:04] To only update this specific test, also pass `--test-args span/regions-escape-loop-via-variable.rs`
[00:51:04] error: 1 errors occurred comparing output.
[00:51:04] status: exit code: 1
[00:51:04] status: exit code: 1
[00:51:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/span/regions-escape-loop-via-variable.rs" "--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/span/regions-escape-loop-via-variable.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/span/regions-escape-loop-via-variable.nll/auxiliary" "-A" "unused"
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] ------------------------------------------
[00:51:04] stderr:
[00:51:04] stderr:
[00:51:04] -------------------/src/test/ui/span/regions-escape-loop-via-variable.rs","byte_start":706,"byte_end":708,"line_start":20,"line_end":20,"column_start":21,"column_end":23,"is_primary":false,"text":[{"text":"        let x = 1 + *p;","highlight_start":21,"highlight_end":23}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-variable.rs:21:13\n   |\nLL |         let x = 1 + *p;\n   |                     -- borrow later used here\nLL |         p = &x;\n   |             ^^ borrowed value does not live long enough\nLL |     }\n   |     - `x` dropped here while still borrowed\n\n"}
[00:51:04] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:04] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] thread '[ui (nll)] ui/span/regions-escape-loop-via-variable.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:04] 
[00:51:04] 
[00:51:04] ---- [ui (nll)] ui/span/regions-escape-loop-via-vec.rs stdout ----
[00:51:04] diff of stderr:
[00:51:04] 
[00:51:04] 7    |           ^ use of borrowed `x`
[00:51:04] 8 LL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
^^^^^^ use of borrowed `x`
[00:51:04] 
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/regions-escape-loop-via-vec.nll/regions-escape-loop-via-vec.nll.stderr
[00:51:04] To update references, rerun the tests and pass the `--bless` flag
[00:51:04] To only update this specific test, also pass `--test-args span/regions-escape-loop-via-vec.rs`
[00:51:04] error: 1 errors occurred comparing output.
[00:51:04] status: exit code: 1
[00:51:04] status: exit code: 1
[00:51:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs" "--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/span/regions-escape-loop-via-vec.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/span/regions-escape-loop-via-vec.nll/auxiliary" "-A" "unused"
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] ------------------------------------------
[00:51:04] stderr:
[00:51:04] stderr:
[00:51:04] ------------------------------------------
[00:51:04] {"message":"cannot use `x` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":592,"byte_end":598,"line_start":14,"line_end":14,"column_start":23,"column_end":29,"is_primary":false,"text":[{"text":"    let mut _y = vec![&mut x];","highlight_start":23,"highlight_end":29}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":611,"byte_end":612,"line_start":15,"line_end":15,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"    while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed","highlight_start":11,"highlight_end":12}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":765,"byte_end":767,"line_start":17,"line_end":17,"column_start":9,"column_end":11,"is_primary":false,"text":[{"text":"        _y.push(&mut z);","highlight_start":9,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-vec.rs:15:11\n   |\nLL |     let mut _y = vec![&mut x];\n   |                       ------ borrow of `x` occurs here\nLL |     while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed\n   |           ^ use of borrowed `x`\nLL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed\nLL |         _y.push(&mut z);\n   |         -- borrow later used here\n\n"}
[00:51:04] {"message":"cannot use `x` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-l   {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":592,"byte_end":598,"line_start":14,"line_end":14,"column_start":23,"column_end":29,"is_primary":false,"text":[{"text":"    let mut _y = vec![&mut x];","highlight_start":23,"highlight_end":29}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":839,"byte_end":845,"line_start":19,"line_end":19,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        x += 1; //~ ERROR cannot assign","highlight_start":9,"highlight_end":15}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escaorrow.rs stdout ----
[00:51:04] 
[00:51:04] 5    |              -------
[00:51:04] 6    |              |
[00:51:04] 7    |              first mutable borrow occurs here
[00:51:04] 7    |              first mutable borrow occurs here
[00:51:04] -    |              first borrow used here, in later iteration of loop
[00:51:04] +    |              first borrow later used here
[00:51:04] 9 LL |         xs.push(1) //~ ERROR cannot borrow `xs`
[00:51:04] 10    |         ^^ second mutable borrow occurs here
[00:51:04] 
[00:51:04] 
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] The actual stderr differed from the expected stderr.
[00:51:04] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/vec/vec-mut-iter-borrow.nll/vec-mut-iter-borrow.nll.stderr
[00:51:04] To update references, rerun the tests and pass the `--bless` flag
[00:51:04] To only update this specific test, also pass `--test-args vec/vec-mut-iter-borrow.rs`
[00:51:04] error: 1 errors occurred comparing output.
[00:51:04] status: exit code: 1
[00:51:04] status: exit code: 1
[00:51:04] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/vec/vec-mut-iter-borrow.rs" "--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/vec/vec-mut-iter-borrow.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/vec/vec-mut-iter-borrow.nll/auxiliary" "-A" "unused"
[00:51:04] stdout:
[00:51:04] ------------------t":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/vec/vec-mut-iter-borrow.rs","byte_start":530,"byte_end":537,"line_start":14,"line_end":14,"column_start":14,"column_end":21,"is_primary":false,"text":[{"text":"    for x in &mut xs {","highlight_start":14,"highlight_end":21}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `xs` as mutable more than once at a time\n  --> /checkout/src/test/ui/vec/vec-mut-iter-borrow.rs:15:9\n   |\nLL |     for x in &mut xs {\n   |              -------\n   |              |\n   |              first mutable borrow occurs here\n   |              first borrow later used here\nLL |         xs.push(1) //~ ERROR cannot borrow `xs`\n   |         ^^ second mutable borrow occurs here\n\n"}
[00:51:04] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:04] {"message":"For more information about this error, try `rustc --explain E0499`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0499`.\n"}
[00:51:04] ------------------------------------------
[00:51:04] 
[00:51:04] thread '[ui (nll)] ui/vec/vec-mut-iter-borrow.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:04] 
---
[00:51:04] 
[00:51:04] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[00:51:04] 
[00:51:04] 
[00:51:04] 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-5.0/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/travis_time:end:10535f48:start=1542743613597502575,finish=1542746678400927449,duration=3064803424874
travis_time:start:0af7098e
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Nov 20 20:44:38 UTC 2018
Tue, 20 Nov 2018 20:44:38 GMT
---
travis_time:end:093aa6d0:start=1542746679749449895,finish=1542746679754477555,duration=5027660
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04198ab2
$ 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

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)

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch 2 times, most recently from 97f0188 to d8f9775 Compare November 20, 2018 21:38
@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.
travis_time:end:396b7c81:start=1542749989091321165,finish=1542750053029259181,duration=63937938016
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:45:43] 
[00:45:43] running 5043 tests
[00:45:45] .F.................................................................................................. 100/5043
[00:45:48] .................................................................................................... 200/5043
[00:45:51] ...........................................F.........F.........F................................F... 300/5043
[00:45:54] ........................................F....................F...................................... 400/5043
[00:45:57] ....................................F..F....F.....FF................................................ 500/5043
[00:46:00] .............................i........F............................................................. 600/5043
[00:46:10] ..................................................................................i...........i..... 800/5043
[00:46:13] .................................................................................................... 900/5043
[00:46:17] .iiiii.............................................................................................. 1000/5043
[00:46:19] .................................................................................................... 1100/5043
[00:46:19] .................................................................................................... 1100/5043
[00:46:21] .................................................................................................... 1200/5043
[00:46:24] .................................................................................................... 1300/5043
[00:46:26] .................................................................................................... 1400/5043
[00:46:29] .................................................................................................... 1500/5043
[00:46:32] ..i.....................................................................Fi.......................... 1600/5043
[00:46:38] .................................................................................................... 1800/5043
[00:46:42] .................................................................................................... 1900/5043
[00:46:45] ....i............................................................................................... 2000/5043
[00:46:48] .................................................................................................... 2100/5043
[00:46:48] .................................................................................................... 2100/5043
[00:46:53] .................................................................................................... 2200/5043
[00:46:56] .................................................................................................... 2300/5043
[00:47:00] .................................................................................................... 2400/5043
[00:47:03] ................F................................................................................... 2500/5043
[00:47:07] ................................................................................................F... 2600/5043
[00:47:14] .................................................................................................... 2800/5043
[00:47:17] .................................................................................................... 2900/5043
[00:47:21] .................................................................................................... 3000/5043
[00:47:24] ...............................................i.................................................... 3100/5043
[00:47:24] ...............................................i.................................................... 3100/5043
[00:47:27] .................................................................................................... 3200/5043
[00:47:30] ..........ii..i..ii.................................................F.........F..................... 3300/5043
[00:47:34] ..................F................................................F...FF..................F........ 3400/5043
[00:47:37] F...........................................................................................ii...... 3500/5043
[00:47:41] ..........i......................................................................................... 3700/5043
[00:47:43] ..................................................................i................................. 3800/5043
[00:47:44] .................................................................................................... 3900/5043
[00:47:47] .................................................................................................... 4000/5043
[00:47:47] .................................................................................................... 4000/5043
[00:47:50] .................................................................................................... 4100/5043
[00:47:53] .................................................................................................... 4200/5043
[00:47:57] ..........................i......................................................................... 4300/5043
[00:48:02] .................................................................................................... 4400/5043
[00:48:05] .................................................................................................... 4500/5043
[00:48:09] .................................................................................................... 4600/5043
[00:48:12] ..........i......................................................................................... 4700/5043
[00:48:16] ....F............................................................................................... 4800/5043
[00:48:21] ..................................................................................i................. 5000/5043
[00:48:22] ...........................................
[00:48:22] failures:
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/E0501.rs#mir stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 10    |                       ^ borrow occurs here
[00:48:22] 11 ...
[00:48:22] 12 LL |     drop(bar);
[00:48:22] -    |          --- first borrow later used here
[00:48:22] +    |          --- first borrow used here, in later iteration of loop
[00:48:22] 14 
[00:48:22] 15 error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
[00:48:22] 16   --> $DIR/E0501.rs:31:23
[00:48:22] 24    |                       ^ borrow occurs here
[00:48:22] 25 ...
[00:48:22] 25 ...
[00:48:22] 26 LL |     drop(bar);
[00:48:22] -    |          --- first borrow later used here
[00:48:22] +    |          --- first borrow used here, in later iteration of loop
[00:48:22] 29 error: aborting due to 2 previous errors
[00:48:22] 30 
[00:48:22] 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/E0501.mir/E0501.mir.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args E0501.rs`
[00:48:22] 
[00:48:22] error in revision `mir`: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/E0501.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "mir" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/E0501.mir/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/E0501.mir/auxiliary" "-A" "unused"
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] ------------------------------------------
[00:48:22] stderr:
[00:48:22] stderr:
[00:48:22] ------------------------------------------
[00:48:22] {"message":"cannot borrow `*a` as mutable because previous closure requires unique access","code":{"code":"E0501","explanation":"\nThis error indicates that a mutable variable is being used while it is still\ncaptured by a closure. Because the closure has borrowed the variable, it is not\navailable for use until the closure goes out of scope.\n\nNote that a capture will either move or borrow a variable, but in this\nsituation, the closure is borrowing the variable. Take a look at\nhttp://rustbyexample.com/fn/closures/capture.html for more information about\ncapturing.\n\nExample of erroneous code:\n\n```compiled_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/E0501.rs","byte_start":700,"byte_end":702,"line_start":25,"line_end":25,"column_start":15,"column_end":17,"is_primary":false,"text":[{"text":"    let bar = || {","highlight_start":15,"highlight_end":17}],"label":"closure construction occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/E0501.rs","byte_start":728,"byte_end":729,"line_start":26,"line_end":26,"column_start":24,"column_end":25,"is_primary":false,"text":[{"text":"        inside_closure(a)","highlight_start":24,"highlight_end":25}],"label":"first borrow occurs due to use of `a` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/E0501.rs","byte_start":1187,"byte_end":1190,"line_start":34,"line_end":34,"column_start":10,"column_end":13,"is_primary":false,"text":[{"text":"    drop(bar);","highlight_start":10,"highlight_end":13}],"label":"first borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access\n  --> /checkout/src/test/ui/E0501.rs:28:23\n   |\nLL |     let bar = || {\n   |               -- closure construction occurs here\nLL |         inside_closure(a)\n   |                        - first borrow occurs due to use of `a` in closure\nLL |     };\nLL |     outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access\n   |                       ^ borrow occurs here\n...\nLL |     drop(bar);\n   |          --- first borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `*a` as immutable because previous closure requires unique access","code":{"code":"E0501","explanation":"\nThis error indicates that a mutable variable is being used while it is still\ncaptured by a closure. Because the closure has borrowed the variable, it is not\navailable for use until the closure goes out of scope.\n\nNote that a capture will either move or borrow a variable, but in this\nsituation, the closure is borrowing the variable. Take a look at\nhttp://rustbyexample.com/fn/closures/capture.html for more information about\ncapturing.\n\nExample of erroneous code:\n\n```compile_fail,E0501\nfn inside_closure(x: &mut i32) {\n    // Actions which require unique access\n}\n\nfn outside_closure(x: &mut i32) {\n    // Actions which require unique access\n}\n\nfn foo(a: &mut i32) {\n    let bar = || {\n        inside_closure(a)\n    };\n    outside_closure(a); // error: cannot borrow `*a` as mutable because previous\n                        //        closure requires unique access.\n}\n```\n\nTo fix this error, you can place the closure in its own scope:\n\n```\nfn inside_closure(x: &mut i32) {}\nfn outside_closure(x: &mut i32) {}\n\nfn foo(a: &mut i32) {\n    {\n        let bar = || {\n            inside_closure(a)\n        };\n    } // borrow on `a` ends.\n    outside_closure(a); // ok!\n}\n```\n\nOr you can pass the variable as a parameter to the closure:\n\n```\nfn inside_closure(x: &mut i32)me":"/checkout/src/test/ui/E0501.rs","byte_start":1187,"byte_end":1190,"line_start":34,"line_end":34,"column_start":10,"column_end":13,"is_primary":false,"text":[{"text":"    drop(bar);","highlight_start":10,"highlight_end":13}],"label":"first borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access\n  --> /checkout/src/test/ui/E0501.rs:31:23\n   |\nLL |     let bar = || {\n   |               -- closure construction occurs here\nLL |         inside_closure(a)\n   |                        - first borrow occurs due to use of `a` in closure\n...\nLL |     outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access\n   |                       ^ borrow occurs here\n...\nLL |     drop(bar);\n   |          --- first borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:48:22] {"message":"For more information about this error, try `rustc --explain E0501`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0501`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/E0501.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:48:22] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/borrowck-closures-two-mut.rs stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 86    |                        second mutable borrow occurs here
[00:48:22] 87 LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:48:22] 88 LL |     drop((c1, c2));
[00:48:22] -    |           -- first borrow later used here
[00:48:22] +    |           -- first borrow used here, in later iteration of loop
[00:48:22] 90 
[00:48:22] 91 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:48:22] 
[00:48:22] 101    |                        second mutable borrow occurs here
[00:48:22] 101    |                        second mutable borrow occurs here
[00:48:22] 102 LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:48:22] 103 LL |     drop((c1, c2));
[00:48:22] -    |           -- first borrow later used here
[00:48:22] +    |           -- first borrow used here, in later iteration of loop
[00:48:22] 105 
[00:48:22] 106 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:48:22] 
[00:48:22] 116    |                        second mutable borrow occurs here
[00:48:22] 116    |                        second mutable borrow occurs here
[00:48:22] 117 LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:48:22] 118 LL |     drop((c1, c2));
[00:48:22] -    |           -- first borrow later used here
[00:48:22] +    |           -- first borrow used here, in later iteration of loop
[00:48:22] 120 
[00:48:22] 121 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:48:22] 
[00:48:22] 131    |                        second mutable borrow occurs here
[00:48:22] 132 ...
[00:48:22] 132 ...
[00:48:22] 133 LL |     drop((c1, c2));
[00:48:22] -    |           -- first borrow later used here
[00:48:22] +    |           -- first borrow used here, in later iteration of loop
[00:48:22] 135 
[00:48:22] 136 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:48:22] 
[00:48:22] 146    |                        second mutable borrow occurs here
[00:48:22] 147 ...
[00:48:22] 147 ...
[00:48:22] 148 LL |     drop((c1, c2));
[00:48:22] -    |           -- first borrow later used here
[00:48:22] +    |           -- first borrow used here, in later iteration of loop
[00:48:22] 151 error: aborting due to 10 previous errors
[00:48:22] 152 
[00:48:22] 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-closures-two-mut/borrowck-closures-two-mut.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args borrowck/borrowck-closures-two-mut.rs`
[00:48:22] error: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testi_start":27,"highlight_end":28}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:24:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 4);\n   |                        -- - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^ - borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\n...\nLL | }\n   | - first borrow ends here\n\n"}
[00:48:22] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1087,"byte_end":1089,"line_start":35,"line_end":35,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut x));","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1127,"byte_end":1129,"line_start":36,"line_end":36,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1277,"byte_end":1278,"line_start":39,"line_end":39,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"first borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1139,"byte_end":1140,"line_start":36,"line_end":36,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"borrow occurs due to use of `x` in closure","suggested_replacem references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1331,"byte_end":1333,"line_start":43,"line_end":43,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1365,"byte_end":1367,"line_start":44,"line_end":44,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1515,"byte_end":1516,"line_start":47,"line_end":47,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"first borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1377,"byte_end":1378,"line_start":44,"line_end":44,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1334,"byte_end":1335,"line_start":43,"line_end":43,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":27,"highlight_end":28}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:44:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 5);\n   |                        -- - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\n...\nLL | }\n   | - first borrow ends here\n\n"}
[00:48:22] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{orrowck-closures-two-mut.rs","byte_start":850,"byte_end":852,"line_start":24,"line_end":24,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":819,"byte_end":820,"line_start":23,"line_end":23,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 4);","highlight_start":27,"highlight_end":28}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":853,"byte_end":854,"line_start":24,"line_end":24,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":27,"highlight_end":28}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":984,"byte_end":986,"line_start":26,"line_end":26,"column_start":11,"column_end":13,"is_primary":false,"text":[{"text":"    drop((c1, c2));","highlight_start":11,"highlight_end":13}],"label":"first borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:24:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 4);\n   |                        -- - first borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^ - second borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL |     drop((c1, c2));\n   |           -- first borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `x` as mutable more than once at a time (Mir)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1087,"byte_end":1089,"line_start":35,"line_end":35,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut x));","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1127,"byte_end":1129,"line_start":36,"line_end":36,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1099,"byte_end":1100,"line_start":35,"line_end":35,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut x));","highlight_start":36,"highlight_end":37}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1139,"byte_end":1140,"line_start":36,"line_end":36,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1267,"byte_end":1269,"line_start":38,"line_end":38,"column_start":11,"column_end":13,"is_primary":false,"text":[{"text":"    drop((c1, c2));","highlight_start":11,"highlight_end":13}],"label":"first borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:36:24\n   |\nLL |     let c1 = to_fn_mut(|| set(&mut x));\n   |                        --          - first borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - second borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL |     drop((c1, c2));\n   |           -- first borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `x` as mutable more than once at a time (Mir)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1331,"byte_end":1333,"line_start":43,"line_end":43,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1365,"byte_end":1367,"line_start":44,"line_end":44,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1334,"byte_end":1335,"line_start":43,"line_end":43,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":27,"highlight_end":28}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1377,"byte_end":1378,"line_start":44,"line_end":44,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1505,"byte_end":1507,"line_start":46,"line_end":46,"column_start":11,"column_end":13,"is_primary":false,"text":[{"text":"    drop((c1, c2));","highlight_start":11,"highlight_end":13}],"label":"first borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:44:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 5);\n   |                        -- - first borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - second borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL |     drop((c1, c2));\n   |           -- first borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `x` as mutable more than once at a time (Mir)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1569,"byte_end":1571,"line_start":51,"line_end":51,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1603,"byte_end":1605,"line_start":52,"line_end":52,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    lprimary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut *x.f));","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1976,"byte_end":1978,"line_start":65,"line_end":65,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut *x.f));","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1946,"byte_end":1947,"line_start":64,"line_end":64,"column_start":37,"column_end":38,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut *x.f));","highlight_start":37,"highlight_end":38}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1989,"byte_end":1990,"line_start":65,"line_end":65,"column_start":37,"column_end":38,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut *x.f));","highlight_start":37,"highlight_end":38}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":2124,"byte_end":2126,"line_start":68,"liner iteration of loop
[00:48:22] 341 
[00:48:22] 342 error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/borrowck-describe-lvalue.mir.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args borrowck/borrowck-describe-lvalue.rs`
[00:48:22] 
[00:48:22] error in revision `mir`: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "mir" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/auxiliary" "-A" "unused"
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] ------------------------------------------
[00:48:22] stderr:
[00:48:22] stderr:
[00:48:22] ------------------------------------------
[00:48:22] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10093,"byte_end":10099,"line_start":294,"line_end":294,"column_start":21,"column_end":27,"is_primary":false,"text":[{"text":"            let y = &mut x;","highlight_start":21,"highlight_end":27}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10113,"byte_end":10119,"line_start":295,"line_end":295,"column_start":13,"column_end":19,"is_primary":true,"text":[{"text":"            &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time","highlight_start":13,"highlight_end":19}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","by,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10595,"byte_end":10601,"line_start":306,"line_end":306,"column_start":28,"column_end":34,"is_primary":false,"text":[{"text":"                   let y = &mut x;","highlight_start":28,"highlight_end":34}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10622,"byte_end":10628,"line_start":307,"line_end":307,"column_start":20,"column_end":26,"is_primary":true,"text":[{"text":"                   &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time","highlight_start":20,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10809,"byte_end":10815,"line_start":309,"line_end":309,"column_start":20,"column_end":26,"is_primary":false,"text":[{"text":"                   *y = 1;","highlight_start":20,"highlight_end":26}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:307:20\n   |\nLL |                    let y = &mut x;\n   |                            ------ first mutable borrow occurs here\nLL |                    &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time\n   |                    ^^^^^^ second mutable borrow occurs here\nLL |                    //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time\nLL |                    *y = 1;\n   |                    ------ first borrow later used here\n\n"}
[00:48:22] {"message":"captured variable cannot escape `FnMut` closure body","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10495,"byte_end":10862,"line_start":305,"line_end":311,"column_start":16,"column_end":18,"is_primary":true,"text":[{"text":"               || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body","highlight_start":16,"highlight_end":88},{"text":"                   let y = &mut x;","highlight_start":1,"highlight_end":35},{"text":"                   &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time","highlight_start":1,"highlight_end":98},{"text":"                   //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time","highlight_start":1,"highlight_end":89},{"text":"                   *y = 1;","highlight_start":1,"highlight_end":27},{"text":"                   drop(y);","highlight_start":1,"highlight_end":28},{"text":"                }","highlight_start":1,"highlight_end":18}],"label":"returns a closure that contains a reference to a captured variable, which then escapes the closure body","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10476,"byte_end":10477,"line_start":304,"line_end":304,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"           || {","highlight_start":13,"highlight_end":14}],"label":"inferred to be a `FnMut` closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`FnMut` closures only have access to their captured variables while they are executing...","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"...therefore, they cannot allow references to captured variables to escape","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: captured variable cannot escape `FnMut` closure body\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:305:16\n   |\nLL |              || {\n   |               - inferred to be a `FnMut` closure\nLL | /                || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body\nLL | |                    let y = &mut x;\nLL | |                    &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time\nLL | |                    //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time\nLL | |                    *y = 1;\nLL | |                    drop(y);\nLL | |                 }\n   | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body\n   |\n   = note: `FnMut` closures only have access to their captured variables while they are executing...\n   = note: ...therefore, they cannot allow references to captured variables to escape\n\n"}
[00:48:22] {"message":"cannot use `f.x` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1054,"byte_end":1055,"line_start":52,"line_end":52,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = f.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `f` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1069,"byte_end":1072,"line_start":53,"line_end":53,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `f`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1224,"byte_end":1225,"line_start":55,"line_end":55,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `f.x` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:53:9\n   |\nLL |         let x = f.x();\n   |                 - borrow of `f` occurs here\nLL |         f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed\n   |         ^^^ use of borrowed `f`\nLL |         //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:48:22] {"message":"cannot use `g.0` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1326,"byte_end":1327,"line_start":60,"line_end":60,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = g.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `g` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1341,"byte_end":1344,"line_start":61,"line_end":61,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `g`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1501,"byte_end":1502,"line_start":63,"line_end":63,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `g.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:61:9\n   |\nLL |         let x = g.x();\n   |                 - borrow of `g` occurs here\nLL |         g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed\n   |         ^^^ use of borrowed `g`\nLL |              //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:48:22] {"message":"cannot use `h.0` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `vaw is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1871,"byte_end":1872,"line_start":76,"line_end":76,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = e.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `e` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1915,"byte_end":1920,"line_start":78,"line_end":78,"column_start":20,"column_end":25,"is_primary":true,"text":[{"text":"            Baz::X(value) => value","highlight_start":20,"highlight_end":25}],"label":"use of borrowed `e`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2110,"byte_end":2111,"line_start":82,"line_end":82,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `e.0` because it was mutably borcan now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2792,"byte_end":2793,"line_start":103,"line_end":103,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = g.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `*g` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2807,"byte_end":2810,"line_start":104,"line_end":104,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `*g`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2967,"byte_end":2968,"line_start":106,"line_end":106,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `g.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:104:9\n   |\nLL |         let x = g.x();\n   |                 - borrow of `*g` occurs here\nLL |         g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed\n   |         ^^^ use of borrowed `*g`\nLL |              //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:48:22] {"message":"cannot use `h.0` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        letsrc/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3251,"byte_end":3252,"line_start":114,"line_end":114,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `h.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:112:9\n   |\nLL |         let x = &mut h.0;\n   |                 -------- borrow of `h.0` occurs here\nLL |         h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed\n   |         ^^^ use of borrowed `h.0`\nLL |              //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:48:22] {"message":"cannot use `e.0` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3357,"byte_end":3358,"line_start":119,"line_end":119,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = e.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `*e` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3402,"byte_end":3407,"line_start":121,"line_end":121,"column_start":20,"column_end":25,"is_primary":true,"text":[{"text":"            Baz::X(value) => value","highlight_start":20,"highlight_end":25}],"label":"use of borrowed `*e`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3597,"byte_end":3598,"line_start":125,"line_end":125,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `e.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:121:20\n   |\nLL |         let x = e.x();\n   |                 - borrow of `*e` occurs here\nLL |         match *e {\nLL |             Baz::X(value) => value\n   |                    ^^^^^ use of borrowed `*e`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:48:22] {"message":"cannot use `u.a` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of thebyte_start":4343,"byte_end":4344,"line_start":146,"line_end":146,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x, .., _, _] => println!(\"{}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:146:18\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, x, .., _, _] => println!(\"{}\", x),\n   |                  ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3998,"byte_end":4004,"line_start":138,"line_end":138,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"fit _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3998,"byte_end":4004,"line_start":138,"line_end":138,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4957,"byte_end":4958,"line_start":158,"line_end":158,"column_start":28,"column_end":29,"is_primary":true,"text":[{"text":"            &[_, _, .., _, x] => println!(\"{}\", x),","highlight_start":28,"highlight_end":29}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:158:28\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, _, .., _, x] => println!(\"{}\", x),\n   |                            ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","hd":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5634,"byte_end":5635,"line_start":176,"line_end":176,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x..] => println!(\"{:?}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:176:18\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, x..] => println!(\"{:?}\", x),\n   |                  ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5911,"byte_end":5912,"line_start":182,"line_end":182,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":"            &[x.., _] => println!(\"{:?}\", x),","highlight_start":15,"highlight_end":16}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:182:15\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[x.., _] => println!(\"{:?}\", x),\n   |               ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6194,"byte_end":6195,"line_start":188,"line_end":188,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x.., _] => println!(\"{:?}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:188:18\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, x.., _] => println!(\"{:?}\", x),\n   |                  ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot use `e` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","d_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7278,"byte_end":7279,"line_start":212,"line_end":212,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:202:18\n   |\nLL |         let x = &mut e;\n   |                 ------ mutable borrow occurs here\nLL |         match e {\nLL |             E::A(ref ax) =>\n   |                  ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `e.x` as immutable because it is also borrowed as mutable","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```\ block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9300,"byte_end":9306,"line_start":270,"line_end":270,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9316,"byte_end":9320,"line_start":271,"line_end":271,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"        v[0].y;","highlight_start":9,"highlight_end":13}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9564,"byte_end":9565,"line_start":275,"line_end":275,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `*v` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:271:9\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\nLL |         v[0].y;\n   |         ^^^^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot use `v[..].y` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    umn_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..].y` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:271:9\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\nLL |         v[0].y;\n   |         ^^^^^^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:48:22] {"message":"cannot borrow `v[..].x` as immutable because it is also borrowed as mutable","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/borrowck/borrowck-describe-lvalue.rs","byte_start":9764,"byte_end":9770,"line_start":283,"line_end":283,"column_start":24,"column_end":30,"is_primary":true,"text":[{"text":"            &[_, F {x: ref xf, ..}] => println!(\"{}\", xf),","highlight_start":24,"highlight_end":30}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9715,"byte_end":9721,"line_start":281,"line_end":281,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9997,"byte_end":9998,"line_start":288,"line_end":288,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:283:24\n   |\nLL |         let x = &mut v;\n   |                 ------ mutable borrow occurs here\nLL |         match v {\nLL |             &[_, F {x: ref xf, ..}] => println!(\"{}\", xf),\n   |                        ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `*block.current` as immutable because it is also borrowed as mutable","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/borrowck/borrowck-describe-lvalue.rs","byte_start":8474,"byte_end":8489,"line_start":245,"line_end":245,"column_start":29,"column_end":44,"is_primary":true,"text":[{"text":"            let p: &'a u8 = &*block.current;","highlight_start":29,"highlight_end":44}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":8434,"byte_end":8444,"line_start":244,"line_end":244,"column_start":21,"column_end":31,"is_primary":false,"text":[{"text":"            let x = &mut block;","highlight_start":21,"hise it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:260:33\n   |\nLL |             let x = &mut block;\n   |                     ---------- mutable borrow occurs here\nLL |             let p : *const u8 = &*(*block).current;\n   |                                 ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here\n...\nLL |             drop(x);\n   |                  - mutable borrow later used here\n\n"}
[00:48:22] {"message":"use of moved value: `x`","code":{"code":"E0382","explanation":"\nThis error occurs when an attempt is made to use a variable after its contents\nhave been moved elsewhere. For example:\n\n```compile_fail,E0382\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = MyStruct{ s: 5u32 };\n    let y = x;\n    x.s = 6;\n    println!(\"{}\", x.s);\n}\n```\n\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\nof `x` when we set `y`. This is fundamental to Rust's ownership system: outside\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\n\nSometimes we don't need to move the value. Using a reference, we can let another\nfunction borrow the value without changing its ownership. In the example below,\nwe don't actually have to move our string to `calculate_length`, we can give it\na reference to it with `&` instead.\n\n```\nfn main() {\n    let s1 = String::from(\"hello\");\n\n    let len = calculate_length(&s1);\n\n    println!(\"The length of '{}' is {}.\", s1, len);\n}\n\nfn calculate_length(s: &String) -> usize {\n    s.len()\n}\n```\n\nA mutable reference can be created with `&mut`.\n\nSometimes we don't want a reference, but a duplicate. All types marked `Clone`\ncan be duplicated by calling `.clone()`. Subsequent changes to a clone do not\naffect the original variable.\n\nMost types in the standard library are marked `Clone`. The example below\ndemonstrates using `clone()` on a string. `s1` is first set to \"many\", and then\ncopied to `s2`. Then the first character of `s1` is removed, without affecting\n`s2`. \"any many\" is printed to the console.\n\n```\nfn main() {\n    let mut s1 = String::from(\"many\");\n    let s2 = s1.clone();\n    s1.remove(0);\n    println!(\"{} {}\", s1, s2);\n}\n```\n\nIf we control the definition of a type, we can implement `Clone` on it ourselves\nwith `#[derive(Clone)]`.\n\nSome types have no ownership semantics at all and are trivial to duplicate. An\nexample is `i32` and the other number types. We don't have to call `.clone()` to\nclone them, because they are marked `Copy` in addition to `Clone`.  Implicit\ncloning is more convenient in this case. We can mark our own types `Copy` if\nall their members also are marked `Copy`.\n\nIn the example below, we implement a `Point` type. Because it only stores two\nintegers, we opt-out of ownership semantics with `Copy`. Then we can\n`let p2 = p1` without `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n    let mut p1 = Point{ x: -1, y: 2 };\n    let p2 = p1;\n    p1.x = 1;\n    println!(\"p1: {}, {}\", p1.x, p1.y);\n    println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don't control the struct's definition, or mutable shared\nownership is truly required, we can use `Rc` and `Rete","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x`\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:318:22\n   |\nLL |                 drop(x);\n   |                      - value moved here\nLL |                 drop(x); //[ast]~ ERROR use of moved value: `x`\n   |                      ^ value used here after move\n   |\n   = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait\n\n"}
[00:48:22] {"message":"aborting due to 32 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 32 previous errors\n\n"}
[00:48:22] {"message":"Some errors occurred: E0382, E0499, E0502, E0503.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0382, E0499, E0502, E0503.\n"}
[00:48:22] {"message":"For more information about an error, try `rustc --explain E0382`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0382`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/borrowck/borrowck-describe-lvalue.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs#mir stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 8    |         ^^^^^^ assignment to borrowed `_a` occurs here
[00:48:22] 9 ...
[00:48:22] 10 LL |     drop(b);
[00:48:22] -    |          - borrow later used here
[00:48:22] +    |          - borrow used here, in later iteration of loop
[00:48:22] 13 error: aborting due to previous error
[00:48:22] 14 
[00:48:22] 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs`
[00:48:22] 
[00:48:22] error in revision `mir`: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "mir" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir/auxiliary" "-A" "unused"
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] ------------------------------------------
[00:48:22] stderr:
[00:48:22] stderr:
[00:48:22] ------------------------------> /checkout/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:19:9\n   |\nLL |     let b = &mut _a;\n   |             ------- borrow of `_a` occurs here\n...\nLL |         _a = 4; //[ast]~ ERROR cannot assign to `_a`\n   |         ^^^^^^ assignment to borrowed `_a` occurs here\n...\nLL |     drop(b);\n   |          - borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:48:22] {"message":"For more information about this error, try `rustc --explain E0506`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0506`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/borrowck-match-already-borrowed.rs#mir stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 8    |         ^^^^^^ use of borrowed `foo`
[00:48:22] 9 ...
[00:48:22] 10 LL |     drop(p);
[00:48:22] -    |          - borrow later used here
[00:48:22] +    |          - borrow used here, in later iteration of loop
[00:48:22] 12 
[00:48:22] 13 error[E0503]: cannot use `foo.0` because it was mutably borrowed
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] The actual stderr differed from the expected stderr.
{\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs","byte_start":870,"byte_end":876,"line_start":34,"line_end":34,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"    let r = &mut x;","highlight_start":13,"highlight_end":19}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs","byte_start":908,"byte_end":909,"line_start":36,"line_end":36,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":"        x => x + 1, //[ast]~ ERROR [E0503]","highlight_start":9,"highlight_end":10}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs","byte_start":1090,"byte_end":1091,"line_start":41,"line_end":41,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    drop(r);","highlight_start":10,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs:36:9\n   |\nLL |     let r = &mut x;\n   |             ------ borrow of `x` occurs here\nLL |     let _ = match x {\nLL |         x => x + 1, //[ast]~ ERROR [E0503]\n   |         ^ use of borrowed `x`\n...\nLL |     drop(r);\n   |          - borrow later used here\n\n"}
[00:48:22] {"message":"cannot use `x` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main()rimary":false,"text":[{"text":"    let r = &mut x;","highlight_start":13,"highlight_end":19}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs","byte_start":995,"byte_end":996,"line_start":38,"line_end":38,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":"        y => y + 2, //[ast]~ ERROR [E0503]","highlight_start":9,"highlight_end":10}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs","byte_start":1090,"byte_end":1091,"line_start":41,"line_end":41,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    drop(r);","highlight_start":10,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-match-already-borrowed.rs:38:9\n   |\nLL |     let r = &mut x;\n   |             ------ borrow of `x` occurs here\n...\nLL |         y => y + 2, //[ast]~ ERROR [E0503]\n   |         ^ use of borrowed `x`\n...\nLL |     drop(r);\n   |          - borrow later used here\n\n"}
[00:48:22] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:48:22] {"message":"For more information about this error, try `rustc --explain E0503`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0503`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/borrowck/borrowck-match-already-borrowed.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/borrowck-overloaded-index-ref-index.rs#mir stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 7    |                      ^^ immutable borrow occurs here
[00:48:22] 8 ...
[00:48:22] 9 LL |     drop(rs);
[00:48:22] -    |          -- mutable borrow later used here
[00:48:22] +    |          -- mutable borrow used here, in later iteration of loop
[00:48:22] 12 error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable
[00:48:22] 13   --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7
[00:48:22] 
[00:48:22] 19    |       ^^ immutable borrow occurs here
[00:48:22] 19    |       ^^ immutable borrow occurs here
[00:48:22] 20 ...
[00:48:22] 21 LL |     drop(rs);
[00:48:22] -    |          -- mutable borrow later used here
[00:48:22] +    |          -- mutable borrow used here, in later iteration of loop
[00:48:22] 23 
[00:48:22] 24 error[E0594]: cannot assign to data in a `&` reference
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir/borrowck-overloaded-index-ref-index.mir.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args borrowck/borrowck-overloaded-index-ref-index.rs`
[00:48:22] 
[00:48:22] error in revision `mir`: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "mir" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir/auxiliary" "-A" "unused"
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] ------------------------------------------
[00:48:22] stderr:
[00:48:22] stderr:
[00:48:22] ------------------------------------------
[00:48:22] {"message":"cannot borrow `s` as immutable because it is also borrowed as mutable","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 `rue,"text":[{"text":"    f[&s] = 10;","highlight_start":7,"highlight_end":9}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs","byte_start":1295,"byte_end":1301,"line_start":61,"line_end":61,"column_start":14,"column_end":20,"is_primary":false,"text":[{"text":"    let rs = &mut s;","highlight_start":14,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs","byte_start":1896,"byte_end":1898,"line_start":74,"line_end":74,"column_start":10,"column_end":12,"is_primary":false,"text":[{"text":"    drop(rs);","highlight_start":10,"highlight_end":12}],"label":"mutable borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs:65:7\n   |\nLL |     let rs = &mut s;\n   |              ------ mutable borrow occurs here\n...\nLL |     f[&s] = 10;\n   |       ^^ immutable borrow occurs here\n...\nLL |     drop(rs);\n   |          -- mutable borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot assign to data in a `&` reference","code":{"code":"E0594","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs","byte_start":1751,"byte_end":1760,"line_start":71,"line_end":71,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    s[2] = 20;","highlight_start":5,"highlight_end":14}],"label":"cannot assign","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0594]: cannot assign to data in a `&` reference\n  --> /checkout/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs:71:5\n   |\nLL |     s[2] = 20;\n   |     ^^^^^^^^^ cannot assign\n\n"}
[00:48:22] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:48:22] {"message":"Some errors occurred: E0502, E0594.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0502, E0594.\n"}
[00:48:22] {"message":"For more information about an error, try `rustc --explain E0502`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0502`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/borrowck/borrowck-overloaded-index-ref-index.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/borrowck-unary-move.rs#mir stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 7    |          ^ move out of `x` occurs here
[00:48:22] 8 LL |     //[mir]~^ ERROR cannot move out of `x` because it is borrowed
[00:48:22] 9 LL |     *y
[00:48:22] -    |on":"\nA value was moved out while it was still borrowed.\n\nErroneous code example:\n\n```compile_fail,E0505\nstruct Value {}\n\nfn eat(val: Value) {}\n\nfn main() {\n    let x = Value{};\n    {\n        let _ref_to_val: &Value = &x;\n        eat(x);\n    }\n}\n```\n\nHere, the function `eat` takes the ownership of `x`. However,\n`x` cannot be moved because it was borrowed to `_ref_to_val`.\nTo fix that you can do few different things:\n\n* Try to avoid moving the variable.\n* Release borrow before move.\n* Implement the `Copy` trait on the type.\n\nExamples:\n\n```\nstruct Value {}\n\nfn eat(val: &Value) {}\n\nfn main() {\n    let x = Value{};\n    {\n        let _ref_to_val: &Value = &x;\n        eat(&x); // pass by reference, if it's possible\n    }\n}\n```\n\nOr:\n\n```\nstruct Value {}\n\nfn eat(val: Value) {}\n\nfn main() {\n    let x = Value{};\n    {\n        let _ref_to_val: &Value = &x;\n    }\n    eat(x); // release borrow and then move it.\n}\n```\n\nOr:\n\n```\n#[derive(Clone, Copy)] // implement Copy trait\nstruct Value {}\n\nfn eat(val: Value) {}\n\nfn main() {\n    let x = Value{};\n    {\n        let _ref_to_val: &Value = &x;\n        eat(x); // it will be copied here.\n    }\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-unary-move.rs","byte_start":599,"byte_end":602,"line_start":16,"line_end":16,"column_start":13,"column_end":16,"is_primary":false,"text":[{"text":"    let y = &*x;","highlight_start":13,"highlight_end":16}],"label":"borrow of `*x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-unary-move.rs","byte_start":613,"byte_end":614,"line_start":17,"line_end":17,"column_start":10,"column_end":11,"is_primary":true,"text":[{"text":"    free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed","highlight_start":10,"highlight_end":11}],"label":"move out of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-unary-move.rs","byte_start":748,"byte_end":750,"line_start":19,"line_end":19,"column_start":5,"column_end":7,"is_primary":false,"text":[{"text":"    *y","highlight_start":5,"highlight_end":7}],"label":"borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0505]: cannot move out of `x` because it is borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-unary-move.rs:17:10\n   |\nLL |     let y = &*x;\n   |             --- borrow of `*x` occurs here\nLL |     free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed\n   |          ^ move out of `x` occurs here\nLL |     //[mir]~^ ERROR cannot move out of `x` because it is borrowed\nLL |     *y\n   |     -- borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:48:22] {"message":"For more information about this error, try `rustc --explain E0505`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0505`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/borrowck/borrowck-unary-move.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/two-phase-activation-sharing-interference.rs#nll_target stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 7    |               ^^ immutable borrow occurs here
[00:48:22] 8 LL |     //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
[00:48:22] 9 LL |     *y += 1;
[00:48:22] -    |     ------- mutable borrow later used here
[00:48:22] +    |     ------- mutable borrow used here, in later iteration of loop
[00:48:22] 12 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
[00:48:22] 13   --> $DIR/two-phase-activation-sharing-interference.rs:50:13
[00:48:22] 
[00:48:22] 29    |             ^^ immutable borrow occurs here
[00:48:22] 29    |             ^^ immutable borrow occurs here
[00:48:22] 30 ...
[00:48:22] 31 LL |     *y += 1;
[00:48:22] -    |     ------- mutable borrow later used here
[00:48:22] +    |     ------- mutable borrow used here, in later iteration of loop
[00:48:22] 34 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
[00:48:22] 35   --> $DIR/two-phase-activation-sharing-interference.rs:72:14
[00:48:22] 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:te_start":1750,"byte_end":1757,"line_start":44,"line_end":44,"column_start":5,"column_end":12,"is_primary":false,"text":[{"text":"    *y += 1;","highlight_start":5,"highlight_end":12}],"label":"mutable borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs:42:15\n   |\nLL |     let y = &mut x;\n   |             ------ mutable borrow occurs here\nLL |     { let z = &x; read(z); }\n   |               ^^ immutable borrow occurs here\nLL |     //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable\nLL |     *y += 1;\n   |     ------- mutable borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot borrow `x` as immutable because it is also borrowed as mutable","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}\  |     |
[00:48:22] 8 LL | 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls/two-phase-cannot-nest-mut-self-calls.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args borrowck/two-phase-cannot-nest-mut-self-calls.rs`
[00:48:22] error: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs" "--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/borrowck/two-phase-cannot-nest-mut-self-calls/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-Z" "two-phase-borrows" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls/auxiliary" "-A" "unused"
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] ------------------------------------------
[00:48:22] stderr:
[00:48:22] stderr:
[00:48:22] ------------------------------------------
[00:48:22] {"message":"cannot borrow `vec` 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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs","byte_start":908,"byte_end":919,"line_start":26,"line_end":26,"column_start":9,"column_end":20,"is_primary":true,"text":[{"text":"        vec.push(2);","highlight_start":9,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs","byte_start":889,"byte_end":892,"line_start":24,"line_end":24,"column_start":5,"column_end":8,"is_primary":false,"text":[{"text":"    vec.get({","highlight_start":5,"highlight_end":8}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-cannot-nest-m    |         first mutable borrow occurs here
[00:48:22] -    |         first borrow later used by call
[00:48:22] +    |         first borrow used by call, in later iteration of loop
[00:48:22] 9 
[00:48:22] 10 error[E0382]: use of moved value: `*f`
[00:48:22] 
[00:48:22] 
[00:48:22] 22    |         - ^ second mutable borrow occurs here
[00:48:22] 24    |         first mutable borrow occurs here
[00:48:22] -    |         first borrow later used by call
[00:48:22] -    |         first borrow later used by call
[00:48:22] +    |         first borrow used by call, in later iteration of loop
[00:48:22] 26 
[00:48:22] 27 error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
[00:48:22] 
[00:48:22] 61    |     | |
[00:48:22] 62    |     | immutable borrow occurs here
[00:48:22] 63    |     mutable borrow occurs here
[00:48:22] 63    |     mutable borrow occurs here
[00:48:22] -    |     mutable borrow later used here
[00:48:22] +    |     mutable borrow used here, in later iteration of loop
[00:48:22] 65 
[00:48:22] 66 error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
[00:48:22] 
[00:48:22] 71    |     | |
[00:48:22] 72    |     | immutable borrow occurs here
[00:48:22] 73    |     mutable borrow occurs here
[00:48:22] 73    |     mutable borrow occurs here
[00:48:22] -    |     mutable borrow later used here
[00:48:22] +    |     mutable borrow used here, in later iteration of loop
[00:48:22] 76 error: aborting due to 9 previous errors
[00:48:22] 77 
[00:48:22] 
[00:48:22] 
[00:48:22] 
[00:48:22] The actual stderr differed from the expected stderr.
[00:48:22] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-nonrecv-autoref.nll/two-phase-nonrecv-autoref.nll.stderr
[00:48:22] To update references, rerun the tests and pass the `--bless` flag
[00:48:22] To only update this specific test, also pass `--test-args borrowck/two-phase-nonrecv-autoref.rs`
[00:48:22] 
[00:48:22] error in revision `nll`: 1 errors occurred comparing output.
[00:48:22] status: exit code: 1
[00:48:22] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "nll" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-nonrecv-autoref.nll/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-Z" "two-phase-borrows" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-nonrecv-autoref.nll/auxiliary" "-A" "unused"
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] ------------------------------------------
[00:48:22] stderr:
[00:48:22] stderr:
[00:48:22] ------------------------------------------
[00:48:22] {"message":"cannot borrow `*f` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":2868,"byte_end":2869,"line_start":70,"line_end":70,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":2870,"byte_end":2871,"line_start":70,"line_end":70,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"        f(f(10));","highlight_start":11,"highlight_end":12}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":2868,"byte_end":2869,"line_start":70,"line_end":70,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":"first borrow used by call, in later  required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the chapter in the\nBook:\n\nhttps://doc.rust-lang.org/book/first-edition/ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3266,"byte_end":3267,"line_start":79,"line_end":79,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3268,"byte_end":3269,"line_start":79,"line_end":79,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"        f(f(10));","highlight_start":11,"highlight_end":12}],"label":"value used here after move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0382]: use of moved value: `*f`\n  --> /checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs:79:11\n   |\nLL |         f(f(10));\n   |         - ^ value used here after move\n   |         |\n   |         value moved here\n\n"}
[00:48:22] {"message":"cannot borrow `*f` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3493,"byte_end":3494,"line_start":86,"line_end":86,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3495,"byte_end":3496,"line_start":86,"line_end":86,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"        f(f(10));","highlight_start":11,"highlight_end":12}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3493,"byte_end":3494,"line_start":86,"line_end":86,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":"first borrow used by call, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `*f` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs:86:11\n   |\nLL |         f(f(10));\n   |         - ^ second mutable borrow occurs here\n   |         |\n   |         first mutable borrow occurs here\n   |         first borrow used by call, in later iteration of loop\n\n"}
[00:48:22] {"message":"cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined","code":{"code":"E0161","explanation":"\nA value was moved. However, its size was not known at compile time, and only\nvalues of a known size can be moved.\n\nErroneous code example:\n\n```compile_fail\n#![feature(box_syntax)]\n\nfn main() {\n    let array: &[isize] = &[1, 2, 3];\n    let _x: Box<[isize]> = box *array;\n    // error: cannot move a value of type [isize]: the size of [isize] cannot\n    //        be statically determined\n}\n```\n\nIn Rust, you can only move a value when its size is known at compile time.\n\nTo work around this restriction, consider \"hiding\" the value behind a reference:\neither `&x` or `&mut x`. Since a reference has a fixed size, this lets you move\nit around as usual. Example:\n\n```\n#![feature(box_syntax)]\n\nfn main() {\n    let array: &[isize] = &[1, 2, 3];\n    let _x: Box<&[isize]> = box array; // ok!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3880,"byte_end":3881,"line_start":95,"line_end":95,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined\n  --> /checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs:95:9\n   |\nLL |         f(f(10));\n   |         ^\n\n"}
[00:48:22] {"message":"cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined","code":{"code":"E0161","explanation":"\nA value was moved. However, its size was not known at compile time, and only\nvalues of a known size can be moved.\n\nErroneous code example:\n\n```compile_fail\n#![feature(box_syntax)]\n\nfn main() {\n    let array: &[isize] = &[1, 2, 3];\n    let _x: Box<[isize]> = box *array;\n    // error: cannot move a value of type [isize]: the size of [isize] cannot\n    //        be statically determined\n}\n```\n\nIn Rust, you can only move a value when its size is known at compile time.\n\nTo work around this restriction, consider \"hiding\" the value behind a reference:\neither `&x` or `&mut x`. Since a reference has a fixed size, this lets you move\nit around as usual. Example:\n\n```\n#![feature(box_syntax)]\n\nfn main() {\n    let array: &[isize] = &[1, 2, 3];\n    let _x: Box<&[isize]> = box array; // ok!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3882,"byte_end":3883,"line_start":95,"line_end":95,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"        f(f(10));","highlight_start":11,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined\n  --> /checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs:95:11\n   |\nLL |         f(f(10));\n   |           ^\n\n"}
[00:48:22] {"message":"use of moved value: `*f`","code":{"code":"E0382","explanation":"\nThis error occurs when an attempt is made to use a variable after its contents\nhave been moved elsewhere. For example:\n\n```compile_fail,E0382\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = MyStruct{ s: 5u32 };\n    let y = x;\n    x.s = 6;\n    println!(\"{}\", x.s);\n}\n```\n\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\nof `x` when we set `y`. This is fundamental to Rust's ownership system: outside\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\n\nSometimes we don't need to move the value. Using a reference, we can let another\nfunction borrow the value without c,"line_start":173,"line_end":173,"column_start":7,"column_end":8,"is_primary":true,"text":[{"text":"    i[i[3]] = i[4];","highlight_start":7,"highlight_end":8}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":6019,"byte_end":6020,"line_start":173,"line_end":173,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    i[i[3]] = i[4];","highlight_start":5,"highlight_end":6}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":6019,"byte_end":6026,"line_start":173,"line_end":173,"column_start":5,"column_end":12,"is_primary":false,"text":[{"text":"    i[i[3]] = i[4];","highlight_start":5,"highlight_end":12}],"label":"mutable borrow used here, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs:173:7\n   |\nLL |     i[i[3]] = i[4];\n   |     --^----\n   |     | |\n   |     | immutable borrow occurs here\n   |     mutable borrow occurs here\n   |     mutable borrow used here, in later iteration of loop\n\n"}
[00:48:22] {"message":"aborting due to 9 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 9 previous errors\n\n"}
[00:48:22] {"message":"Some errors occurred: E0161, E0382, E0499, E0502.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0161, E0382, E0499, E0502.\n"}
[00:48:22] {"message":"For more information about an error, try `rustc --explain E0161`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0161`.\n"}
[00:48:22] ------------------------------------------
[00:48:22] 
[00:48:22] thread '[ui] ui/borrowck/two-phase-nonrecv-autoref.rs#nll' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:48:22] 
[00:48:22] 
[00:48:22] ---- [ui] ui/borrowck/two-phase-surprise-no-conflict.rs#nll stdout ----
[00:48:22] diff of stderr:
[00:48:22] 
[00:48:22] 25 LL |     reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));
[00:48:22] 26    |     --- ---------------                           ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] +    |     |   first borrow used by call, in later iteration of loop
[00:48:22] 29    |     first mutable borrow occurs here
[00:48:22] 30 
[00:48:22] 31 error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
[00:48:22] 
[00:48:22] 34 LL |     reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
[00:48:22] 35    |     --- --------------                               ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] +    |     |   first borrow used by call, in later iteration of loop
[00:48:22] 38    |     first mutable borrow occurs here
[00:48:22] 39 
[00:48:22] 40 error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
[00:48:22] 
[00:48:22] 43 LL |     reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
[00:48:22] 44    |     --- -------------                               ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] +    |     |   first borrow used by call, in later iteration of loop
[00:48:22] 47    |     first mutable borrow occurs here
[00:48:22] 48 
[00:48:22] 49 error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
[00:48:22] 
[00:48:22] 52 LL |     reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));
[00:48:22] 53    |     --- ------------                       ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] -    |     |   first borrow later used by call
[00:48:22] +    |     |   first borrow used by call, in later iteration of loop
[00:48:22] 56    |     first mutable borrow occurs here
[00:48:22] 57 
[00:48:22] 58 error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable
[00:48:22] 
[00:48:22] 104 LL |     reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
[00:48:22] 105    |     --- --------------                               ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:48:22] 106    |     |   |
[00:48:22] -    |     |   firstmutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":1502,"byte_end":1512,"line_start":39,"line_end":39,"column_start":27,"column_end":37,"is_primary":false,"text":[{"text":"        let _mut_borrow = &mut *self;","highlight_start":27,"highlight_end":37}],"label":"borrow of `*self` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/":5,"column_end":8,"is_primary":false,"text":[{"text":"    reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));","highlight_start":5,"highlight_end":8}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6235,"byte_end":6252,"line_start":151,"line_end":151,"column_start":51,"column_end":68,"is_primary":true,"text":[{"text":"    reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));","highlight_start":51,"highlight_end":68}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6193,"byte_end":6208,"line_start":151,"line_end":151,"column_start":9,"column_end":24,"is_primary":false,"text":[{"text":"    reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));","highlight_start":9,"highlight_end":24}],"label":"first borrow used by call, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:151:51\n   |\nLL |     reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));\n   |     --- ---------------                           ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here\n   |     |   |\n   |     |   first borrow used by call, in later iteration of loop\n   |     first mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `reg.sess_mut` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6437,"byte_end":6440,"line_start":156,"line_end":156,"column_start":5,"column_end":8,"is_primary":false,"text":[{"text":"    reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));","highlight_start":5,"highlight_end":8}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6486,"byte_end":6503,"line_start":156,"line_end":156,"column_start":54,"column_end":71,"is_primary":true,"text":[{"text":"    reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));","highlight_start":54,"highlight_end":71}],"label":"second mutable borrow occle:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6688,"byte_end":6691,"line_start":161,"line_end":161,"column_start":5,"column_end":8,"is_primary":false,"text":[{"text":"    reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));","highlight_start":5,"highlight_end":8}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6736,"byte_end":6753,"line_start":161,"line_end":161,"column_start":53,"column_end":70,"is_primary":true,"text":[{"text":"    reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));","highlight_start":53,"highlight_end":70}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6692,"byte_end":6705,"line_start":161,"line_end":161,"column_start":9,"column_end":22,"is_primary":false,"text":[{"text":"    reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));","highlight_start":9,"highlight_end":22}],"label":"first borrow used by call, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:161:53\n   |\nLL |     reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));\n   |     --- -------------                               ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here\n   |     |   |\n   |     |   first borrow used by call, in later iteration of loop\n   |     first mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `reg.sess_mut` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6938,"byte_end":6941,"line_start":166,"line_end":166,"column_start":5,"column_end":8,"is_primary":false,"text":[{"text":"    reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));","highlight_start":5,"highlight_end":8}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6977,"byte_end":6994,"line_start":166,"line_end":166,"column_start":44,"column_end":61,"is_primary":true,"text":[{"text":"    reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));","highlight_start":44,"highlight_end":61}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":6942,"byte_end":6954,"line_start":166,"line_end":166,"column_start":9,"column_end":21,"is_primary":false,"text":[{"text":"    reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));","highlight_start":9,"highlight_end":21}],"label":"first borrow used by call, in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:166:44\n   |\nLL |     reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));\n   |     --- ------------                       ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here\n   |     |   |\n   |     |   first borrow used by call, in later iteration of loop\n   |     first mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `*reg` 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\nExampl,"line_end":183,"column_start":23,"column_end":64,"is_primary":false,"text":[{"text":"    reg.register_univ(Box::new(CapturePass::new(&reg.sess_mut)));","highlight_start":23,"highlight_end":64}],"label":"cast requires that `reg.sess_mut` is borrowed for `'a`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:183:5\n   |\nLL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) {\n   |                     -- lifetime `'a` defined here\n...\nLL |     reg.register_univ(Box::new(CapturePass::new(&reg.sess_mut)));\n   |     ^^^^^^^^^^^^^^^^^^-----------------------------------------^\n   |     |                 |                         |\n   |     |                 |                         immutable borrow occurs here\n   |     |                 cast requires that `reg.sess_mut` is borrowed for `'a`\n   |     mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `*reg` 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 thatnull}],"children":[],"rendered":"error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:188:5\n   |\nLL |     reg.register_ref(&CapturePass::new(&reg.sess_mut));\n   |     ^^^^------------^^^^^^^^^^^^^^^^^^^-------------^^\n   |     |   |                              |\n   |     |   |                              immutable borrow occurs here\n   |     |   immutable borrow later used by call\n   |     mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `*reg` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":8555,"byte_end":8572,"line_start":200,"line_end":200,"column_start":54,"column_end":71,"is_primary":false,"text":[{"text":"    reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));","highlight_start":54,"highlight_end":71}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":8506,"byte_end":8575,"line_start":200,"line_end":200,"column_start":5,"column_end":74,"is_primary":true,"text":[{"text":"    reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));","highlight_start":5,"highlight_end":74}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":8510,"byte_end":8524,"line_start":200,"line_end":200,"column_start":9,"column_end":23,"is_primary":false,"text":[{"text":"    reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));","highlight_start":9,"highlight_end":23}],"label":"first borrow later used by call","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `*reg` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:200:5\n   |\nLL |     reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));\n   |     ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^\n   |     |   |                                            |\n   |     |   |                                            first mutable borrow occurs here\n   |     |   first borrow later used by call\n   |     second mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `reg.sess_mut` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":8506,"byte_end":8509,"line_start":200,"line_end":200,"column_start":5,"column_end":8,"is_primary":false,"text":[{"text":"    reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));","highlight_start":5,"highlight_end":8}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs","byte_start":8555,"byte_end":8572,"line_start":200,"line_end":200,"column_start":54,"column_end":71,"is_primary":true,"text":[{"text":"    reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));","highlight_start":54,"highlight_end":71}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borapturePass::new_mut(&mut reg.sess_mut)));","highlight_start":23,"highlight_end":72}],"label":"cast requires that `reg.sess_mut` is borrowed for `'a`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `*reg` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs:206:5\n   |\nLL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) {\n   |                     -- lifetime `'a` defined here\n...\nLL |     reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));\n   |     ^^^^^^^^^^^^^^^^^^-------------------------------------------------^\n   |     |                 |                             |\n   |     |                 |                             first mutable borrow occurs here\n   |     |                 cast requires that `reg.sess_mut` is borrowed for `'a`\n   |     second mutable borrow occurs here\n\n"}
[00:48:22] {"message":"cannot borrow `reg.sess_mut` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a  |                 ---- ---------  ^^^^^^^ immutable borrow occurs here
[00:48:22] -    |                 |    mutable borrow later used by call
[00:48:22] -    |                 |    mutable borrow later used by call
[00:48:22] +    |                 |    mutable borrow used by call, in later iteration of loop
[00:48:22] 20 
[00:48:22] 20 
[00:48:22] 21 error[E0502]: cannot borrow `*self.cx_mut` as immutable because it is also borrowed as mutable
[00:48:22] 
[00:48:22] 24 LL |                 self.hash_expr(&self.cx_mut.body(eid).value);
[00:48:22] 25    |                 ---- ---------  ^^^^^^^^^^^ immutable borrow occurs here
[00:48:22] -    |                 |    mutable borrow later used by call
[00:48:22] -    |                 |    mutable borrow later used by call
[00:48:22] +    |                 |    mutable borrow used by call, in later iteration of loop
[00:48:22] 29 
[00:48:22] 30 error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
[00:48:22] 
[00:48:22] 
[00:48:22] 33 LL |     reg.register_static(Box::new(TrivialPass::new(&reg.sess_mut)));
[00:48:22] 34    |     --- ---------------                           ^^^^^^^^^^^^^ immutable borrow occurs here
[00:48:22] -    |     |   mutable borrow later used by call
[00:48:22] -    |     |   mutable borrow later used by call
---
[00:48:22]     [ui] ui/borrowck/borrowck-describe-lvalue.rs#mir
[00:48:22]     [ui] ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs#mir
[00:48:22]     [ui] ui/borrowck/borrowck-match-already-borrowed.rs#mir
[00:48:22]     [ui] ui/borrowck/borrowck-overloaded-index-ref-index.rs#mir
[00:48:22]     [ui] ui/borrowck/borrobin/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-5.0/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" "5.0.0\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:48:22] 
[00:48:22] 
[00:48:22] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:48:22] Build completed unsuccessfully in 0:03:36
[00:48:22] Build completed unsuccessfully in 0:03:36
[00:48:22] make: *** [check] Error 1
[00:48:22] Makefile:58: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0af23bc1
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Nov 20 22:29:24 UTC 2018

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)

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from d8f9775 to 15b775e Compare November 20, 2018 23:04
@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.
travis_time:end:18b09ab0:start=1542755152075231628,finish=1542755219307626052,duration=67232394424
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:50:16] .................................................................................................... 100/5043
[00:50:19] .................................................................................................... 200/5043
[00:50:22] ..............................ii...........................................ii...................ii.. 300/5043
[00:50:24] ..............................................................................................iii... 400/5043
[00:50:27] .....iiiiiiii.iii.........F..................iii...........................................i........ 500/5043
[00:50:34] .................................................................................................... 700/5043
[00:50:40] ..................................................................................i...........i..... 800/5043
[00:50:43] .................................................................................................... 900/5043
[00:50:43] .................................................................................................... 900/5043
[00:50:47] .iiiii...................iiiiii..................................................................... 1000/5043
[00:50:49] ............................................................................iiiiiiii................ 1100/5043
[00:50:53] .................................................................................................... 1300/5043
[00:50:55] .................................................................................................... 1400/5043
[00:50:58] .................................i.................................................................. 1500/5043
[00:51:01] ..i.........ii.........................................................i............................ 1600/5043
---
[00:51:21] .................................................................................................... 2200/5043
[00:51:25] .................................................................................................... 2300/5043
[00:51:29] .................................................................................................... 2400/5043
[00:51:33] .................................................................................................... 2500/5043
[00:51:36] .....................................................................................iiiiiiiii...... 2600/5043
[00:51:43] ...................................................ii............................................... 2800/5043
[00:51:45] .................................................................................................... 2900/5043
[00:51:49] .................................................................................................... 3000/5043
[00:51:52] ...............................................i.................................................... 3100/5043
---
[00:52:11] ..................................................................i................................. 3800/5043
[00:52:13] .................................................................................................... 3900/5043
[00:52:16] .................................................................................................... 4000/5043
[00:52:19] .................................................................................................... 4100/5043
[00:52:22] ...................................................................................................i 4200/5043
[00:52:25] iiii.............F........i......................................................................... 4300/5043
[00:52:29] .................................................................................................... 4400/5043
[00:52:32] .......................................................................................F............ 4500/5043
[00:52:39] ..........i......................................................................................... 4700/5043
[00:52:43] .................................................................................................... 4800/5043
[00:52:45] .................................................................................................... 4900/5043
[00:52:45] .................................................................................................... 4900/5043
ed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/sy creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":592,"byte_end":598,"line_start":14,"line_end":14,"column_start":23,"column_end":29,"is_primary":false,"text":[{"text":"    let mut _y = vec![&mut x];","highlight_start":23,"highlight_end":29}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":839,"byte_end":845,"line_start":19,"line_end":19,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        x += 1; //~ ERROR cannot assign","highlight_start":9,"highlight_end":15}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":travis_time:end:09062880:start=1542755227417439551,finish=1542758397125595476,duration=3169708155925
travis_time:start:1c18535e
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Nov 20 23:59:57 UTC 2018
Tue, 20 Nov 2018 23:59:57 GMT

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 Nov 27, 2018

Ping fromt triage @spastorino: It looks like your PR failed on travis.

@spastorino
Copy link
Member Author

@TimNN yeah, we are currently discussing this on Zulip. Consider this PR a WIP. Adding WIP to the title to state this clearly.

@spastorino spastorino changed the title Erroneous loop diagnostic in nll [WIP] Erroneous loop diagnostic in nll Nov 28, 2018
@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from 15b775e to 1062697 Compare November 30, 2018 18:58
@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.
travis_time:end:03295236:start=1543604886720081360,finish=1543604940412944832,duration=53692863472
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:53:32] 
[00:53:32] running 5104 tests
[00:53:35] .................................................................................................... 100/5104
[00:53:38] .................................................................................................... 200/5104
[00:53:41] .............................ii............................F...............ii...................ii.. 300/5104
[00:53:43] ........................F.....................................................................iii... 400/5104
[00:53:46] .....iiiiiiii.iii.........F..................iii...........................................i........ 500/5104
[00:53:53] .................................................................................................... 700/5104
[00:53:59] ................................................................................................i... 800/5104
[00:54:03] ............i....................................................................................... 900/5104
[00:54:07] ...................iiiii..................ii.iiii................................................... 1000/5104
---
[00:54:46] .................................................................................................... 2300/5104
[00:54:51] .................................................................................................... 2400/5104
[00:54:55] .................................................................................................... 2500/5104
[00:54:58] .................................................................................................... 2600/5104
[00:55:02] ............iiiiiiiii............................................................................... 2700/5104
[00:55:05] ....................................................F.........................ii.................... 2800/5104
[00:55:12] .................................................................................................... 3000/5104
[00:55:15] ..........................................................................i......................... 3100/5104
[00:55:18] .................................................................................................... 3200/5104
[00:55:22] ....................................ii..i..ii....................................................... 3300/5104
---
[00:55:36] .................................................................................................... 3900/5104
[00:55:43] .................................................................................................... 4000/5104
[00:55:46] .................................................................................................... 4100/5104
[00:55:49] .................................................................................................... 4200/5104
[00:55:53] .........................................................iiiii.............F........i............... 4300/5104
[00:56:00] .................................................................................................... 4500/5104
[00:56:00] .................................................................................................... 4500/5104
[00:56:03] .......................................F..F......................................................... 4600/5104
[00:56:10] .................................................................................................... 4800/5104
[00:56:14] .................................................................................................... 4900/5104
[00:56:17] .................................................................................................... 5000/5104
[00:56:17] .................................................................................................... 5000/5104
[00:56:19] .......................................F...i........................................................ 5100/5104
[00:56:19] failures:
[00:56:19] 
[00:56:19] ---- [ui (nll)] ui/borrowck/borrowck-for-loop-head-linkage.rs stdout ----
[00:56:19] diff of stderr:
[00:56:19] diff of stderr:
[00:56:19] 
[00:56:19] 5    |               -------
[00:56:19] 6    |               |
[00:56:19] 7    |               immutable borrow occurs here
[00:56:19] -    |               immutable borrow used here, in later -head-linkage.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/borrowck/borrowck-for-loop-head-linkage.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"cannot borrow `vector` 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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":605,"byte_end":629,"line_start":17,"line_end":17,"column_start":9,"column_end":33,"is_primary":true,"text":[{"text":"        vector.extend(repeat(0));      //~ ERROR cannot borrow","highlight_start":9,"highlight_end":33}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":550,"byte_end":557,"line_start":15,"line_end":15,"column_start":15,"column_end":22,"is_primary":false,"text":[{"text":"    for &x in &vector {","highlight_start":15,"highlight_end":22}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":550,"byte_end":557,"line_start":15,"line_end":15,"column_start":15,"column_end":22,"is_primary":false,"text":[{"text":"    for &x in &vector {","highlight_start":15,"highlight_end":22}],"label":"immutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs:17:9\n   |\nLL |     for &x in &vector {\n   |               -------\n   |               |\n   |               immutable borrow occurs here\n   |               immutable borrow later used here\nLL |         let cap = vector.capacity();\nLL |         vector.extend(repeat(0));      //~ ERROR cannot borrow\n   |         ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\n\n"}
[00:56:19] {"message":"cannot borrow `vector` 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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":668,"byte_end":674,"line_start":18,"line_end":18,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        vector[1] = 5;   //~ ERROR cannot borrow","highlight_start":9,"highlight_end":15}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-for-loop-head-linkage.rs","byte_start":550,"byte_end":557,"line_start":15,"line_end":15,"column_start":15,"column_end":22,"is_primary":false,"text":[{"text":"    for &x in &vector {","highlight_start":15,"highlight_end":22}],"label":"immutable borrow occurs here","suggested_replacement":null,"sugge19] ---- [ui (nll)] ui/borrowck/borrowck-mut-borrow-linear-errors.rs#ast stdout ----
[00:56:19] 
[00:56:19] 
[00:56:19] 4 LL |             1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
[00:56:19] 5    |                    ----      ^^^^^^ second mutable borrow occurs here
[00:56:19] 6    |                    |
[00:56:19] -    |                    first borrow used here, in later iteration of loop
[00:56:19] 8 ...
[00:56:19] 8 ...
[00:56:19] 9 LL |             _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
[00:56:19] 10    |                              ------ first mutable borrow occurs here
[00:56:19] 13   --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30
[00:56:19] 14    |
[00:56:19] 14    |
[00:56:19] 15 LL |             1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
[00:56:19] -    |                    ---- first borrow used here, in later iteration of loop
[00:56:19] +    |                    ---- first borrow later used here
[00:56:19] 17 LL |             //[mir]~^ ERROR [E0499]
[00:56:19] 18 LL |             2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
[00:56:19] 19    |                              ^^^^^^ second mutable borrow occurs here
[00:56:19] 
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll/borrowck-mut-borrow-linear-errors.ast.nll.stderr
[00:56:19] To update references, rerun the tests and pass the `--bless` flag
[00:56:19] To only update this specific test, also pass `--test-args borrowck/borrowck-mut-borrow-linear-errors.rs`
[00:56:19] 
[00:56:19] error in revision `ast`: 1 errors occurred comparing output.
[00:56:19] status: exit code: 1
[00:56:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "ast" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":1066,"byte_end":1072,"line_start":27,"line_end":27,"column_start":30,"column_end":36,"is_primary":false,"text":[{"text":"            _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":868,"byte_end":874,"line_start":23,"line_end":23,"column_start":30,"column_end":36,"is_primary":true,"text":[{"text":"            1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":858,"byte_end":862,"line_start":23,"line_end":23,"column_start":20,"column_end":24,"is_primary":false,"text":[{"text":"            1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":20,"highlight_end":24}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/btion":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs","byte_start":1066,"byte_end":1072,"line_start":27,"line_end":27,"column_start":30,"column_end":36,"is_primary":true,"text":[{"text":"            _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]","highlight_start":30,"highlight_end":36}],"label":"mutable borrow starts here in previous iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs:27:30\n   |\nLL |             _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\n   |                              ^^^^^^ mutable borrow starts here in previous iteration of loop\n\n"}
[00:56:19] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:56:19] {"message":"For more information about this error, try `rustc --explain E0499`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0499`.\n"}
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] thread '[ui (nll)] ui/borrowck/borrowck-mut-borrow-linear-errors.rs#ast' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:56:19] 
[00:56:19] 
[00:56:19] ---- [ui (nll)] ui/borrowck/mut-borrow-outside-loop.rs stdout ----
[00:56:19] diff of stderr:
[00:56:19] 
[00:56:19] 17    |                            ^^^^^^^^^^^^^^^ second mutable borrow occurs here
[00:56:19] 18 LL |         inner_second.use_mut();
[00:56:19] 19 LL |         inner_first.use_mut();
[00:56:19] -    |         ----------- first borrow used here, in later iteration of loop
[00:56:19] +    |         ----------- first borrow later used here
[00:56:19] 22 error: aborting due to 2 previous errors
[00:56:19] 23 
[00:56:19] 
[00:56:19] 
[00:56:19] 
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/mut-borrow-outside-loop.nll/mut-borrow-outside-loop.nll.stderr
[00:56:19] To update references, rerun the tests and pass the `--bless` flag
[00:56:19] To only update this specific test, also pass `--test-args borrowck/mut-borrow-outside-loop.rs`
[00:56:19] error: 1 errors occurred comparing output.
[00:56:19] status: exit code: 1
[00:56:19] status: exit code: 1
[00:56:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs" "--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/borrowck/mut-borrow-outside-loop.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/borrowck/mut-borrow-outside-loop.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"cannot borrow `void` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":645,"byte_end":654,"line_start":16,"line_end":16,"column_start":17,"column_end":26,"is_primary":false,"text":[{"text":"    let first = &mut void;","highlight_start":17,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":673,"byte_end":682,"line_start":17,"line_end":17,"column_start":18,"column_end":27,"is_primary":true,"text":[{"text":"    let second = &mut void; //~ ERROR cannot borrow","highlight_start":18,"highlight_end":27}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":712,"byte_end":717,"line_start":18,"line_end":18,"column_start":5,"column_end":10,"is_primary":false,"text":[{"text":"    first.use_mut();","highlight_start":5,"highlight_end":10}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `void` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs:17:18\n   |\nLL |     let first = &mut void;\n   |                 --------- first mutable borrow occurs here\nLL |     let second = &mut void; //~ ERROR cannot borrow\n   |                  ^^^^^^^^^ second mutable borrow occurs here\nLL |     first.use_mut();\n   |     ----- first borrow later used here\n\n"}
[00:56:19] {"message":"cannot borrow `inner_void` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":823,"byte_end":838,"line_start":24,"line_end":24,"column_start":27,"column_end":42,"is_primary":false,"text":[{"text":"        let inner_first = &mut inner_void;","highlight_start":27,"highlight_end":42}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":867,"byte_end":882,"line_start":25,"line_end":25,"column_start":28,"column_end":43,"is_primary":true,"text":[{"text":"        let inner_second = &mut inner_void; //~ ERROR cannot borrow","highlight_start":28,"highlight_end":43}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":948,"byte_end":959,"line_start":27,"line_end":27,"column_start":9,"column_endowed value does not live long enough
[00:56:19] 6 ...
[00:56:19] 7 LL |         acc += cnt2;
[00:56:19] -    |         --- borrow used here, in later iteration of loop
[00:56:19] 9 ...
[00:56:19] 9 ...
[00:56:19] 10 LL |     }
[00:56:19] 11    |     - `line` dropped here while still borrowed
[00:56:19] 
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-52126-assign-op-invariance.nll/issue-52126-assign-op-invariance.nll.stderr
[00:56:19] To update references, rerun the tests and pass the `--bless` flag
[00:56:19] To only update this specific test, also pass `--test-args issues/issue-52126-assign-op-invariance.rs`
[00:56:19] error: 1 errors occurred comparing output.
[00:56:19] status: exit code: 1
[00:56:19] status: exit code: 1
[00:56:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs" "--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/issues/issue-52126-assign-op-invariance.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/issues/issue-52126-assign-op-invariance.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"`line` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs","byte_start":1442,"byte_end":1446,"line_start":44,"line_end":44,"column_start":28,"column_end":32,"is_primary":true,"text":[{"text":"        let v: Vec<&str> = line.split_whitespace().collect();","highlight_start":28,"highlight_end":32}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs","byte_start":2011,"byte_end":2012,"line_start":58,"line_end":58,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"`line` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs","byte_start":1858,"byte_end":1861,"line_start":55,"line_end":55,"column_start":9,"column_end":12,"is_primary":false,"text":[{"text":"        acc += cnt2;","highlight_start":9,"highlight_end":12}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `line` does not live long enough\n  --> /checkout/src/test/ui/issues/issue-52126-assign-op-invariance.rs:44:28\n   |\nLL |         let v: Vec<&str> = line.split_whitespace().collect();\n   |                            ^^^^ borrowed value does not live long enough\n...\nLL |         acc += cnt2;\n   |         --- borrow later used here\n...\nLL |     }\n   |     - `line` dropped here while still borrowed\n\n"}
[00:56:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:19] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] thread '[ui (nll)] ui/issues/issue-52126-assign-op-invariance.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:56:19] 
[00:56:19] 
[00:56:19] ---- [ui (nll)] ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs stdout ----
[00:56:19] diff of stderr:
[00:56:19] 
[00:56:19] 7    |         ^^^^^^^^^^^^ mutable borrow occurs here
[00:56:19] 8 LL |         //~^ ERROR cannot borrow `foo` as mutable
[00:56:19] 9 LL |         println!("foo={:?}", *string);
[00:56:19] -    |                              ------- immutable borrow used here, in later iteration of loop
[00:56:19] 11 
[00:56:19] 12 error: aborting due to previous error
[00:56:19] 13 
[00:56:19] 
[00:56:19] 
[00:56:19] 
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll/borrowck-issue-49631.nll.stderr
[00:56:19] To update references, rerun the tests and pass the `--bless` flag
[00:56:19] To only update this specific test, also pass `--test-args rfc-2005-default-binding-mode/borrowck-issue-49631.rs`
[00:56:19] error: 1 errors occurred comparing output.
[00:56:19] status: exit code: 1
[00:56:19] status: exit code: 1
[00:56:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs" "--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/rfc-2005-default-binding-mode/borrowck-issue-49631.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"cannot borrow `foo` 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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs","byte_start":916,"byte_end":928,"line_start":30,"line_end":30,"column_start":9,"column_end":21,"is_primary":true,"text":[{"text":"        foo.mutate();","highlight_start":9,"highlight_end":21}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs","byte_start":896,"byte_end":899,"line_start":29,"line_end":29,"column_start":34,"column_end":37,"is_primary":false,"text":[{"text":"    while let Some(Ok(string)) = foo.get() {","highlight_start":34,"highlight_end":37}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs","byte_start":1009,"byte_end":1016,"line_start":32,"line_end":32,"column_start":30,"column_end":37,"is_primary":false,"text":[{"text":"        println!(\"foo={:?}\", *string);","highlight_start":30,"highlight_end":37}],"label":"immutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs:30:9\n   |\nLL |     while let Some(Ok(string)) = foo.get() {\n   |                                  --- immutable borrow occurs here\nLL |         foo.mutate();\n   |         ^^^^^^^^^^^^ mutable borrow occurs here\nLL |         //~^ ERROR cannot borrow `foo` as mutable\nLL |         println!(\"foo={:?}\", *string);\n   |                              ------- immutable borrow later used here\n\n"}
[00:56:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to pre-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/span/regions-escape-loop-via-variable.rs" "--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/span/regions-escape-loop-via-variable.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/span/regions-escape-loop-via-variable.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"`x` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-variable.rs","byte_start":722,"byte_end":724,"line_start":21,"line_end":21,"column_start":13,"column_end":15,"is_primary":true,"text":[{"text":"        p = &x;","highlight_start":13,"highlight_end":15}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-variable.rs","byte_start":730,"byte_end":731,"line_start":22,"line_end":22,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-variable.rs","byte_start":706,"byte_end":708,"line_start":20,"line_end":20,"column_start":21,"column_end":23,"is_primary":false,"text":[{"text":"        let x = 1 + *p;","highlight_start":21,"highlight_end":23}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-variable.rs:21:13\n   |\nLL |         let x = 1 + *p;\n   |                     -- borrow later used here\nLL |         p = &x;\n   |             ^^ borrowed value does not live long enough\nLL |     }\n   |     - `x` dropped here while still borrowed\n\n"}
[00:56:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:19] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] thread '[ui (nll)] ui/span/regions-escape-loop-via-variable.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:56:19] 
[00:56:19] 
[00:56:19] ---- [ui (nll)] ui/span/regions-escape-loop-via-vec.rs stdout ----
[00:56:19] diff of stderr:
[00:56:19] 
[00:56:19] 7    |           ^ use of borrowed `x`
[00:56:19] 8 LL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
[00:56:19] 9 LL |         _y.push(&mut z);
[00:56:19] -    |         -- borrow used here, in later iteration of loop
[00:56:19] 11 
[00:56:19] 11 
[00:56:19] 12 error[E0503]: cannot use `x` because it was mutably borrowed
[00:56:19] 
[00:56:19] 
[00:56:19] 18 LL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
[00:56:19] 19    |                     ^ use of borrowed `x`
[00:56:19] 20 LL |         _y.push(&mut z);
[00:56:19] -    |         -- borrow used here, in later iteration of loop
[00:56:19] 22 
[00:56:19] 22 
[00:56:19] 23 error[E0597]: `z` does not live long enough
[00:56:19] 
[00:56:19] 
[00:56:19] 26 LL |         _y.push(&mut z);
[00:56:19] 27    |         --      ^^^^^^ borrowed value does not live long enough
[00:56:19] 28    |         |
[00:56:19] -    |         borrow used here, in later iteration of loop
[00:56:19] 30 ...
[00:56:19] 30 ...
[00:56:19] 31 LL |     }
[00:56:19] 32    |     - `z` dropped here while still borrowed
[00:56:19] 38    |                       ------ borrow of `x` occurs here
[00:56:19] 39 ...
[00:56:19] 39 ...
[00:56:19] 40 LL |         _y.push(&mut z);
[00:56:19] -    |         -- borrow used here, in later iteration of loop
[00:56:19] +    |         -- borrow later used here
[00:56:19] 42 LL |         //~^ ERROR `z` does not live long enough
[00:56:19] 43 LL |         x += 1; //~ ERROR cannot assign
[00:56:19] 44    |         ^^^^^^ use of borrowed `x`
[00:56:19] 
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] The actual stderr differed from the expected stderr.
[00:56:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/regions-escape-loop-via-vec.nll/regions-escape-loop-via-vec.nll.stderr
[00:56:19] To update references, rerun the tests and pass the `--bless` flag
[00:56:19] To only update this specific test, also pass `--test-args span/regions-escape-loop-via-vec.rs`
[00:56:19] error: 1 errors occurred comparing output.
[00:56:19] status: exit code: 1
[00:56:19] status: exit code: 1
[00:56:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs" "--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/span/"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-vec.rs:15:11\n   |\nLL |     let mut _y = vec![&mut x];\n   |                       ------ borrow of `x` occurs here\nLL |     while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed\n   |           ^ use of borrowed `x`\nLL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed\nLL |         _y.push(&mut z);\n   |         -- borrow later used here\n\n"}
[00:56:19] {"message":"cannot use `x` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":592,"byte_end":598,"line_start":14,"line_end":14,"column_start":23,"column_end":29,"is_primary":false,"text":[{"text":"    let mut _y = vec![&mut x];","highlight_start":23,"highlight_end":29}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":697,"byte_end":698,"line_start":16,"line_end":16,"column_start":21,"column_end":22,"is_primary":true,"text":[{"text":"        let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed","highlight_start":21,"highlight_end":22}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":765,"byte_end":767,"line_start":17,"line_end":17,"column_start":9,"column_end":11,"is_primary":false,"text":[{"text":"        _y.push(&mut z);","highlight_start":9,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-vec.rs:16:21\n   |\nLL |     let mut _y = vec![&mut x];\n   |                       ------ borrow of `x` occurs here\nLL |     while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed\nLL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed\n   |                     ^ use of borrowed `x`\nLL |         _y.push(&mut z);\n   |         -- borrow later used here\n\n"}
[00:56:19] {"message":"`z` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":773,"byte_end":779,"line_start":17,"line_end":17,"column_start":17,"column_end":23,"is_primary":true,"text":[{"text":"        _y.push(&mut z);","highlight_start":17,"highlight_end":23}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":875,"byte_end":876,"line_start":20,"line_end":20,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"`z` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":765,"byte_end":767,"line_start":17,"line_end":17,"column_start":9,"column_end":11,"is_primary":false,"text":[{"text":"        _y.push(&mut z);","highlight_start":9,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `z` does not live long enough\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-vec.rs:17:17\n   |\nLL |         _y.push(&mut z);\n   |         --      ^^^^^^ borrowed value does not live long enough\n   |         |\n   |         borrow later used here\n...\nLL |     }\n   |     - `z` dropped here while still borrowed\n\n"}
[00:56:19] {"message":"cannot use `x` because it was mutably borrowed","code":{"code":"E0503","explanatiia-vec.rs","byte_start":592,"byte_end":598,"line_start":14,"line_end":14,"column_start":23,"column_end":29,"is_primary":false,"text":[{"text":"    let mut _y = vec![&mut x];","highlight_start":23,"highlight_end":29}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":839,"byte_end":845,"line_start":19,"line_end":19,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        x += 1; //~ ERROR cannot assign","highlight_start":9,"highlight_end":15}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":765,"byte_end":767,"line_start":17,"line_end":17,"column_start":9,"column_end":11,"is_primary":false,"text":[{"text":"        _y.push(&mut z);","highlight_start":9,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-vec.rs:19:9\n   |\nLL |     let mut _y = vec![&mut x];\n   |                       ------ borrow of `x` occurs here\n...\nLL |         _y.push(&mut z);\n   |         -- borrow later used here\nLL |         //~^ ERROR `z` does not live long enough\nLL |         x += 1; //~ ERROR cannot assign\n   |         ^^^^^^ use of borrowed `x`\n\n"}
[00:56:19] {"message":"aborting due to 4 previous errors"est-args vec/vec-mut-iter-borrow.rs`
[00:56:19] error: 1 errors occurred comparing output.
[00:56:19] status: exit code: 1
[00:56:19] status: exit code: 1
[00:56:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/vec/vec-mut-iter-borrow.rs" "--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/vec/vec-mut-iter-borrow.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-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/ui/vec/vec-mut-iter-borrow.nll/auxiliary" "-A" "unused"
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] ------------------------------------------
[00:56:19] stderr:
[00:56:19] stderr:
[00:56:19] ------------------------------------------
[00:56:19] {"message":"cannot borrow `xs` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/vec/vec-mut-iter-borrow.rs","byte_start":530,"byte_end":537,"line_start":14,"line_end":14,"column_start":14,"column_end":21,"is_primary":false,"text":[{"text":"    for x in &mut xs {","highlight_start":14,"highlight_end":21}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/vec/vec-mut-iter-borrow.rs","byte_start":548,"byte_end":550,"line_start":15,"line_end":15,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"        xs.push(1) //~ ERROR cannot borrow `xs`","highlight_start":9,"highlight_end":11}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/vec/vec-mut-iter-borrow.rs","byte_start":530,"byte_end":537,"line_start":14,"line_end":14,"column_start":14,"column_end":21,"is_primary":false,"text":[{"text":"    for x in &mut xs {","highlight_start":14,"highlight_end":21}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `xs` as mutable more than once at a time\n  --> /checkout/src/test/ui/vec/vec-mut-iter-borrow.rs:15:9\n   |\nLL |     for x in &mut xs {\n   |              -------\n   |              |\n   |              first mutable borrow occurs here\n   |              first borrow later used here\nLL |         xs.push(1) //~ ERROR cannot borrow `xs`\n   |         ^^ second mutable borrow occurs here\n\n"}
[00:56:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:19] {"message":"For more information about this error, try `rustc --explain E0499`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0499`.\n"}
[00:56:19] ------------------------------------------
[00:56:19] 
[00:56:19] thread '[ui (nll)] ui/vec/vec-mut-iter-borrow.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:56:19] 
---
[00:56:19] 
[00:56:19] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:503:22
[00:56:19] 
[00:56:19] 
[00:56: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-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--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" "5.0.0\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:56:19] 
[00:56:19] 
[00:56:19] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:56:19] Build completed unsuccessfully in 0:06:54
[00:56:19] Build completed unsuccessfully in 0:06:54
[00:56:19] make: *** [check] Error 1
[00:56:19] Makefile:58: recipe for target 'check' failed
 [ -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:15ebcbec
travis_time:start:15ebcbec
$ 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:037f7040
$ 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)

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from 1062697 to 065cced Compare December 1, 2018 00:05
@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.
travis_time:end:24105152:start=1543622839934118287,finish=1543622893918813437,duration=53984695150
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:48:44] .................................................................................................... 100/5105
[00:48:47] .................................................................................................... 200/5105
[00:48:49] .............................ii............................................ii...................ii.. 300/5105
[00:48:52] ..............................................................................................iii... 400/5105
[00:48:55] .....iiiiiiii.iii.........F..................iii...........................................i........ 500/5105
[00:49:01] .................................................................................................... 700/5105
[00:49:07] .................................................................................................i.. 800/5105
[00:49:11] .............i...................................................................................... 900/5105
[00:49:14] ....................iiiii...................iiiiii.................................................. 1000/5105
---
[00:49:52] .................................................................................................... 2300/5105
[00:49:56] .................................................................................................... 2400/5105
[00:49:59] .................................................................................................... 2500/5105
[00:50:03] .................................................................................................... 2600/5105
[00:50:06] ............iiiiiiiii............................................................................... 2700/5105
[00:50:12] .................................................................................................... 2900/5105
[00:50:16] .................................................................................................... 3000/5105
[00:50:19] ..........................................................................i......................... 3100/5105
[00:50:22] .................................................................................................... 3200/5105
---
[00:50:38] .................................................................................................... 3900/5105
[00:50:45] .................................................................................................... 4000/5105
[00:50:48] .................................................................................................... 4100/5105
[00:50:50] .................................................................................................... 4200/5105
[00:50:54] ..........................................................iiiii............F.........i.............. 4300/5105
[00:51:01] .................................................................................................... 4500/5105
[00:51:01] .................................................................................................... 4500/5105
[00:51:04] ..........................................F......................................................... 4600/5105
[00:51:11] .................................................................................................... 4800/5105
[00:51:14] .................................................................................................... 4900/5105
[00:51:14] .................................................................................................... 4900/5105
https://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":823,"byte_end":838,"line_start":24,"line_end":24,"column_start":27,"column_end":42,"is_primary":false,"text":[{"text":"        let inner_first = &mut inner_void;","highlight_start":27,"highlight_end":42}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":867,"byte_end":882,"line_start":25,"line_end":25,"column_start":28,"column_end":43,"is_primary":true,"text":[{"text":"        let inner_second = &mut inner_void; //~ ERROR cannot borrow","highlight_start":28,"highlight_end":43}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/mut-borrow-outside-loop.rs","byte_start":948,"byte_end":959,"line_start":27,"line_end":27,"column_start":9,"column_end":20,"is_primary":false,"text":[{"text":"        inner_first.use_mut();","highlight_start":9,"highlight_end":20}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `inner_void` as mutable more than once at a time\n  --> /checkout/simary":true,"text":[{"text":"        let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed","highlight_start":21,"highlight_end":22}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/span/regions-escape-loop-via-vec.rs","byte_start":765,"byte_end":767,"line_start":17,"line_end":17,"column_start":9,"column_end":11,"is_primary":false,"text":[{"text":"        _y.push(&mut z);","highlight_start":9,"highlight_end":11}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/span/regions-escape-loop-via-vec.rs:16:21\n   |\nLL |     let mut _y = vec![&mut x];\n   |                       ------ borrow of `x` occurs here\nLL |     while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed\nLL |         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed\n   |                     ^ use of borrowed `x`\nLL |         _y.push(&mut z);\n   |         -- borrow later used here\n\n"}
[00:51:19] {"message":"`z` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y
[00:51:19] 
[00:51:19] 
[00:51:19] 
[00:51: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-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--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" "5.0.0\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:51:19] 
[00:51:19] 
[00:51:19] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:51:19] Build completed unsuccessfully in 0:06:26
[00:51:19] Build completed unsuccessfully in 0:06:26
[00:51:19] Makefile:58: recipe for target 'check' failed
[00:51:19] make: *** [check] Error 1

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)

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from 065cced to 08f6d0b Compare December 1, 2018 14:48
@spastorino spastorino changed the title [WIP] Erroneous loop diagnostic in nll Erroneous loop diagnostic in nll Dec 1, 2018
block: *bb,
})
.filter(|s| visited_locations.insert(*s))
.filter(|s| !self.is_back_edge(location, *s) || to == *s),
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this miss this case:

loop {
    loop {
        if cond { break };
        use(v);
    }
    borrow(&mut v);
}

It is only possible to reach the borrow from the use by going through the back-edge in the inner loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that a usable definition of "a cfg node N is inside the loop whose header is the cfg node L" is:

  1. L dominates N
  2. there is a path from N to L that goes only through nodes that L dominates.

Because:

  1. L dominates all the nodes within the loop, so that if N is within the loop and has a path within the loop that goes back to L, the condition will be true.
  2. If N is outside of the loop but dominated by L, then going back to L will require going through an outer loop header, which will dominate N and therefore not be dominated by it.

Copy link
Contributor

@arielb1 arielb1 Dec 3, 2018

Choose a reason for hiding this comment

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

another class of "confusible" cases:

loop {
    loop {
        if cond { break; }
        borrow(&v);
    }
    use(&mut v);
}

is the same MIR as

loop {
    if cond {
        use(&mut v);
    } else {
        borrow(&v);
    }
}

but the error message should be different

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the goal was to "first do no harm", right? i.e., stop printing "previous iteration of loop" at wrong spots, but not necessarily always print in all the "right spots"? In that case:

If we do merge the PR, these are good examples to put on the "follow-up" issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, let me go back now that I checked current behavior to see what @arielb1 suggested. @arielb1 are you saying that it'd be better not to use the "outermost backedge" but instead adopt a different strategy? If so, I suspect that is likely true.

Copy link
Contributor

@arielb1 arielb1 Dec 5, 2018

Choose a reason for hiding this comment

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

So, given the second example, I think that any CFG-based model will be fairly inaccurate, so I'm ok with this

@bors
Copy link
Contributor

bors commented Dec 7, 2018

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

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch 2 times, most recently from 7931e12 to 461ec7a Compare January 8, 2019 05:05
@rust-lang rust-lang deleted a comment from rust-highfive Jan 8, 2019
@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch 3 times, most recently from 8a1ae3c to 6b6a0c5 Compare January 8, 2019 11:08
@spastorino
Copy link
Member Author

@Dylan-DPC I don't think so. Niko even did an r+. The problem with this issue is that tests are failing on x86_64-gnu-nopt, could be something related to successors not returning the same order on different platforms. I need to investigate but I'm working on a different issue for now.

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from fe2f1f8 to 06ec1a4 Compare February 3, 2019 21:25
@spastorino
Copy link
Member Author

spastorino commented Feb 3, 2019

@nikomatsakis let me know if with the last commit added the rest of the cases also look good to you. Left the changes in a different commit so you can more easily review the non approved changes. When you think it's ok I can squash this last commit in the right place and get rid of this noisy last one :).

@@ -5,7 +5,7 @@ LL | for &x in &vector {
| -------
| |
| immutable borrow occurs here
| immutable borrow used here, in later iteration of loop
Copy link
Member Author

Choose a reason for hiding this comment

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

@nikomatsakis this change is for the worse, I don't remember you saying that with this approach some things were going to be worse but I couldn't find the discussion about it and if this is one of those cases or it's just an error in the code :).

@@ -17,7 +17,7 @@ LL | for &x in &vector {
| -------
| |
| immutable borrow occurs here
| immutable borrow used here, in later iteration of loop
Copy link
Member Author

Choose a reason for hiding this comment

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

Same thing here.

@@ -13,7 +13,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-mut-borrow-linear-errors.rs:15:30
|
LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
| ---- first borrow used here, in later iteration of loop
Copy link
Member Author

Choose a reason for hiding this comment

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

The two changes in this files also happened in AST and we already approved that.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see an analogous message in
https://github.com/rust-lang/rust/blob/06ec1a422a5ff147c3a09af7eb80db77459e797b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr#L4-L20

Were you referring to a different file when you said "also happened in AST" ? Or do you mean that the above diagnostic is analogous to what NLL is being changed to produced above?

(To be clear, I think AST is currently producing a third totally different diagnostic message right now for this case...)

Copy link
Member

Choose a reason for hiding this comment

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

(note in particular that the AST-borrowck error message is highlighting a use of x in the second match arm, while NLL is highlighting a use of addr in the first match arm.)

I'm not saying I object to the change. I'm just trying to understand the comment you have written here on github about it.

@@ -5,7 +5,7 @@ LL | let v: Vec<&str> = line.split_whitespace().collect();
| ^^^^ borrowed value does not live long enough
...
LL | acc += cnt2;
| --- borrow used here, in later iteration of loop
Copy link
Member Author

Choose a reason for hiding this comment

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

This is better

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyway the error is still ungreat :)

@bors
Copy link
Contributor

bors commented Feb 9, 2019

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

@pnkfelix
Copy link
Member

I think the blessed changes from 06ec1a4 are fine. Of course we now need to rebase the PR.

r=me under assumption that the rebase is trivial.

@pnkfelix
Copy link
Member

Hey @spastorino do you think you'll have a chance to rebase this in the near future?

@spastorino
Copy link
Member Author

@pnkfelix yes, I can rebase it now. I was wondering if the changes are considered good enough or better than what we currently have because there are things that are "improvable" or work for future PRs.

@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from 06ec1a4 to 02117c3 Compare February 20, 2019 14:53
@spastorino
Copy link
Member Author

@pnkfelix rebased, let's see if CI is still ok :)

This commit fixes the logic of detecting when a use happen in a later
iteration of where a borrow was defined

Fixes rust-lang#53773
@spastorino spastorino force-pushed the erroneous-loop-diagnostic-in-nll branch from 02117c3 to a12982c Compare February 20, 2019 15:17
@rust-lang rust-lang deleted a comment from rust-highfive Feb 20, 2019
@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 20, 2019

📌 Commit a12982c 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 Feb 20, 2019
@bors
Copy link
Contributor

bors commented Feb 22, 2019

⌛ Testing commit a12982c with merge 1005f3b...

bors added a commit that referenced this pull request Feb 22, 2019
…=pnkfelix

Erroneous loop diagnostic in nll

Closes #53773

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Feb 22, 2019

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 22, 2019
@bors
Copy link
Contributor

bors commented Feb 22, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants