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

Remove adt_def from projections and downcasts in MIR #59514

Merged
merged 2 commits into from
Apr 3, 2019

Conversation

tmandry
Copy link
Member

@tmandry tmandry commented Mar 29, 2019

As part of optimizing generator layouts in MIR, we'd like to allow downcasting generators to variants which do not have a corresponding def_id, since they are created by the compiler.

This refactor hopes to allow that, without regressing perf.

r? @eddyb

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 29, 2019
@eddyb
Copy link
Member

eddyb commented Mar 29, 2019

@bors try

@bors
Copy link
Contributor

bors commented Mar 29, 2019

⌛ Trying commit f4a1628 with merge 24a40d8...

bors added a commit that referenced this pull request Mar 29, 2019
…=<try>

Remove adt_def from projections and downcasts in MIR

As part of optimizing generator layouts in MIR, we'd like to allow downcasting generators to variants which do not have a corresponding `def_id`, since they are created by the compiler.

This refactor hopes to allow that, without regressing perf.

r? @eddyb
@tmandry tmandry force-pushed the remove-adt-def-from-projection-elem branch from f4a1628 to d1b02f7 Compare March 29, 2019 03:37
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.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:001168ec:start=1553830693456851826,finish=1553830695802015183,duration=2345163357
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[01:09:51] 
[01:09:51] running 5501 tests
[01:09:53] .................................................................................................... 100/5501
[01:09:56] .................................................................................................... 200/5501
[01:09:59] ...........................................................F........................................ 300/5501
[01:10:06] .................................................................................................... 500/5501
[01:10:09] ..........................................i......................................................... 600/5501
[01:10:13] .................................................................................................... 700/5501
[01:10:18] .................................................................................................... 800/5501
---
[01:13:10] 
[01:13:10] 269 LL |         drop(x);
[01:13:10] 270    |              - mutable borrow later used here
[01:13:10] 271 
[01:13:10] - error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable
[01:13:10] + error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable
[01:13:10] 274    |
[01:13:10] 275 LL |         let x = &mut e;
[01:13:10] 
[01:13:10] 
[01:13:10] 
[01:13:10] The actual stderr differed from the expected stderr.
[01:13:10] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/borrowck-describe-lvalue.mir.stderr
[01:13:10] To update references, rerun the tests and pass the `--bless` flag
[01:13:10] To only update this specific test, also pass `--test-args borrowck/borrowck-describe-lvalue.rs`
[01:13:10] 
[01:13:10] error in revision `mir`: 1 errors occurred comparing output.
[01:13:10] status: exit code: 1
[01:13:10] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs" "-Zthreads=1" "--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"
[01:13:10] ------------------------------------------
[01:13:10] 
[01:13:10] ------------------------------------------
[01:13:10] stderr:
[01:13:10] stderr:
[01:13:10] ------------------------------------------
[01:13:10] {"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/book/ch04-02-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":9625,"byte_end":9631,"line_start":284,"line_end":284,"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":9645,"byte_end":9651,"line_start":285,"line_end":285,"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","byte_start":9826,"byte_end":9832,"line_start":287,"line_end":287,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"            *y = 1;","highlight_start":13,"highlight_end":19}],"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:285:13\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"}
[01:13:10] {"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/book/ch04-02-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":10042,"byte_end":10048,"line_start":295,"line_end":295,"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":10069,"byte_end":10075,"line_start":296,"line_end":296,"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":10256,"byte_end":10262,"line_start":298,"line_end":298,"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:296: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"}
[01:13:10] {"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":9942,"byte_end":10309,"line_start":294,"line_end":300,"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":9923,"byte_end":9924,"line_start":293,"line_end":293,"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:294: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"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":587,"byte_end":588,"line_start":42,"line_end":42,"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":602,"byte_end":605,"line_start":43,"line_end":43,"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":757,"byte_end":758,"line_start":45,"line_end":45,"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:43: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"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":859,"byte_end":860,"line_start":50,"line_end":50,"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":874,"byte_end":877,"line_start":51,"line_end":51,"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":1034,"byte_end":1035,"line_start":53,"line_end":53,"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:51: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"}
[01:13:10] {"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 `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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1130,"byte_end":1138,"line_start":58,"line_end":58,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut h.0;","highlight_start":17,"highlight_end":25}],"label":"borrow of `h.0` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1148,"byte_end":1151,"line_start":59,"line_end":59,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `h.0`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1308,"byte_end":1309,"line_start":61,"line_end":61,"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:59: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"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1404,"byte_end":1405,"line_start":66,"line_end":66,"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":1448,"byte_end":1453,"line_start":68,"line_end":68,"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":1643,"byte_end":1644,"line_start":72,"line_end":72,"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:68: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"}
[01:13:10] {"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 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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1748,"byte_end":1756,"line_start":77,"line_end":77,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":17,"highlight_end":25}],"label":"borrow of `u.a` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1766,"byte_end":1769,"line_start":78,"line_end":78,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `u.a`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1926,"byte_end":1927,"line_start":80,"line_end":80,"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 `u.a` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:78:9\n   |\nLL |         let x = &mut u.a;\n   |                 -------- borrow of `u.a` occurs here\nLL |         u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed\n   |         ^^^ use of borrowed `u.a`\nLL |              //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2038,"byte_end":2039,"line_start":85,"line_end":85,"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":2053,"byte_end":2056,"line_start":86,"line_end":86,"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":2213,"byte_end":2214,"line_start":88,"line_end":88,"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:86: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"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2325,"byte_end":2326,"line_start":93,"line_end":93,"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":2340,"byte_end":2343,"line_start":94,"line_end":94,"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":2500,"byte_end":2501,"line_start":96,"line_end":96,"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:94: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"}
[01:13:10] {"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 `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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2606,"byte_end":2614,"line_start":101,"line_end":101,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut h.0;","highlight_start":17,"highlight_end":25}],"label":"borrow of `h.0` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2624,"byte_end":2627,"line_start":102,"line_end":102,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `h.0`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2784,"byte_end":2785,"line_start":104,"line_end":104,"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:102: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"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2890,"byte_end":2891,"line_start":109,"line_end":109,"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":2935,"byte_end":2940,"line_start":111,"line_end":111,"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":3130,"byte_end":3131,"line_start":115,"line_end":115,"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:111: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"}
[01:13:10] {"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 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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3245,"byte_end":3253,"line_start":120,"line_end":120,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":17,"highlight_end":25}],"label":"borrow of `u.a` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3263,"byte_end":3266,"line_start":121,"line_end":121,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `u.a`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3423,"byte_end":3424,"line_start":123,"line_end":123,"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 `u.a` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:121:9\n   |\nLL |         let x = &mut u.a;\n   |                 -------- borrow of `u.a` occurs here\nLL |         u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed\n   |         ^^^ use of borrowed `u.a`\nLL |              //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3531,"byte_end":3537,"line_start":128,"line_end":128,"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":3571,"byte_end":3572,"line_start":130,"line_end":130,"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":4760,"byte_end":4761,"line_start":153,"line_end":153,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:130:15\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\nLL |         match v {\nLL |             &[x, _, .., _, _] => println!(\"{}\", x),\n   |               ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3531,"byte_end":3537,"line_start":128,"line_end":128,"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":3876,"byte_end":3877,"line_start":136,"line_end":136,"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":4760,"byte_end":4761,"line_start":153,"line_end":153,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:136: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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3531,"byte_end":3537,"line_start":128,"line_end":128,"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":4185,"byte_end":4186,"line_start":142,"line_end":142,"column_start":25,"column_end":26,"is_primary":true,"text":[{"text":"            &[_, _, .., x, _] => println!(\"{}\", x),","highlight_start":25,"highlight_end":26}],"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":4760,"byte_end":4761,"line_start":153,"line_end":153,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:142:25\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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3531,"byte_end":3537,"line_start":128,"line_end":128,"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":4490,"byte_end":4491,"line_start":148,"line_end":148,"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":4760,"byte_end":4761,"line_start":153,"line_end":153,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:148: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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4847,"byte_end":4853,"line_start":158,"line_end":158,"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":4887,"byte_end":4888,"line_start":160,"line_end":160,"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":5988,"byte_end":5989,"line_start":183,"line_end":183,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:160:15\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\nLL |         match v {\nLL |             &[x..] => println!(\"{:?}\", x),\n   |               ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4847,"byte_end":4853,"line_start":158,"line_end":158,"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":5167,"byte_end":5168,"line_start":166,"line_end":166,"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":5988,"byte_end":5989,"line_start":183,"line_end":183,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:166: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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4847,"byte_end":4853,"line_start":158,"line_end":158,"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":5444,"byte_end":5445,"line_start":172,"line_end":172,"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":5988,"byte_end":5989,"line_start":183,"line_end":183,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:172: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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4847,"byte_end":4853,"line_start":158,"line_end":158,"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":5727,"byte_end":5728,"line_start":178,"line_end":178,"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":5988,"byte_end":5989,"line_start":183,"line_end":183,"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 `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:178: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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6113,"byte_end":6119,"line_start":190,"line_end":190,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut e;","highlight_start":17,"highlight_end":23}],"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":6151,"byte_end":6163,"line_start":192,"line_end":192,"column_start":13,"column_end":25,"is_primary":true,"text":[{"text":"            E::A(ref ax) =>","highlight_start":13,"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":6811,"byte_end":6812,"line_start":202,"line_end":202,"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` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:192:13\n   |\nLL |         let x = &mut e;\n   |                 ------ borrow of `e` occurs here\nLL |         match e {\nLL |             E::A(ref ax) =>\n   |             ^^^^^^^^^^^^ use of borrowed `e`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[01:13:10] {"message":"cannot borrow `e.0` 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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6156,"byte_end":6162,"line_start":192,"line_end":192,"column_start":18,"column_end":24,"is_primary":true,"text":[{"text":"            E::A(ref ax) =>","highlight_start":18,"highlight_end":24}],"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":6113,"byte_end":6119,"line_start":190,"line_end":190,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut e;","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":6811,"byte_end":6812,"line_start":202,"line_end":202,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","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:192: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 later used here\n\n"}
[01:13:10] {"message":"cannot borrow `e.0` 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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6522,"byte_end":6528,"line_start":197,"line_end":197,"column_start":23,"column_end":29,"is_primary":true,"text":[{"text":"            E::B { x: ref bx } =>","highlight_start":23,"highlight_end":29}],"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":6113,"byte_end":6119,"line_start":190,"line_end":190,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut e;","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":6811,"byte_end":6812,"line_start":202,"line_end":202,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","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:197:23\n   |\nLL |         let x = &mut e;\n   |                 ------ mutable borrow occurs here\n...\nLL |             E::B { x: ref bx } =>\n   |                       ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow later used here\n\n"}
[01:13:10] {"message":"cannot borrow `s.y.0` 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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7053,"byte_end":7059,"line_start":211,"line_end":211,"column_start":22,"column_end":28,"is_primary":true,"text":[{"text":"            S  { y: (ref y0, _), .. } =>","highlight_start":22,"highlight_end":28}],"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":7006,"byte_end":7012,"line_start":209,"line_end":209,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut s;","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":7763,"byte_end":7764,"line_start":224,"line_end":224,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:211:22\n   |\nLL |         let x = &mut s;\n   |                 ------ mutable borrow occurs here\nLL |         match s {\nLL |             S  { y: (ref y0, _), .. } =>\n   |                      ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow later used here\n\n"}
[01:13:10] {"message":"cannot borrow `s.x.y` 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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7423,"byte_end":7429,"line_start":218,"line_end":218,"column_start":28,"column_end":34,"is_primary":true,"text":[{"text":"            S  { x: F { y: ref x0, .. }, .. } =>","highlight_start":28,"highlight_end":34}],"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":7006,"byte_end":7012,"line_start":209,"line_end":209,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut s;","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":7763,"byte_end":7764,"line_start":224,"line_end":224,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:218:28\n   |\nLL |         let x = &mut s;\n   |                 ------ mutable borrow occurs here\n...\nLL |             S  { x: F { y: ref x0, .. }, .. } =>\n   |                            ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":8833,"byte_end":8839,"line_start":260,"line_end":260,"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":8849,"byte_end":8853,"line_start":261,"line_end":261,"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":9096,"byte_end":9097,"line_start":265,"line_end":265,"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 `*v` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:261: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"}
[01:13:10] {"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    // 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/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":8833,"byte_end":8839,"line_start":260,"line_end":260,"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":8849,"byte_end":8855,"line_start":261,"line_end":261,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        v[0].y;","highlight_start":9,"highlight_end":15}],"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":9096,"byte_end":9097,"line_start":265,"line_end":265,"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 `v[_].y` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:261: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"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9296,"byte_end":9302,"line_start":273,"line_end":273,"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":9247,"byte_end":9253,"line_start":271,"line_end":271,"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":9529,"byte_end":9530,"line_start":278,"line_end":278,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","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:273: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 later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":8007,"byte_end":8022,"line_start":235,"line_end":235,"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":7967,"byte_end":7977,"line_start":234,"line_end":234,"column_start":21,"column_end":31,"is_primary":false,"text":[{"text":"            let x = &mut block;","highlight_start":21,"highlight_end":31}],"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":8212,"byte_end":8213,"line_start":238,"line_end":238,"column_start":18,"column_end":19,"is_primary":false,"text":[{"text":"            drop(x);","highlight_start":18,"highlight_end":19}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:235:29\n   |\nLL |             let x = &mut block;\n   |                     ---------- mutable borrow occurs here\nLL |             let p: &'a u8 = &*block.current;\n   |                             ^^^^^^^^^^^^^^^ immutable borrow occurs here\n...\nLL |             drop(x);\n   |                  - mutable borrow later used here\n\n"}
[01:13:10] {"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/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":8473,"byte_end":8491,"line_start":250,"line_end":250,"column_start":33,"column_end":51,"is_primary":true,"text":[{"text":"            let p : *const u8 = &*(*block).current;","highlight_start":33,"highlight_end":51}],"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":8429,"byte_end":8439,"line_start":249,"line_end":249,"column_start":21,"column_end":31,"is_primary":false,"text":[{"text":"            let x = &mut block;","highlight_start":21,"highlight_end":31}],"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":8681,"byte_end":8682,"line_start":253,"line_end":253,"column_start":18,"column_end":19,"is_primary":false,"text":[{"text":"            drop(x);","highlight_start":18,"highlight_end":19}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:250: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"}
[01:13:10] {"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 `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/ch04-00-understanding-ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10412,"byte_end":10413,"line_start":306,"line_end":306,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"                drop(x);","highlight_start":22,"highlight_end":23}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10437,"byte_end":10438,"line_start":307,"line_end":307,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":"                drop(x); //[ast]~ ERROR use of moved value: `x`","highlight_start":22,"highlight_end":23}],"label":"value used here after move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x`\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:307: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"}
[01:13:10] {"message":"aborting due to 32 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 32 previous errors\n\n"}
[01:13:10] {"message":"Some errors occurred: E0382, E0499, E0502, E0503.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0382, E0499, E0502, E0503.\n"}
[01:13:10] 
[01:13:10] ------------------------------------------
[01:13:10] 
[01:13:10] thread '[ui] ui/borrowck/borrowck-describe-lvalue.rs#mir' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3422:9
---
[01:13:10] 
[01:13:10] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:516:22
[01:13:10] 
[01:13:10] 
[01:13:10] 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-6.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" "6.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"
[01:13:10] 
[01:13:10] 
[01:13:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:13:10] Build completed unsuccessfully in 0:04:18
[01:13:10] Build completed unsuccessfully in 0:04:18
[01:13:10] make: *** [check] Error 1
[01:13:10] Makefile:48: recipe for target 'check' failed
2766044 ./obj
2766004 ./obj/build
2093520 ./obj/build/x86_64-unknown-linux-gnu
1371080 ./src
---
147104 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu
147100 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release
143588 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps
142560 ./obj/build/bootstrap/debug/incremental/bootstrap-2vehb6dba088a
142556 ./obj/build/bootstrap/debug/incremental/bootstrap-2vehb6dba088a/s-fasc1m2ar7-552fnu-h9pt7lk04bnw
138372 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu
138368 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release
135528 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps
123640 ./src/llvm-project/llvm/test/CodeGen

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)

@tmandry tmandry force-pushed the remove-adt-def-from-projection-elem branch from d1b02f7 to 2ff7e78 Compare March 29, 2019 05:17
@petrochenkov petrochenkov self-assigned this Mar 29, 2019
@eddyb
Copy link
Member

eddyb commented Mar 29, 2019

@rust-timer build 24a40d8

@rust-timer
Copy link
Collaborator

Success: Queued 24a40d8 with parent 70a497a, comparison URL.

@petrochenkov petrochenkov removed their assignment Mar 29, 2019
@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 24a40d8

ProjectionElem::Downcast(_name, index) => {
let ty = self.to_ty();
match &ty.sty {
ty::Adt(adt_def, _substs) => {
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this match, it's kind of pointless nowadays.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

let variant_index = match &self {
PlaceTy::Ty { .. } => VariantIdx::new(0),
PlaceTy::Downcast { ty: _, variant_index } => *variant_index,
};
Copy link
Member

Choose a reason for hiding this comment

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

This is subtly incomplete, but pre-existing.
The non-downcast case should use .non_enum_variant() to get the variant, while downcasts should assert the ADT is an enum.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -1980,16 +1980,16 @@ pub enum ProjectionElem<'tcx, V, T> {
/// "Downcast" to a variant of an ADT. Currently, we only introduce
/// this for ADTs with more than one variant. It may be better to
/// just introduce it always, or always for enums.
Downcast(&'tcx AdtDef, VariantIdx),
Downcast(Option<Symbol>, VariantIdx),
Copy link
Member

Choose a reason for hiding this comment

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

Wait, how do we print fields? Always by index? Or do they use some trickery to show the name of the field? Because if the latter, we can reuse that for downcasts too.

@@ -16,8 +16,7 @@ pub enum PlaceTy<'tcx> {
Ty { ty: Ty<'tcx> },

/// Downcast to a particular variant of an enum.
Downcast { adt_def: &'tcx AdtDef,
substs: SubstsRef<'tcx>,
Downcast { ty: Ty<'tcx>,
variant_index: VariantIdx },
Copy link
Member

Choose a reason for hiding this comment

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

Since we are going ahead with this, might as well switch to:

pub struct PlaceTy<'tcx> {
    pub ty: Ty<'tcx>,
    pub variant_index: Option<VariantIdx>,
}

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@tmandry tmandry force-pushed the remove-adt-def-from-projection-elem branch from 2ff7e78 to 943a21b Compare March 30, 2019 17:31
tcx.mk_adt(adt_def, substs),
}
pub fn to_ty(&self) -> Ty<'tcx> {
self.ty
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this?

let answer = match self.ty.sty {
ty::TyKind::Adt(adt_def, substs) => {
let variant_def = match &self.variant_index {
None => &adt_def.non_enum_variant(),
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary borrows in these two lines.

let variant = if let Some(idx) = variant_index {
&def.variants[idx]
} else {
if def.is_enum() {
Copy link
Member

Choose a reason for hiding this comment

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

This should be impossible.

@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Apr 1, 2019
@tmandry tmandry force-pushed the remove-adt-def-from-projection-elem branch 2 times, most recently from 3249324 to ae0e763 Compare April 1, 2019 23:35
@tmandry
Copy link
Member Author

tmandry commented Apr 1, 2019

Updated, then rebased.

Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

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

r=me with this last comment addressed

@tmandry tmandry force-pushed the remove-adt-def-from-projection-elem branch from ae0e763 to 4122d22 Compare April 2, 2019 19:02
@tmandry
Copy link
Member Author

tmandry commented Apr 2, 2019

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Apr 2, 2019

📌 Commit 4122d22 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 2, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 2, 2019
…ion-elem, r=eddyb

Remove adt_def from projections and downcasts in MIR

As part of optimizing generator layouts in MIR, we'd like to allow downcasting generators to variants which do not have a corresponding `def_id`, since they are created by the compiler.

This refactor hopes to allow that, without regressing perf.

r? @eddyb
Centril added a commit to Centril/rust that referenced this pull request Apr 3, 2019
…ion-elem, r=eddyb

Remove adt_def from projections and downcasts in MIR

As part of optimizing generator layouts in MIR, we'd like to allow downcasting generators to variants which do not have a corresponding `def_id`, since they are created by the compiler.

This refactor hopes to allow that, without regressing perf.

r? @eddyb
bors added a commit that referenced this pull request Apr 3, 2019
Rollup of 4 pull requests

Successful merges:

 - #55448 (Add 'partition_at_index/_by/_by_key' for slices.)
 - #59186 (improve worst-case performance of BTreeSet intersection v3)
 - #59514 (Remove adt_def from projections and downcasts in MIR)
 - #59630 (Shrink `mir::Statement`.)

Failed merges:

r? @ghost
@bors bors merged commit 4122d22 into rust-lang:master Apr 3, 2019
@tmandry tmandry deleted the remove-adt-def-from-projection-elem branch April 11, 2019 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants