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

introduce "type must be valid for" into lexical region solver #55988

Closed
wants to merge 6 commits into from

Conversation

nikomatsakis
Copy link
Contributor

This is a fix for #55756 -- it makes the lexical region solver impose constraints more like the ones that NLL does, which overcomes a shortcoming in the logic for handling <T as Foo<'a>>::Bar: 'b outlives bounds. As part of the NLL check, that logic itself was fixed to avoid "overconstraining" -- i.e., adding stricter region checks than were necessary. Unfortunately, the logic now has the potential to underconstrain (it always did, but it's worse). This is caused #55756. This change matches NLL's behavior, which winds up requiring that if a value of type T is live during some scope S, then every region in T must outlive S (which is stricter than outlives when normalization is involved).

As part of the Chalk and Polonius work, I plan to revisit this whole system, and hopefully move to a more precise solver that can accommodate the kinds of outlives constraints we encounter in progress. However, this patch seems like a reasonably conservative step that also solves the regressions at hand.

More discussion in this comment.

Fixes #55756

r? @eddyb

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

eddyb commented Nov 15, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Nov 15, 2018

📌 Commit 4b4e074fdc64cc1e189ae86a813f0c30cb8ab337 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 Nov 15, 2018
@nikomatsakis nikomatsakis added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 15, 2018
@nikomatsakis nikomatsakis added this to the Rust 2018 Release milestone Nov 15, 2018
@nikomatsakis
Copy link
Contributor Author

cc @rust-lang/compiler -- I'm nominating this for beta backport, since it fixes a regression.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:14200f80:start=1542309149209316682,finish=1542309205491462242,duration=56282145560
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---

[00:04:02] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:02] tidy error: /checkout/src/librustc_typeck/check/regionck.rs:378: line longer than 100 chars
[00:04:02] tidy error: /checkout/src/librustc_typeck/check/regionck.rs:832: line longer than 100 chars
[00:04:02] tidy error: /checkout/src/librustc_typeck/check/regionck.rs:1049: line longer than 100 chars
[00:04:03] some tidy checks failed
[00:04:03] 
[00:04:03] 
[00:04:03] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:03] 
[00:04:03] 
[00:04:03] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:03] Build completed unsuccessfully in 0:00:50
[00:04:03] Build completed unsuccessfully in 0:00:50
[00:04:03] make: *** [tidy] Error 1
[00:04:03] Makefile:79: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:08c8d7e8
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Nov 15 19:17:38 UTC 2018
---
travis_time:end:068bfc0a:start=1542309459332541282,finish=1542309459336954797,duration=4413515
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0437009c
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:233d8d82
travis_time:start:233d8d82
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:03f25eb8
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@pietroalbini
Copy link
Member

@bors r-
Tidy failed:

[00:04:02] tidy error: /checkout/src/librustc_typeck/check/regionck.rs:378: line longer than 100 chars
[00:04:02] tidy error: /checkout/src/librustc_typeck/check/regionck.rs:832: line longer than 100 chars
[00:04:02] tidy error: /checkout/src/librustc_typeck/check/regionck.rs:1049: line longer than 100 chars

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 15, 2018
@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb p=1

@bors
Copy link
Contributor

bors commented Nov 16, 2018

📌 Commit 134c7d1019623aaa96f92d574428303845474fd4 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 16, 2018
@nikomatsakis
Copy link
Contributor Author

Giving p=1 because this is a Rust 2018 blocker.

@nikomatsakis
Copy link
Contributor Author

@bors r-

Huh. Apparently this broke some tests.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 16, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0b5f04b4:start=1542379240667325525,finish=1542379297885939025,duration=57218613500
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:48:37] 
[00:48:37] running 5022 tests
[00:48:40] .................................................................................................... 100/5022
[00:48:43] .................................................................................................... 200/5022
[00:48:46] .................................................F.................................................. 300/5022
[00:48:52] .................................................................................................... 500/5022
[00:48:56] .............................i...................................................................... 600/5022
[00:48:59] .................................................................................................... 700/5022
[00:49:05] .................................................................................i...........i...... 800/5022
[00:49:05] .................................................................................i...........i...... 800/5022
[00:49:09] .................................................................................................... 900/5022
[00:49:13] iiiii............................................................................................... 1000/5022
[00:49:15] .................................................................................................... 1100/5022
[00:49:18] .................................................................................................... 1200/5022
[00:49:20] .................................................................................................... 1300/5022
[00:49:23] .................................................................................................... 1400/5022
[00:49:25] .................................................................................................... 1500/5022
[00:49:28] .i....................................................................i............................. 1600/5022
[00:49:32] ..................................................F................................................. 1700/5022
[00:49:39] .................................................................................................... 1900/5022
[00:49:42] i................................................................................................... 2000/5022
[00:49:46] .................................................................................................... 2100/5022
[00:49:51] .................................................................................................... 2200/5022
[00:49:51] .................................................................................................... 2200/5022
[00:49:55] .................................................................................................... 2300/5022
[00:49:58] .................................................................................................... 2400/5022
[00:50:02] .................................................................................................FF. 2500/5022
[00:50:06] .................................................................................................... 2600/5022
[00:50:10] ......................................................................F............................. 2700/5022
[00:50:16] .................................................................................................... 2900/5022
[00:50:21] .................................................................................................... 3000/5022
[00:50:24] ...........................................i........................................................ 3100/5022
[00:50:28] .................................................................................................... 3200/5022
[00:50:28] .................................................................................................... 3200/5022
[00:50:31] ......i.i..ii....................................................................................... 3300/5022
[00:50:35] .................................................................................................... 3400/5022
[00:50:38] ...................................................................................i..ii............ 3500/5022
[00:50:41] .................................................................................................... 3600/5022
[00:50:42] ...i................................................................................................ 3700/5022
[00:50:43] ...........................................................i........................................ 3800/5022
[00:50:45] .................................................................................................... 3900/5022
[00:50:49] ..............................................................................................F..F.. 4000/5022
[00:50:52] .......................................F............................................................ 4100/5022
[00:50:55] .F.................................................................................................. 4200/5022
[00:51:04] .................................................................................................... 4400/5022
[00:51:07] .................................................................................................... 4500/5022
[00:51:11] ...........................................................................................i........ 4600/5022
[00:51:14] .................................................................................................... 4700/5022
---
[00:51:24] 
[00:51:24] ---- [ui] ui/borrowck/borrowck-describe-lvalue.rs#ast stdout ----
[00:51:24] diff of stderr:
[00:51:24] 
[00:51:24] 219 LL |         };
[00:51:24] 220    |         - first borrow ends here
[00:51:24] 221 
[00:51:24] + error[E0598]: lifetime of `x` is too short to guarantee its contents can be safely reborrowed
[00:51:24] +   --> $DIR/borrowck-describe-lvalue.rs:305:16
[00:51:24] +    |
[00:51:24] + LL |                || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body
[00:51:24] +    |
[00:51:24] +    |
[00:51:24] + note: `x` would have to be valid for the expression at 304:12...
[00:51:24] +   --> $DIR/borrowck-describe-lvalue.rs:304:12
[00:51:24] +    |
[00:51:24] + LL | /            || {
[00:51:24] + LL | |                || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body
[00:51:24] + LL | |                    let y = &mut x;
[00:51:24] + LL | |                    &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
[00:51:24] + ...  |
[00:51:24] + LL | |                 }
[00:51:24] + LL | |            };
[00:51:24] +    | |____________^
[00:51:24] + note: ...but `x` is only valid for the lifetime  as defined on the body at 304:12
[00:51:24] +   --> $DIR/borrowck-describe-lvalue.rs:304:12
[00:51:24] +    |
[00:51:24] + LL |            || {
[00:51:24] + 
[00:51:24] + 
[00:51:24] 222 error[E0499]: cannot borrow `**x` as mutable more than once at a time
[00:51:24] 224    |
[00:51:24] 
[00:51:24] 240    |
[00:51:24] 240    |
[00:51:24] 241    = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
[00:51:24] - error: aborting due to 26 previous errors
[00:51:24] + error: aborting due to 27 previous errors
[00:51:24] 244 
[00:51:24] - Some errors occurred: E0382, E0499, E0502, E0503.
[00:51:24] - Some errors occurred: E0382, E0499, E0502, E0503.
[00:51:24] + Some errors occurred: E0382, E0499, E0502, E0503, E0598.
[00:51:24] 246 For more information about an error, try `rustc --explain E0382`.
[00:51:24] 247 
[00:51:24] 
[00:51:24] 
[00:51:24] The actual stderr differed from the expected stderr.
[00:51:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.ast/borrowck-describe-lvalue.ast.stderr
[00:51:24] To update references, rerun the tests and pass the `--bless` flag
[00:51:24] To only update this specific test, also pass `--test-args borrowck/borrowck-describe-lvalue.rs`
[00:51:24] 
[00:51:24] error in revision `ast`: 1 errors occurred comparing output.
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "ast" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.ast/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.ast/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"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 borr; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed\n   |         ^^^ use of borrowed `f`\n\n"}
[00:51:24] {"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 ca borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1602,"byte_end":1605,"line_start":68,"line_end":68,"column_start":22,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut h.0;","highlight_start":22,"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":1615,"byte_end":1618,"line_start":69,"line_end":69,"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}],"children":[],"rendered":"error[E0503]: cannot use `h.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:69: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`\n\n"}
[00:51:24] {"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.":20,"highlight_end":25}],"label":"use of borrowed `e`","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:78: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\n"}
[00:51:24] {"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/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2220,"byte_end":2223,"line_start":87,"line_end":87,"column_start":22,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":22,"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":2233,"byte_end":2236,"line_start":88,"line_end":88,"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}],"children":[],"rendered":"error[E0503]: cannot use `u.a` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:88: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`\n\n"}
[00:51:24] {"message":"cannot use `f.x` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2505,"byte_end":2506,"line_start":95,"line_end":95,"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":2520,"byte_end":2523,"line_start":96,"line_end":96,"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}],"children":[],"rendered":"error[E0503]: cannot use `f.x` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:96: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`\n\n"}
[00:51:24] {"message":"cannot use `g.0` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2792,"byte_end":2793,"line_start":103,"line_end":103,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = g.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `*g` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2807,"byte_end":2810,"line_start":104,"line_end":104,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `*g`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `g.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:104:9\n   |\nLL |         let x = g.x();\n   |                 - borrow of `*g` occurs here\nLL |         g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed\n   |         ^^^ use of borrowed `*g`\n\n"}
[00:51:24] {"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\nYLL |         match *e {\nLL |             Baz::X(value) => value\n   |                    ^^^^^ use of borrowed `*e`\n\n"}
[00:51:24] {"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/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3717,"byte_end":3720,"line_start":130,"line_end":130,"column_start":22,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":22,"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":3730,"byte_end":3733,"line_start":131,"line_end":131,"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}],"children":[],"rendered":"error[E0503]: cannot use `u.a` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:131: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`\n\n"}
[00:51:24] {"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    //  let x = &mut v;","highlight_start":22,"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":4038,"byte_end":4039,"line_start":140,"line_end":140,"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}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:140: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\n"}
[00:51:24] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4003,"byte_end":4004,"line_start":138,"line_end":138,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":22,"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":4343,"byte_end":4344,"line_start":146,"line_end":146,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x, .., _, _] => println!(\"{}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:146:18\n   |\nLL |         let x = &mut v;\n   |                      - borrow of `v` occurs here\n...\nLL |             &[_, x, .., _, _] => println!(\"{}\", x),\n   |                  ^ use of borrowed `v`\n\n"}
[00:51:24] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4003,"byte_end":4004,"line_start":138,"line_end":138,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":22,"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":4652,"byte_end":4653,"line_start":152,"line_end":152,"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}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:152:25\n   |\nLL |         let x = &mut v;\n   |                      - borrow of `v` occ here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4003,"byte_end":4004,"line_start":138,"line_end":138,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":22,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4957,"byte_end":4958,"line_start":158,"line_end":158,"column_start":28,"column_end":29,"is_primary":true,"text":[{"text":"            &[_, _, .., _, x] => println!(\"{}\", x),","highlight_start":28,"highlight_end":29}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:158:28\n   |\nLL |         let x = &mut v;\n   |                      - borrow of `v` occurs here\n...\nLL |             &[_, _, .., _, x] => println!(\"{}\", x),\n   |                            ^ use of borrowed `v`\n\n"}
[00:51:24] {"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 borrghlight_start":22,"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":5354,"byte_end":5355,"line_start":170,"line_end":170,"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}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:170: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\n"}
[00:51:24] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5319,"byte_end":5320,"line_start":168,"line_end":168,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":22,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5634,"byte_end":5635,"line_start":176,"line_end":176,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x..] => println!(\"{:?}\", x),","highlight_start" main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5319,"byte_end":5320,"line_start":168,"line_end":168,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":22,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5911,"byte_end":5912,"line_start":182,"line_end":182,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":"            &[x.., _] => println!(\"{:?}\", x),","highlight_start":15,"highlight_end":16}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:182:15\n   |\nLL |         let x = &mut v;\n   |                      - borrow of `v` occurs here\n...\nLL |             &[x.., _] => println!(\"{:acement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `e.0` as immutable because `e` is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:202:18\n   |\nLL |         let x = &mut e;\n   |                      - mutable borrow occurs here\nLL |         match e {\nLL |             E::A(ref ax) =>\n   |                  ^^^^^^ immutable borrow occurs here\n...\nLL |     }\n   |     - mutable borrow ends here\n\n"}
[00:51:24] {"message":"cannot borrow `e.x` as immutable because `e` is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6989,"byte_end":6995,"line_start":207,"line_end":207,"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":6585,"byte_end":6586,"line_start":200,"line_end":200,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut e;","highlight_start":22,"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":7286,"byte_end":7287,"line_start":213,"line_end":213,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"mutable borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `e.x` as immutable because `e` is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:207: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 |     }\n   |     - mutable borrow ends here\n\n"}
[00:51:24] {"message":"cannot borrow `s.y.0` as immutable because `s` 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 b5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"mutable borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:221: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 |     }\n   |     - mutable borrow ends here\n\n"}
[00:51:24] {"message":"cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7890,"byte_end":7896,"line_start":228,"line_end":228,"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":7478,"byte_end":7479,"line_start":219,"line_end":219,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut s;","highlight_start":22,"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":8238,"byte_end":8239,"line_start":235,"line_end":235,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"mutable borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:228: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 |     }\n   |     - mutable borrow ends here\n\n"}
[00:51:24] {"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/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9305,"byte_end":9306,"line_start":270,"line_end":270,"column_start":22,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":22,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9316,"byte_end":9322,"line_start":271,"line_end":271,"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}],"children":[],"rendered":"error[E0503]: cannot use `v[..].y` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:271:9\n   |\nLL |         let x = &mut v;\n   |                      - borrow of `v` occurs here\nLL |         v[0].y;\n   |         ^^^^^^ use of borrowed `v`\n\n"}
[00:51:24] {"message":"cannot borrow `**x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for mor"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},{"text":"           };","highlight_start":1,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...but `x` is only valid for the lifetime  as defined on the body at 304:12","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10475,"byte_end":10477,"line_start":304,"line_end":304,"column_start":12,"column_end":14,"is_primary":true,"text":[{"text":"           || {","highlight_start":12,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0598]: lifetime of `x` is too short to guarantee its contents can be safely reborrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:305:16\n   |\nLL |                || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body\n   |                ^^\n   |\nnote: `x` would have to be valid for the expression at 304:12...\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:304:12\n   |\nLL | /            || {\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\n...  |\nLL | |                 }\nLL | |            };\n   | |____________^\nnote: ...but `x` is only valid for the lifetime  as defined on the body at 304:12\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:304:12\n   |\nLL |            || {\n   |            ^^\n\n"}
[00:51:24] {"message":"cannot borrow `**x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10600,"byte_end":10601,"line_start":306,"line_end":306,"column_start":33,"column_end":34,"is_primary":false,"text":[{"text":"                   let y = &mut x;","highlight_start":33,"highlight_end":34}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borr = 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 owne--
[00:51:24] {"message":"the feature `conservative_impl_trait` has been stable since 1.26.0 and no longer requires an attribute to enable","code":{"code":"stable_features","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs","byte_start":107,"byte_end":130,"line_start":4,"line_end":4,"column_start":12,"column_end":35,"is_primary":true,"text":[{"text":"#![feature(conservative_impl_trait)]","highlight_start":12,"highlight_end":35}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"#[warn(stable_features)] on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: the feature `conservative_impl_trait` has been stable since 1.26.0 and no longer requires an attribute to enable\n  --> /checkout/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs:4:12\n   |\nLL | #![feature(conservative_impl_trait)]\n   |            ^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: #[warn(stable_features)] on by default\n\n"}
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] thread '[ui] ui/impl-trait/issue-55608-captures-empty-region.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:24] 
[00:51:24] 
[00:51:24] ---- [ui] ui/issues/issue-40510-1.rs stdout ----
[00:51:24] 
[00:51:24] error: test compilation failed although it shouldn't!
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-40510-1.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-1/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-1/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"message":"cannot infer an appropriate lifetime for borrow expression due to conflicting requirements","code":{"code":"E0495","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":568,"byte_end":574,"line_start":18,"line_end":18,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        &mut x","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"first, the lifetime cannot outlive the lifetime  as defined on the body at 17:5...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":555,"byte_end":557,"line_start":17,"line_end":17,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":7}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":n":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:18:9\n   |\nLL |         &mut x\n   |         ^^^^^^\n   |\nnote: first, the lifetime cannot outlive the lifetime  as defined on the body at 17:5...\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:17:5\n   |\nLL |     || {\n   |     ^^\nnote: ...so that closure can access `x`\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:18:9\n   |\nLL |         &mut x\n   |         ^^^^^^\nnote: but, the lifetime must be valid for the expression at 17:5...\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:17:5\n   |\nLL | /     || {\nLL | |         &mut x\nLL | |     };\n   | |_____^\nnote: ...so type `[closure@/checkout/src/test/ui/issues/issue-40510-1.rs:17:5: 19:6 x:&mut std::boxed::Box<()>]` of expression is valid during the expression\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:17:5\n   |\nLL | /     || {\nLL | |         &mut x\nLL | |     };\n   | |_____^\n\n"}
[00:51:24] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:24] {"message":"For more information about this error, try `rustc --explain E0495`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0495`.\n"}
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] thread '[ui] ui/issues/issue-40510-1.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:24] 
[00:51:24] 
[00:51:24] ---- [ui] ui/issues/issue-40510-3.rs stdout ----
[00:51:24] 
[00:51:24] error: test compilation failed although it shouldn't!
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-40510-3.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-3/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-3/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"message":"lifetime of `x` is too short to guarantee its contents can be safely reborrowed","code":{"code":"E0598","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-3.rs","byte_start":566,"byte_end":568,"line_start":18,"line_end":18,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"        || {","highlight_start":9,"highlight_end":11}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`x` would have to be valid for the expression at 17:5...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-3.rs","byte_start":553,"byte_end":609,"line_start":17,"line_end":21,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":9},{"text":"        || {","highlight_start":1,"highlight_end":13},{"text":"            x.push(())","highlight_start":1,"highlight_end":23},{"text":"        }","highlight_start":1,"highlight_end":10},{"text":"    };","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...but `x` is only valid for the lifetime  as defined on the body at 17:5","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-3.rs","byte_start":553,"byte_end":555,"line_start":17,"line_end":17,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":7}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0598]: lifetime of `x` is too short to guarantee its contents can be safely reborrowed\n  --> /checkout/src/test/ui/issues/issue-40510-3.rs:18:9\n   |\nLL |         || {\n   |         ^^\n   |\nnote: `x` would have to be valid for the expression at 17:5...\n  --> /checkout/src/test/ui/issues/issue-40510-3.rs:17:5\n   |\nLL | /     || {\nLL | |         || {\nLL | |             x.push(())\nLL | |         }\nLL | |     };\n   | |_____^\nnote: ...but `x` is only valid for the lifetime  as defined on the body at 17:5\n  --> /checkout/src/test/ui/issues/issue-40510-3.rs:17:5\n   |\nLL |     || {\n   |     ^^\n\n"}
[00:51:24] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:24] {"message":"For more information about this error, try `rustc --explain E0598`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0598`.\n"}
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] thread '[ui] ui/issues/issue-40510-3.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:24] 
[00:51:24] 
[00:51:24] ---- [ui] ui/issues/issue-49824.rs stdout ----
[00:51:24] diff of stderr:
[00:51:24] 
[00:51:24] - error: compilation successful
[00:51:24] -   --> $DIR/issue-49824.rs:18:1
[00:51:24] + error[E0598]: lifetime of `x` is too short to guarantee its contents can be safely reborrowed
[00:51:24] +   --> $DIR/issue-49824.rs:22:9
[00:51:24] 3    |
[00:51:24] - LL | / fn main() {
[00:51:24] - LL | |     //~^ compilation successful
[00:51:24] - LL | |     let mut x = 0;
[00:51:24] - LL | |     || {
[00:51:24] - ...  |
[00:51:24] + LL |         || {
[00:51:24] +    |
[00:51:24] +    |
[00:51:24] + note: `x` would have to be valid for the expression at 21:5...
[00:51:24] +   --> $DIR/issue-49824.rs:21:5
[00:51:24] +    |
[00:51:24] + LL | /     || {
[00:51:24] + LL | |         || {
[00:51:24] + LL | |             let _y = &mut x;
[00:51:24] + LL | |         }
[00:51:24] 9 LL | |     };
[00:51:24] - LL | | }-----------------------------------------
[00:51:24] {"message":"lifetime of `x` is too short to guarantee its contents can be safely reborrowed","code":{"code":"E0598","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-49824.rs","byte_start":802,"byte_end":804,"line_start":22,"line_end":22,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"        || {","highlight_start":9,"highlight_end":11}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`x` would have to be valid for the expression at 21:5...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-49824.rs","byte_start":789,"byte_end":851,"line_start":21,"line_end":25,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":9},{"text":"        || {","highlight_start":1,"highlight_end":13},{"text":"            let _y = &mut x;","highlight_start":1,"highlight_end":29},{"text":"        }","highlight_start":1,"highlight_end":10},{"text":"    };","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...but `x` is only valid for the lifetime  as defined on the body at 21:5","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-49824.rs","byte_start":789,"byte_end":791,"line_start":21,"line_end":21,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":7}],"lore borrower
[00:51:24] -    |
[00:51:24] -    = note: values in a scope are dropped in the opposite order they are created
[00:51:24] +    |     - borrowed value only lives until here
[00:51:24] + ...
[00:51:24] + LL | }
[00:51:24] +    | - borrowed value needs to live until here
[00:51:24] 13 
[00:51:24] 14 error[E0597]: `y` does not live long enough
[00:51:24] 
[00:51:24] 20    |                          capture occurs here
[00:51:24] 21 ...
[00:51:24] 21 ...
[00:51:24] 22 LL |     });
[00:51:24] -    |     - borrowed value dropped before borrower
[00:51:24] -    |
[00:51:24] -    = note: values in a scope are dropped in the opposite order they are created
[00:51:24] +    |     - borrowed value only lives until here
[00:51:24] + ...
[00:51:24] + LL | }
[00:51:24] +    | - borrowed value needs to live until here
[00:51:24] 27 error: aborting due to 2 previous errors
[00:51:24] 28 
[00:51:24] 
[00:51:24] 
[00:51:24] 
[00:51:24] The actual stderr differed from the expected stderr.
[00:51:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-big.ast/region-borrow-params-issue-29793-big.ast.stderr
[00:51:24] To update references, rerun the tests and pass the `--bless` flag
[00:51:24] To only update this specific test, also pass `--test-args regions/region-borrow-params-issue-29793-big.rs`
[00:51:24] 
[00:51:24] error in revision `ast`: 1 errors occurred comparing output.
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/region-borrow-params-issue-29793-big.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "ast" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-big.ast/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-big.ast/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"message":"`x` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-bor:null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-big.rs:81:43\n   |\nLL |         WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)\n   |                          ---------        ^ borrowed value does not live long enough\n   |                          |\n   |                          capture occurs here\n...\nLL |     });\n   |     - borrowed value only lives until here\n...\nLL | }\n   | - borrowed value needs to live until here\n\n"}
[00:51:24] {"message":"`y` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-big.rs","byte_start":2061,"byte_end":2070,"line_start":81,"line_end":81,"column_start":26,"column_end":35,"is_primary":false,"text":[{"text":"        WrapB:orrowed value only lives until here
[00:51:24] + ...
[00:51:24] + LL | }
[00:51:24] +    | - borrowed value needs to live until here
[00:51:24] 52 
[00:51:24] 53 error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
[00:51:24] 
[00:51:24] 
[00:51:24] The actual stderr differed from the expected stderr.
[00:51:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-small/region-borrow-params-issue-29793-small.stderr
[00:51:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-small/region-borrow-params-issue-29793-small.stderr
[00:51:24] To update references, rerun the tests and pass the `--bless` flag
[00:51:24] To only update this specific test, also pass `--test-args regions/region-borrow-params-issue-29793-small.rs`
[00:51:24] error: 1 errors occurred comparing output.
[00:51:24] status: exit code: 1
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-small/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-borrow-params-issue-29793-small/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"message":"`x` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":717,"byte_end":726,"line_start":19,"line_end":19,"column_start":17,"column_end":26,"is_primary":false,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":"capture occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":734,"byte_end":735,"line_start":19,"line_end":19,"column_start":34,"column_end":35,"is_primary":true,"text":[{"text":"        let f = |t: bool| if t { x } else { y }rrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":717,"byte_end":726,"line_start":19,"line_end":19,"column_start":17,"column_end":26,"is_primary":false,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":"capture occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":745,"byte_end":746,"line_start":19,"line_end":19,"column_start":45,"column_end":46,"is_primary":true,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":45,"highlight_end":46}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":1125,"byte_end":1126,"line_start":30,"line_end":30,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"borrowed value needs to live until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":906,"byte_end":907,"line_start":23,"line_end":23,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    };","highlight_start":5,"highlight_end":6}],"label":"borrowed value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `y` does not live long enough\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:19:45\n   |\nLL |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ---------                   ^ borrowed value does not live long enough\n   |                 |\n   |                 capture occurs here\n...\nLL |     };\n   |     - borrowed value only lives until here\n...\nLL | }\n   | - borrowed value needs to live until here\n\n"}
[00:51:24] {"message":"`x` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":1221,"byte_end":1230,"line_start":34,"line_end":34,"column_start":17,"column_end":26,"is_primary":false,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":"capture occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":1238,"byte_end":1239,"line_start":34,"line_end":34,"column_start":34,"column_end":35,"is_primary":true,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":34,"highlight_end":35}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":1444,"byte_end":1445,"line_start":41,"line_end":41,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"borrowed value needs to live until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":1402,"byte_end":1403,"line_start":38,"line_end":38,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    };","highlight_start":5,"highlight_end":6}],"label":"borrowed value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:34:34\n   |\nLL |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ---------        ^ borrowed value does not live long enough\n   |                 |\n   |                 capture occurs here\n...\nLL |     };\n   |     - borrowed value only lives until here\n...\nLL | }\n   | - borrowed value needs to live until here\n\n"}
[00:51:24] {"message":"`y` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order-29793-small.rs","byte_start":1402,"byte_end":1403,"line_start":38,"line_end":38,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    };","highlight_start":5,"highlight_end":6}],"label":"borrowed value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `y` does not live long enough\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:34:45\n   |\nLL |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ---------                   ^ borrowed value does not live long enough\n   |                 |\n   |                 capture occurs here\n...\nLL |     };\n   |     - borrowed value only lives until here\n...\nLL | }\n   | - borrowed value needs to live until here\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `x`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_f}; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":"may outlive borrowed value `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":2080,"byte_end":2089,"line_start":65,"line_end":65,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:65:17\n   |\nLL |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ^^^^^^^^^        - `x` is borrowed here\n   |                 |\n   |                 may outlive borrowed value `x`\nhelp: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword\n   |\nLL |         let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `y`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/ct borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:65:17\n   |\nLL |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ^^^^^^^^^                   - `y` is borrowed here\n   |                 |\n   |                 may outlive borrowed value `y`\nhelp: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword\n   |\nLL |         let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `x`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well  bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":45,"highlight_end":46}],"label":"`y` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":2395,"byte_end":2404,"line_start":76,"line_end":76,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":"may outlive borrowed value `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":2395,"byte_end":2404,"line_start":76,"line_end":76,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"        let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:76:17\n   |\nLL |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ^^^^^^^^^                   - `y` is borrowed here\n   |                 |\n   |                 may outlive borrowed value `y`\nhelp: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword\n   |\nLL |         let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                 ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `x`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\ntissue-29793-small.rs","byte_start":3053,"byte_end":3062,"line_start":100,"line_end":100,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:100:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^        - `x` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `x`\nhelp: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `y`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3081,"byte_end":3082,"line_start":100,"line_end":100,"column_start":49,"column_end":50,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":49,"highlight_end":50}],"label":"`y` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3053,"byte_end":3062,"line_start":100,"line_end":100,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3053,"byte_end":3062,"line_start":100,"line_end":100,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:100:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^                   - `y` is borrowed here\n   |                     |\n   |                     may outlive boris approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3452,"byte_end":3453,"line_start":114,"line_end":114,"column_start":38,"column_end":39,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":38,"highlight_end":39}],"label":"`x` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3435,"byte_end":3444,"line_start":114,"line_end":114,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3435,"byte_end":3444,"line_start":114,"line_end":114,"column_start":21,"column_end":30,"is_primary":trusts. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3463,"byte_end":3464,"line_start":114,"line_end":114,"column_start":49,"column_end":50,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":49,"highlight_end":50}],"label":"`y` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3435,"byte_end":3444,"line_start":114,"line_end":114,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":3435,"byte_end":3444,"line_start":114,"line_end":114,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:114:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^                   - `y` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `y`\nhelp: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword\n   |\nLle) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4286,"byte_end":4287,"line_start":142,"line_end":142,"column_start":38,"column_end":39,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":38,"highlight_end":39}],"label":"`x` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4269,"byte_end":4278,"line_start":142,"line_end":142,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4269,"byte_end":4278,"line_start":142,"line_end":142,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:142:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^        - `x` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `x`\nhelp: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `y`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4297,"byte_end":4298,"line_start":142,"line_end":142,"column_start":49,"column_end":50,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":49,"highlight_end":50}],"label":"`y` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4269,"byte_end":4278,"line_start":142,"line_end":142,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4269,"byte_end":4278,"line_start":142,"line_end":142,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:142:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^                   - `y` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `y`\nhelp: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `x`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;cement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:157:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^        - `x` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `x`\nhelp: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `y`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn  // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":4744,"byte_end":4753,"line_start":157,"line_end":157,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:157:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^                   - `y` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `y`\nhelp: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `x`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"or[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:185:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^        - `x` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `x`\nhelp: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `y`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new th":6016,"line_start":199,"line_end":199,"column_start":38,"column_end":39,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":38,"highlight_end":39}],"label":"`x` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":5998,"byte_end":6007,"line_start":199,"line_end":199,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":5998,"byte_end":6007,"line_start":199,"line_end":199,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:199:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^        - `x` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `x`\nhelp: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"closure may outlive the current function, but it borrows `y`, which is owned by the current function","code":{"code":"E0373","explanation":"\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It's most commonly seen when attempting to\nreturn a closure:\n\n```compile_fail,E0373\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(|y| x + y)\n}\n```\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n    let x = 0u32;\n    let y = 1u32;\n\n    let thr = std::thread::spawn(|| {\n        x + y\n    });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won't disappear), we will not succeed: the compiler cannot prove\nthat this behaviour is safe, and so won't let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<Fn(u32) -> u32> {\n    let x = 0u32;\n    Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there's no need to worry\nabout safety.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":6026,"byte_end":6027,"line_start":199,"line_end":199,"column_start":49,"column_end":50,"is_primary":false,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":49,"highlight_end":50}],"label":"`y` is borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":5998,"byte_end":6007,"line_start":199,"line_end":199,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":"may outlive borrowed value `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs","byte_start":5998,"byte_end":6007,"line_start":199,"line_end":199,"column_start":21,"column_end":30,"is_primary":true,"text":[{"text":"            let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)","highlight_start":21,"highlight_end":30}],"label":null,"suggested_replacement":"move |t: bool|","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function\n  --> /checkout/src/test/ui/regions/region-borrow-params-issue-29793-small.rs:199:21\n   |\nLL |             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^                   - `y` is borrowed here\n   |                     |\n   |                     may outlive borrowed value `y`\nhelp: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword\n   |\nLL |             let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)\n   |                     ^^^^^^^^^^^^^^\n\n"}
[00:51:24] {"message":"aborting due to 20 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 20 previous errors\n\n"}
[00:51:24] {"message":"Some errors occurred: E0373, E0597.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0373, E0597.\n"}
[00:51:24] {"message":"For more information about an error, try `rustc --explain E0373`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0373`.\n"}
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] thread '[ui] ui/regions/region-borrow-params-issue-29793-small.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:24] 
[00:51:24] 
[00:51:24] ---- [ui] ui/regions/regions-escape-via-trait-or-not.rs stdout ----
[00:51:24] diff of stderr:
[00:51:24] 
[00:51:24] 12    = note: ...so that the expression is assignable:
[00:51:24] 13            expected &isize
[00:51:24] 14               found &isize
[00:51:24] - note: but, the lifetime must be valid for the expression at 28:5...
[00:51:24] + note: but, the lifetime must be valid for the call at 28:5...
[00:51:24] 17    |
[00:51:24] 17    |
[00:51:24] 18 LL |     with(|o| o) //~ ERROR cannot infer
[00:51:24] -    |     ^^^^
[00:51:24] -    |     ^^^^
[00:51:24] - note: ...so type `fn([closure@$DIR/regions-escape-via-trait-or-not.rs:28:10: 28:15]) -> isize {with::<&isize, [closure@$DIR/regions-escape-via-trait-or-not.rs:28:10: 28:15]>}` of expression is valid during the expression
[00:51:24] +    |     ^^^^^^^^^^^
[00:51:24] +    |     ^^^^^^^^^^^
[00:51:24] + note: ...so that argument is valid for the call
[00:51:24] +   --> $DIR/regions-escape-via-trait-or-not.rs:28:10
[00:51:24] 22    |
[00:51:24] 23 LL |     with(|o| o) //~ ERROR cannot infer
[00:51:24] +    |          ^^^^^
[00:51:24] 25 
[00:51:24] 26 error: aborting due to previous error
[00:51:24] 27 
[00:51:24] 27 
[00:51:24] 
[00:51:24] 
[00:51:24] The actual stderr differed from the expected stderr.
[00:51:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-escape-via-trait-or-not/regions-escape-via-trait-or-not.stderr
[00:51:24] To update references, rerun the tests and pass the `--bless` flag
[00:51:24] To only update this specific test, also pass `--test-args regions/regions-escape-via-trait-or-not.rs`
[00:51:24] error: 1 errors occurred comparing output.
[00:51:24] status: exit code: 1
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/regions-escape-via-trait-or-not.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-escape-via-trait-or-not/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-escape-via-trait-or-not/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"message":"cannot infer an appropriate lifetime due to conflicting requirements","code":{"code":"E0495","explanation":null},"level":"error",:"...so that argument is valid for the call","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/regions/regions-escape-via-trait-or-not.rs","byte_start":735,"byte_end":740,"line_start":28,"line_end":28,"column_start":10,"column_end":15,"is_primary":true,"text":[{"text":"    with(|o| o) //~ ERROR cannot infer","highlight_start":10,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements\n  --> /checkout/src/test/ui/regions/regions-escape-via-trait-or-not.rs:28:14\n   |\nLL |     with(|o| o) //~ ERROR cannot infer\n   |              ^\n   |\nnote: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 28:10...\n  --> /checkout/src/test/ui/regions/regions-escape-via-trait-or-not.rs:28:10\n   |\nLL |     with(|o| o) //~ ERROR cannot infer\n   |          ^^^^^\n   = note: ...so that the expression is assignable:\n           expected &isize\n              found &isize\nnote: but, the lifetime must be valid for the call at 28:5...\n  --> /checkout/src/test/ui/regions/regions-escape-via-trait-or-not.rs:28:5\n   |\nLL |     with(|o| o) //~ ERROR cannot infer\n   |     ^^^^^^^^^^^\nnote: ...so that argument is valid for the call\n  --> /checkout/src/test/ui/regions/regions-escape-via-trait-or-not.rs:28:10\n   |\nLL |     with(|o| o) //~ ERROR cannot infer\n   |          ^^^^^\n\n"}
[00:51:24] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error^^^^
[00:51:24] - note: but, the lifetime must be valid for the call at 19:17...
[00:51:24] -    |
[00:51:24] -    |
[00:51:24] - LL |         let y = f();
[00:51:24] -    |                 ^^^
[00:51:24] - note: ...so type `&mut i32` of expression is valid during the expression
[00:51:24] -    |
[00:51:24] -    |
[00:51:24] - LL |         let y = f();
[00:51:24] -    |                 ^^^
[00:51:24] +    |             -----   -- ^^^^^^ cannot be stored outside of its closure
[00:51:24] +    |             |       |
[00:51:24] +    |             |       ...because it cannot outlive this closure
[00:51:24] +    |             borrowed data cannot be stored into here...
[00:51:24] 28 error: aborting due to previous error
[00:51:24] 29 
[00:51:24] 
[00:51:24] - For more information about this error, try `rustc --explain E0495`.
[00:51:24] - For more information about this error, try `rustc --explain E0495`.
[00:51:24] 31 
[00:51:24] 
[00:51:24] 
[00:51:24] The actual stderr differed from the expected stderr.
[00:51:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-return-ref-to-upvar-issue-17403/regions-return-ref-to-upvar-issue-17403.stderr
[00:51:24] To update references, rerun the tests and pass the `--bless` flag
[00:51:24] To only update this specific test, also pass `--test-args regions/regions-return-ref-to-upvar-issue-17403.rs`
[00:51:24] error: 1 errors occurred comparing output.
[00:51:24] status: exit code: 1
[00:51:24] status: exit code: 1
[00:51:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-return-ref-to-upvar-issue-17403/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-return-ref-to-upvar-issue-17403/auxiliary" "-A" "unused"
[00:51:24] ------------------------------------------
[00:51:24] 
[00:51:24] ------------------------------------------
[00:51:24] stderr:
[00:51:24] stderr:
[00:51:24] ------------------------------------------
[00:51:24] {"message":"borrowed data cannot be stored outside of its closure","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.rs","byte_start":619,"byte_end":625,"line_start":17,"line_end":17,"column_start":24,"column_end":30,"is_primary":true,"text":[{"text":"        let mut f = || &mut x; //~ ERROR cannot infer","highlight_start":24,"highlight_end":30}],"label":"cannot be stored outside of its closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.rs","byte_start":608,"byte_end":613,"line_start":17,"line_end":17,"column_start":13,"column_end":18,"is_primary":false,"text":[{"text":"        let mut f = || &mut x; //~ ERROR cannot infer","highlight_start":13,"highlight_end":18}],"label":"borrowed data ce-40510-1.rs
[00:51:24]     [ui] ui/issues/issue-49824.rs
[00:51:24]     [ui] ui/regions/region-borrow-params-issue-29793-big.rs#ast
[00:51:24]     [ui] ui/regions/region-borrow-params-issue-29793-small.rs
[00:51:24]     [ui] ui/regions/regions-escape-via-trait-or-not.rs
[00:51:24]     [ui] ui/regions/regions-escape-via-trait-or-not.rs
[00:51:24]     [ui] ui/regions/regions-return-ref-to-upvar-issue-17403.rs
[00:51:24] 
[00:51:24] test result: FAILED. 4989 passed; 9 failed; 24 ignored; 0 measured; 0 filtered out
[00:51:24] 
[00:51:24] 
[00:51:24] 
[00:51:24] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cge1-rustc/x86_64-unknown-linux-gnu/release/deps
134668 ./obj/build/bootstrap/debug/incremental/bootstrap-zemjd6kcyh2u
134664 ./obj/build/bootstrap/debug/incremental/bootstrap-zemjd6kcyh2u/s-f6q7c6djfl-18d18hb-bouay2ep2m1v
130752 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release
123680 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps
111072 ./src/llvm/test/CodeGen
109776 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/release
---
56044 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/release/build
56000 ./obj/build/x86_64-unknown-linux-gnu/stage0-sysroot
55996 ./obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib
55992 ./obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib
55988 ./obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-"$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:12b36412
travis_time:start:12b36412
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:05d281ec
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikomatsakis
Copy link
Contributor Author

OK, so, the errors are sort of interesting. These are test cases that also break with NLL (I guess that makes sense). They have to do with closures whose signatures contain invalid types -- currently, regionck doesn't give an error for this, but it seems wrong. An example is:

    || {
        &mut x //~ ERROR cannot infer
    };

Why, you ask, is this wrong? Well, the answer is that this is an FnMut closure, so it has access to only an &'a mut self, but it is returning out access to (effectively) &mut self.x. The return type of this closure would therefore have to be something like &'a mut T where T is the type of x. But given the structure of the FnMut trait, the associated type Output cannot name this 'a, it is not in scope. And indeed if you try to use this closure in any way, the error would be detected. (Here is an analogous situation written more explicitly.)

I suspect we can get away with breaking these tests -- NLL will break them away, and they are seim-broken -- but it makes me a bit nervous. We could also try one of the alternative fixes I had in mind. (Hmm, I thought that the NLL breakage was noticed in the wild (#49824) but it turns out that this breakage was noticed by me from one of our other tests which was purposefully probing at extreme scenarios. That makes me feel better.)

One test that used to give errors also now started to work, interestingly -- that test seems clearly "ok" to me (it's an impl Trait regression test added because it used to ICE, owing to inferring a 'empty region, one that is presumably now constrained by the more coarse rule).

@nikomatsakis
Copy link
Contributor Author

On balance, given that the broken tests are basically invalid and the fixed test seems valid, I'm inclined to run with it.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:05a644b8:start=1542393462420127791,finish=1542393516717684738,duration=54297556947
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:49:08] 
[00:49:08] running 5022 tests
[00:49:11] .................................................................................................... 100/5022
[00:49:14] .................................................................................................... 200/5022
[00:49:16] .............................ii..................F.........................ii...................ii.. 300/5022
[00:49:19] ..............................................................................................iii... 400/5022
[00:49:22] .....iiiiiiii.iii............................iii...........................................i........ 500/5022
[00:49:28] .................................................................................................... 700/5022
[00:49:34] .................................................................................i...........i...... 800/5022
[00:49:37] .................................................................................................... 900/5022
[00:49:41] iiiii..................ii.iiii...................................................................... 1000/5022
---
[00:50:11] .................................................................................................... 2100/5022
[00:50:15] .................................................................................................... 2200/5022
[00:50:19] .................................................................................................... 2300/5022
[00:50:23] .................................................................................................... 2400/5022
[00:50:26] .................................................................................................FF. 2500/5022
[00:50:29] .................................................................................iiiiiiiii.......... 2600/5022
[00:50:33] .....................................................................F.............................. 2700/5022
[00:50:39] .................................................................................................... 2900/5022
[00:50:43] .................................................................................................... 3000/5022
[00:50:46] ...........................................i........................................................ 3100/5022
[00:50:49] .................................................................................................... 3200/5022
---
[00:51:41] diff of stderr:
[00:51:41] 
[00:51:41] 10    |             ------ first borrow later used here
[00:51:41] 11 
[00:51:41] 12 error[E0499]: cannot borrow `x` as mutable more than once at a time
[00:51:41] +   --> $DIR/borrowck-describe-lvalue.rs:308:20
[00:51:41] 14    |
[00:51:41] 14    |
[00:51:41] 15 LL |                    let y = &mut x;
[00:51:41] 16    |                            ------ first mutable borrow occurs here
[00:51:41] 
[00:51:41] 26 LL |              || {
[00:51:41] 27    |               - inferred to be a `FnMut` closure
[00:51:41] 28 LL | /                || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body
[00:51:41] + LL | |                    //[ast]~^ ERROR lifetime of `x` is too short
[00:51:41] 29 LL | |                    let y = &mut x;
[00:51:41] 30 LL | |                    &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
[00:51:41] - LL | |                    //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
[00:51:41] - LL | |                    *y = 1;
[00:51:41] + ...  |
[00:51:41] 33 LL | |                    drop(y);
[00:51:41] 34 LL | |                 }
[00:51bj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.ast.nll/auxiliary" "-A" "unused"
[00:51:41] ------------------------------------------
[00:51:41] 
[00:51:41] ------------------------------------------
[00:51:41] stderr:
[00:51:41] stderr:
[00:51:41] ------------------------------------------
[00:51:41] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10093,"byte_end":10099,"line_start":294,"line_end":294,"column_start":21,"column_end":27,"is_primary":false,"text":[{"text":"            let y = &mut x;","highlight_start":21,"highlight_end":27}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10113,"byte_end":10119,"line_start":295,"line_end":295,"column_start":13,"column_enPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10659,"byte_end":10665,"line_start":307,"line_end":307,"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":10686,"byte_end":10692,"line_start":308,"line_end":308,"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":10873,"byte_end":10879,"line_start":310,"line_end":310,"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_app     *y = 1;","highlight_start":1,"highlight_end":27},{"text":"                   drop(y);","highlight_start":1,"highlight_end":28},{"text":"                }","highlight_start":1,"highlight_end":18}],"label":"returns a closure that contains a reference to a captured variable, which then escapes the closure body","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10476,"byte_end":10477,"line_start":304,"line_end":304,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"           || {","highlight_start":13,"highlight_end":14}],"label":"inferred to be a `FnMut` closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`FnMut` closures only have access to their captured variables while they are executing...","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"...therefore, they cannot allow references to captured variables to escape","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: captured variable cannot escape `FnMut` closure body\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:305:16\n   |\nLL |              || {\n   |               - inferred to be a `FnMut` closure\nLL | /                || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body\nLL | |                    //[ast]~^ ERROR lifetime of `x` is too short\nLL | |                    let y = &mut x;\nLL | |                    &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable mn    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1054,"byte_end":1055,"line_start":52,"line_end":52,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = f.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `f` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1069,"byte_end":1072,"line_start":53,"line_end":53,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `f`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1224,"byte_end":1225,"line_start":55,"line_end":55,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":nulpe\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1871,"byte_end":1872,"line_start":76,"line_end":76,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = e.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `e` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1915,"byte_end":1920,"line_start":78,"line_end":78,"column_start":20,"column_end":25,"is_primary":true,"text":[{"text":"            Baz::X(value) => value","highlight_start":20,"highlight_end":25}],"label":"use of borrowed `e`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2215,"byte_end":2223,"line_start":87,"line_end":87,"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":2233,"byte_end":2236,"line_start":88,"line_end":88,"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,"e by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2505,"byte_end":2506,"line_start":95,"line_end":95,"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":2520,"byte_end":2523,"line_start":96,"line_end":96,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed",sed to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2792,"byte_end":2793,"line_start":103,"line_end":103,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = g.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `*g` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2807,"byte_end":2810,"line_start":104,"line_end":104,"column_start":9,"c    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3712,"byte_end":3720,"line_start":130,"line_end":130,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":17,"highlig"byte_start":3998,"byte_end":4004,"line_start":138,"line_end":138,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4343,"byte_end":4344,"line_start":146,"line_end":146,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x, .., _, _] => println!(\"{}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:146:18\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, x, .., _, _] => println!(\"{}\", x),\n   |                  ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:51:41] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3998,"byte_end":4004,"line_start":138,"line_end":138,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4652,"byte_end":4653,"line_start":152,"line_end":152,"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":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:152: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"}
[00:51:41] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3998,"byte_end":4004,"line_start":138,"line_end":138,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4957,"byte_end":4958,"line_start":158,"line_end":158,"column_start":28,"column_end":29,"is_primary":true,"text":[{"text":"            &[_, _, .., _, x] => println!(\"{}\", x),","highlight_start":28,"highlight_end":29}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:158:28\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, _, .., _, x] => println!(\"{}\", x),\n   |                            ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:51:41] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[00:51:41] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5354,"byte_end":5355,"line_start":170,"line_end":170,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":"            &[x..] => println!(\"{:?}\", x),","highlight_start":15,"highlight_end":16}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:170:15\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\nLL |         match v {\nLL |             &[x..] => println!(\"{:?}\", x),\n   |               ^ e information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5634,"byte_end":5635,"line_start":176,"line_end":176,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x..] => println!(\"{:?}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:176:18\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, x..] => println!(\"{:?}\", x),\n   |     ou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5911,"byte_end":5912,"line_start":182,"line_end":182,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":"            &[x.., _] => println!(\"{:?}\", x),","highlight_start":15,"highlight_end":16}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:182:15\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[x.., _] => println!(\"{:?}\",n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5314,"byte_end":5320,"line_start":168,"line_end":168,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6194,"byte_end":6195,"line_start":188,"line_end":188,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":"            &[_, x.., _] => println!(\"{:?}\", x),","highlight_start":18,"highlight_end":19}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6455,"byte_end":6456,"line_start":193,"line_end":193,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow 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:188:18\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, x.., _] => println!(\"{:?}\", x),\n   |                  ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:51:41] {"message":"cannot use `e` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6580,"byte_end":6586,"line_start":200,"line_end":200,"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":6618,"byte_end":6630,"line_start":202,"line_end":202,"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":7278,"byte_end":7279,"line_start":212,"line_end":212,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"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:202: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"}
[00:51:41] {"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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6623,"byte_end":6629,"line_start":202,"line_end":202,"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":6580,"byte_end":6586,"line_start":200,"line_end":200,"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":7278,"byte_end":7279,"line_start":212,"line_end":212,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow 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:202:18\n   |\nLL |         let x = &mut e;\n   |                 ------ mutable borrow occurs here\nLL |         match e {\nLL |             E::A(ref ax) =>\n   |                  ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow later used here\n\n"}
[00:51:41] {"message":"cannot borrow `e.x` as immutable because it is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":6989,"byte_end":6995,"line_start":207,"line_end":207,"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":6580,"byte_end":6586,"line_start":200,"line_end":200,"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":7278,"byte_end":7279,"line_start":212,"line_end":212,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:207: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"}
[00:51:41] {"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/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7520,"byte_end":7526,"line_start":221,"line_end":221,"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":nnfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7890,"byte_end":7896,"line_start":228,"line_end":228,"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":7473,"byte_end":7479,"line_start":219,"line_end":219,"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":8230,"byte_end":8231,"line_start":234,"line_end":234,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(xded and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9300,"byte_end":9306,"line_start":270,"line_end":270,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9316,"byte_end":9320,"line_start":271,"line_end":271,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"        v[0].y;","highlight_start":9,"highlight_end":13}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9564,"byte_end":9565,"line_start":275,"line_end":275,"column_start":14,"column_end":15,"is_prin.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9300,"byte_end":9306,"line_start":270,"line_end":270,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":9316,"byte_end":9322,"line_start":271,"line_end":271,"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":9564,"byte_end":9565,"line_start":275,"line_end":275,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start"yte_start":9148,"byte_end":9149,"line_start":263,"line_end":263,"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":[{"message":"This error has been downgraded to a warning for backwards compatibility with previous releases.\nIt represents potential unsoundness in your code.\nThis warning will become a hard error in the future.","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:260:33\n   |\nLL |             let x = &mut block;\n   |                     ---------- mutable borrow occurs here\nLL |             let p : *const u8 = &*(*block).current;\n   |                                 ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here\n...\nLL |             drop(x);\n   |                  - mutable borrow later used here\n   |\n   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.\n           It represents potential unsoundness in your code.\n           This warning will become a hard error in the future.\n\n"}
[00:51:41] {"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 }/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":11029,"byte_end":11030,"line_start":318,"line_end":318,"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":11054,"byte_end":11055,"line_start":319,"line_end":319,"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:319:22\n   |\nLL |                 drop(x);\n   |                      - value moved here\nLL |                 drop(x); //[ast]~ ERROR use of moved value: `x`\n   |                      ^ value used here after move\n   |\n   = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait\n\n"}
[00:51:41] {"message":"aborting due to 30 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 30 previous errors\n\n"}
[00:51:41] {"message":"Some errors occurred: E0382, E0499, E0502, E0503.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0382, E0499, E0502, E0503.\n"}
[00:51:41] {"message":"For more information about an error, try `rustc --explain E0382`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0382`.\n"}
[00:51:41] ------------------------------------------
[00:51:41] 
[00:51:41] thread '[ui (nll)] ui/borrowck/borrowck-describe-lvalue.rs#ast' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:41] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:51:41] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:51:41] 
[00:51:41] ---- [ui (nll)] ui/issues/issue-40510-1.rs stdout ----
[00:51:41] diff of stderr:
[00:51:41] 
[00:51:41] - warning: captured variable cannot escape `FnMut` closure body
[00:51:41] -   --> $DIR/issue-40510-1.rs:18:9
[00:51:41] + error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
[00:51:41] +   --> $DIR/issue-40510-1.rs:20:9
[00:51:41] 3    |
[00:51:41] + LL |         &mut x //~ ERROR cannot infer
[00:51:41] +    |
[00:51:41] +    |
[00:51:41] + note: first, the lifetime cannot outlive the lifetime  as defined on the body at 19:5...
[00:51:41] +   --> $DIR/issue-40510-1.rs:19:5
[00:51:41] +    |
[00:51:41] 4 LL |     || {
[00:51:41] -    |      - inferred to be a `FnMut` closure
[00:51:41] - LL |         &mut x
[00:51:41] -    |         ^^^^^^ returns a reference to a captured variable which escapes the closure body
[00:51:41] +    |     ^^
[00:51:41] + note: ...so that closure can access `x`
[00:51:41] +   --> $DIR/issue-40510-1.rs:20:9
[00:51:41] 8    |
[00:51:41] -    = note: `FnMut` closures only have access to their captured variables while they are executing...
[00:51:41] -    = note: ...therefore, they cannot allow references to captured variables to escape
[00:51:41] -            It represents potential unsoundness in your code.
[00:51:41] -            This warning will become a hard error in the future.
[00:51:41] -            This warning will become a hard error in the future.
[00:51:41] + LL |         &mut x //~ ERROR cannot infer
[00:51:41] +    |         ^^^^^^
[00:51:41] + note: but, the lifetime must be valid for the expression at 19:5...
[00:51:41] +   --> $DIR/issue-40510-1.rs:19:5
[00:51:41] +    |
[00:51:41] + LL | /     || {
[00:51:41] + LL | |         &mut x //~ ERROR cannot infer
[00:51:41] + LL | |     };
[00:51:41] +    | |_____^
[00:51:41] + note: ...so type `[closure@$DIR/issue-40510-1.rs:19:5: 21:6 x:&mut std::boxed::Box<()>]` of expression is valid during the expression
[00:51:41] +   --> $DIR/issue-40510-1.rs:19:5
[00:51:41] +    |
[00:51:41] + LL | /     || {
[00:51:41] + LL | |         &mut x //~ ERROR cannot infer
[00:51:41] + LL | |     };
[00:51:41] 14 
[00:51:41] + error: aborting due to previous error
[00:51:41] + 
[00:51:41] + For more information about this error, try `rustc --explain E0495`.
[00:51:41] + For more information about this error, try `rustc --explain E0495`.
[00:51:41] 15 
[00:51:41] 
[00:51:41] 
[00:51:41] The actual stderr differed from the expected stderr.
[00:51:41] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-1.nll/issue-40510-1.nll.stderr
[00:51:41] To update references, rerun the tests and pass the `--bless` flag
[00:51:41] To only update this specific test, also pass `--test-args issues/issue-40510-1.rs`
[00:51:41] error: 1 errors occurred comparing output.
[00:51:41] status: exit code: 1
[00:51:41] status: exit code: 1
[00:51:41] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-40510-1.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-1.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-40510-1.nll/auxiliary" "-A" "unused"
[00:51:41] ------------------------------------------
[00:51:41] 
[00:51:41] ------------------------------------------
[00:51:41] stderr:
[00:51:41] stderr:
[00:51:41] ------------------------------------------
[00:51:41] {"message":"cannot infer an appropriate lifetime for borrow expression due to conflicting requirements","code":{"code":"E0495","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":641,"byte_end":647,"line_start":20,"line_end":20,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        &mut x //~ ERROR cannot infer","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"first, the lifetime cannot outlive the lifetime  as defined on the body at 19:5...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":628,"byte_end":630,"line_start":19,"line_end":19,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":7}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...so that closure can access `x`","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":641,"byte_end":647,"line_start":20,"line_end":20,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        &mut x //~ ERROR cannot infer","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"but, the lifetime must be valid for the expression at 19:5...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":628,"byte_end":676,"line_start":19,"line_end":21,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":9},{"text":"        &mut x //~ ERROR cannot infer","highlight_start":1,"highlight_end":38},{"text":"    };","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...so type `[closure@/checkout/src/test/ui/issues/issue-40510-1.rs:19:5: 21:6 x:&mut std::boxed::Box<()>]` of expression is valid during the expression","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-1.rs","byte_start":628,"byte_end":676,"line_start":19,"line_end":21,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    || {","highlight_start":5,"highlight_end":9},{"text":"        &mut x //~ ERROR cannot infer","highlight_start":1,"highlight_end":38},{"text":"    };","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:20:9\n   |\nLL |         &mut x //~ ERROR cannot infer\n   |         ^^^^^^\n   |\nnote: first, the lifetime cannot outlive the lifetime  as defined on the body at 19:5...\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:19:5\n   |\nLL |     || {\n   |     ^^\nnote: ...so that closure can access `x`\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:20:9\n   |\nLL |         &mut x //~ ERROR cannot infer\n   |         ^^^^^^\nnote: but, the lifetime must be valid for the expression at 19:5...\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:19:5\n   |\nLL | /     || {\nLL | |         &mut x //~ ERROR cannot infer\nLL | |     };\n   | |_____^\nnote: ...so type `[closure@/checkout/src/test/ui/issues/issue-40510-1.rs:19:5: 21:6 x:&mut std::boxed::Box<()>]` of expression is valid during the expression\n  --> /checkout/src/test/ui/issues/issue-40510-1.rs:19:5\n   |\nLL | /     || {\nLL | |         &mut x //~ ERROR cannot infer\nLL | |     };\n   | |_____^\n\n"}
[00:51:41] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:41] {"message":"For more information about this error, try `rustc --explain E0495`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0495`.\n"}
[00:51:41] ------------------------------------------
[00:51:41] 
[00:51:41] thread '[ui (nll)] ui/issues/issue-40510-1.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:41] 
[00:51:41] 
[00:51:41] ---- [ui (nll)] ui/issues/issue-40510-3.rs stdout ----
[00:51:41] diff of stderr:
[00:51:41] 
[00:51:41] - warning: captured variable cannot escape `FnMut` closure body
[00:51:41] -   --> $DIR/issue-40510-3.rs:18:9
[00:51:41] + error: captured variable cannot escape `FnMut` closure body
[00:51:41] +   --> $DIR/issue-40510-3.rs:20:9
[00:51:41] 3    |
[00:51:41] 4 LL |       || {
[00:51:41] 5    |        - inferred to be a `FnMut` closure
[00:51:41] 
[00:51:41] - LL | /         || {
[00:51:41] + LL | /         || { //~ ERROR too short
[00:51:41] 7 LL | |             x.push(())
[00:51:41] 8 LL | |         }
[00:51:41] 9    | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
[00:51:41] 10    |
[00:51:41] 11    = notused"
[00:51:41] stdout:
[00:51:41] ------------------------------------------
[00:51:41] ------------------------------------------
[00:51:41] 
[00:51:41] ------------------------------------------
[00:51:41] stderr:
[00:51:41] ------------------------------------------
[00:51:41] {"message":"captured variable cannot escape `FnMut` closure body","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-40510-3.rs","byte_start":639,"byte_end":696,"line_start":20,"line_end":22,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":"        || { //~ ERROR too short","highlight_start":9,"highlight_end":33},{"text":"            x.push(())","highlight_start":1,"highlight_end":23},{"text":"        }","highlight_start":1,"highlight_end":10}],"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/issues/issue-40510-3.rs","byte_start":627,"byte_end":628,"line_start":19,"line_end":19,"column_start":6,"column_end":7,"is_primary":false,"text":[{"text":"    || {","highlight_start":6,"highlight_end":7}],"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":"erro^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
[00:51:41] 10    |
[00:51:41] 10    |
[00:51:41] 11    = note: `FnMut` closures only have access to their captured variables while they are executing...
[00:51:41] 12    = note: ...therefore, they cannot allow references to captured variables to escape
[00:51:41] -            It represents potential unsoundness in your code.
[00:51:41] -            This warning will become a hard error in the future.
[00:51:41] - 
[00:51:41] - error: compilation successful
[00:51:41] - error: compilation successful
[00:51:41] -   --> $DIR/issue-49824.rs:18:1
[00:51:41] -    |
[00:51:41] - LL | / fn main() {
[00:51:41] - LL | |     //~^ compilation successful
[00:51:41] - LL | |     let mut x = 0;
[00:51:41] - LL | |     || {
[00:51:41] - ...  |
[00:51:41] - LL | |     };
[00:51:41] - LL | | }
[00:51:41] 28 
[00:51:41] 29 error: aborting due to previous error
[00:51:41] 30 
[00:51:41] 
[00:51:41] 
[00:51:41] 
[00:51:41] The actual stderr differed from the expected stderr.
[00:51:41] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-49824.nll/issue-49824.nll.stderr
[00:51:41] To update references, rerun the tests and pass the `--bless` flag
[00:51:41] To only update this specific test, also pass `--test-args issues/issue-49824.rs`
[00:51:41] error: 1 errors occurred comparing output.
[00:51:41] status: exit code: 1
[00:51:41] status: exit code: 1
[00:51:41] command: "/checkout/obj/build/x86_64-unknown-linux-gt_start":6,"highlight_end":7}],"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/issues/issue-49824.rs:23:9\n   |\nLL |       || {\n   |        - inferred to be a `FnMut` closure\nLL | /         || { //~ ERROR too short\nLL | |             let _y = &mut x;\nLL | |         }\n   | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body\n   |\n   = note: `FnMut` closures only have access to their captured variables while they are executing...\n   = note: ...therefore, they cannot allow references to captured variables to escape\n\n"}
[00:51:41] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:41] ------------------------------------------
[00:51:41] 
[00:51:41] thread '[ui (nll)] ui/issues/issue-49824.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:41] 
---
travis_time:end:0638ee2c:start=1542396629515816872,finish=1542396629523231789,duration=7414917
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1c8e8c41
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0e149ff5
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:01b07478:start=1542401858657554307,finish=1542401916210817723,duration=57553263416
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:52:40] .................................................................................................... 100/5021
[00:52:43] .................................................................................................... 200/5021
[00:52:46] .............................ii............................................ii...................ii.. 300/5021
[00:52:48] ..............................................................................................iii... 400/5021
[00:52:51] .....iiiiiiii.iii............................iii...........................................i........ 500/5021
[00:52:58] .................................................................................................... 700/5021
[00:53:05] .................................................................................i...........i...... 800/5021
[00:53:08] .................................................................................................... 900/5021
[00:53:11] .iiiii.................ii.iiii...................................................................... 1000/5021
---
[00:53:48] .................................................................................................... 2200/5021
[00:53:52] .................................................................................................... 2300/5021
[00:53:56] .................................................................................................... 2400/5021
[00:54:00] .................................................................................................... 2500/5021
[00:54:03] ................................................................................iiiiiiiii........... 2600/5021
[00:54:10] ..............................................ii.................................................... 2800/5021
[00:54:13] .................................................................................................... 2900/5021
[00:54:16] .................................................................................................... 3000/5021
[00:54:20] ...........................................i........................................................ 3100/5021
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:08:16] 
[01:08:16] running 116 tests
[01:08:19] i..ii...iii..iiii.....i...i.........i..iii...........i.....i.....ii...i..i.ii..............i...ii..i 100/116
[01:08:19] i.i....iiii.....
[01:08:19] 
[01:08:19]  finished in 3.567
[01:08:19] travis_fold:end:test_codegen

---
travis_time:start:test_incremental
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:08:21] 
[01:08:21] running 92 tests
[01:08:34] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[01:08:34] .................F..........................................................................
[01:08:34] 
[01:08:34] ---- [incremental] incremental/hashes/closure_expressions.rs stdout ----
[01:08:34] 
[01:08:34] 
[01:08:34] error in revision `cfail1`: test compilation failed although it shouldn't!
[01:08:34] status: exit code: 1
[01:08:34] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/incremental/hashes/closure_expressions.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "cfail1" "-C" "incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental/hashes/closure_expressions/closure_expressions.inc" "-Z" "incremental-verify-ich" "-Z" "incremental-queries" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental/hashes/closure_expressions/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "query-dep-graph" "-Zincremental-ignore-spans" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental/hashes/closure_expressions/auxiliary"
[01:08:34] ------------------------------------------
[01:08:34] 
[01:08:34] ------------------------------------------
[01:08:34] stderr:
[01:08:34] stderr:
[01:08:34] ------------------------------------------
[01:08:34] {"message":"cannot infer an appropriate lifetime due to conflicting requirements","code":{"code":"E0495","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/incremental/hashes/closure_expressions.rs","byte_start":1810,"byte_end":1811,"line_start":63,"line_end":63,"column_start":23,"column_end":24,"is_primary":true,"text":[{"text":"    let _ = |x: &u32| x;","highlight_start":23,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 63:13...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/incremental/hashes/closure_expressions.rs","byte_start":1800,"byte_end":1811,"line_start":63,"line_end":63,"column_start":13,"column_end":24,"is_primary":true,"text":[{"text":"    let _ = |x: &u32| x;","highlight_start":13,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...so that the expression is assignable:\nexpected &u32\n   found &u32","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"but, the lifetime must be valid for the expression at 63:13...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/incremental/hashes/closure_expressions.rs","byte_start":1800,"byte_end":1811,"line_start":63,"line_end":63,"column_start":13,"column_end":24,"is_primary":true,"text":[{"text":"    let _ = |x: &u32| x;","highlight_start":13,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...so type `[closure@/checkout/src/test/incremental/hashes/closure_expressions.rs:63:13: 63:24]` of expression is valid during the expression","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/incremental/hashes/closure_expressions.rs","byte_start":1800,"byte_end":1811,"line_start":63,"line_end":63,"column_start":13,"column_end":24,"is_primary":true,"text":[{"text":"    let _ = |x: &u32| x;","highlight_start":13,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements\n  --> /checkout/src/test/incremental/hashes/closure_expressions.rs:63:23\n   |\nLL |     let _ = |x: &u32| x;\n   |                       ^\n   |\nnote: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 63:13...\n  --> /checkout/src/test/incremental/hashes/closure_expressions.rs:63:13\n   |\nLL |     let _ = |x: &u32| x;\n   |             ^^^^^^^^^^^\n   = note: ...so that the expression is assignable:\n           expected &u32\n              found &u32\nnote: but, the lifetime must be valid for the expression at 63:13...\n  --> /checkout/src/test/incremental/hashes/closure_expressions.rs:63:13\n   |\nLL |     let _ = |x: &u32| x;\n   |             ^^^^^^^^^^^\nnote: ...so type `[closure@/checkout/src/test/incremental/hashes/closure_expressions.rs:63:13: 63:24]` of expression is valid during the expression\n  --> /checkout/src/test/incremental/hashes/closure_expressions.rs:63:13\n   |\nLL |     let _ = |x: &u32| x;\n   |             ^^^^^^^^^^^\n\n"}
[01:08:34] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[01:08:34] {"message":"For more information about this error, try `rustc --explain E0495`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0495`.\n"}
[01:08:34] ------------------------------------------
[01:08:34] 
[01:08:34] thread '[incremental] incremental/hashes/closure_expressions.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[01:08:34] note: Run with `RUST_BACKTRACE=1` trap/debug/bootstrap test
[01:08:34] note: Run with `RUST_BACKTRACE=1` trap/debug/bootstrap test
[01:08:34] Build completed unsuccessfully in 0:19:45
[01:08:34] make: *** [check] Error 1
[01:08:34] Makefile:58: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:17754cf3
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Nov 16 22:07:20 UTC 2018

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Nov 18, 2018

📌 Commit 752feb7814fd98c383c344dccb6cd9c328fbcf5e 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 18, 2018
@alexcrichton
Copy link
Member

@nikomatsakis with #56043 landed and backported is still still 2018 edition critical? (aka on the milestone)

@nikomatsakis
Copy link
Contributor Author

@alexcrichton it is not

@nikomatsakis nikomatsakis removed this from the Rust 2018 Release milestone Nov 19, 2018
@nikomatsakis
Copy link
Contributor Author

@bors p=0

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Nov 21, 2018

📌 Commit 29ec15a 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 21, 2018
@nikomatsakis
Copy link
Contributor Author

@bors r-

Actually, second guessing. I want to think about whether to land this now or let NLL fix these test cases.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 21, 2018
@TimNN
Copy link
Contributor

TimNN commented Dec 4, 2018

Ping from triage @nikomatsakis: What is the status of this PR?

@bors
Copy link
Contributor

bors commented Dec 7, 2018

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

@pnkfelix
Copy link
Member

pnkfelix commented Dec 10, 2018

@nikomatsakis I'd like us to consider landing this now.

Minimizing the number of subtle discrepancies between AST-borrowck and NLL simplifies our internal processes for evaluating the correctness of NLL itself.

@eddyb
Copy link
Member

eddyb commented Dec 10, 2018

@pnkfelix I would prefer landing this if it gets us closer to removing the AST borrowck (is there a full post-2018 transition plan spelled out anywhere?).

@Dylan-DPC-zz
Copy link

ping from triage @nikomatsakis @pnkfelix @eddyb any updates on this?

@nikomatsakis
Copy link
Contributor Author

Sorry, I've been busy. I'm going to try and rebase this and/or close it this week though =)

@stokhos
Copy link

stokhos commented Jan 14, 2019

Ping from triage @nikomatsakis Have you been able to make any progress on this PR?

@nikomatsakis
Copy link
Contributor Author

nikomatsakis commented Jan 14, 2019 via email

@TimNN TimNN added A-allocators Area: Custom and system allocators and removed A-allocators Area: Custom and system allocators labels Jan 22, 2019
@Centril
Copy link
Contributor

Centril commented Jan 27, 2019

Ping from triage, @nikomatsakis -- have you been able to make progress?

r? @pnkfelix

@rust-highfive rust-highfive assigned pnkfelix and unassigned eddyb Jan 27, 2019
@Dylan-DPC-zz
Copy link

ping from triage @nikomatsakis closing this due to inactivity. Thanks

@Dylan-DPC-zz Dylan-DPC-zz added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lifetimes bug on beta 1.31: the associated type may not live long enough