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

[NLL] Use smaller spans for errors involving closure captures #52959

Merged
merged 3 commits into from
Aug 5, 2018

Conversation

matthewjasper
Copy link
Contributor

Closes #51170
Closes #46599

Error messages involving closures now point to the captured variable/closure args.

r? @pnkfelix

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2018
@matthewjasper
Copy link
Contributor Author

Comments (which seem to have gone missing) addressed

@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.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/2a/a2/dba13566ff2819757280c7c92ca225de3bef4ef4892697885156dbe36ac9/awscli-1.15.71-py2.py3-none-any.whl (1.3MB)
    0% |▎                               | 10kB 10.8MB/s eta 0:00:01
    1% |▌                               | 20kB 1.9MB/s eta 0:00:01
    2% |▊                               | 30kB 2.2MB/s eta 0:00:01
    3% |█                               | 40kB 2.0MB/s eta 0:00:01
---
travis_time:start:test_ui
Check compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:42:15] 
[00:42:15] running 2233 tests
[00:42:18] .......................................F...........F....................F...........................
[00:42:25] ....................................................................................................
[00:42:27] ....................................................................................................
[00:42:29] ....................................................................................................
[00:42:32] ....................................................................................................
[00:42:32] ....................................................................................................
[00:42:34] ....................................................................................................
[00:42:37] ....................................................................................................
[00:42:40] ....................................................................................................
[00:42:42] ...........i........................................................................................
[00:42:44] ....................................................................................................
[00:42:47] ....................................FF.F............................................................
[00:42:49] ..........................................................................F.........................
[00:42:52] ..................................................................................................F.
[00:42:55] ............FF.............F.............................F..........................................
[00:43:01] ....................................................................................................
[00:43:01] ....................................................................................................
[00:43:05] .....i.........FF..FF...FF.F..FFF..............F.......F.F..............F...................F.......
[00:43:11] ....................................................................................................
[00:43:14] ....................................................................................................
/borrowck-closures-two-mut.rs`
[00:43:19] 
[00:43:19] 
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-closures-two-mut/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=compare" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-closures-two-mut/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet ut.rs","byte_start":1139,"byte_end":1140,"line_start":36,"line_end":36,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1099,"byte_end":1100,"line_start":35,"line_end":35,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut x));","highlight_start":36,"highlight_end":37}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:36:24\n   |\nLL |     let c1 = to_fn_mut(|| set(&mut x));\n   |                        --          - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\n...\nLL | }\n   | - first borrow ends here\n\n"}
[00:43:19] {"message":"cannot borrow `x` as mutable more than onc":1515,"byte_end":1516,"line_start":47,"line_end":47,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"first borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1377,"byte_end":1378,"line_start":44,"line_end":44,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1334,"byte_end":1335,"line_start":43,"line_end":43,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":27,"highlight_end":28}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:44:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 5);\n   |                        -- - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x`|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1806,"byte_end":1807,"line_start":56,"line_end":56,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"first borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1639,"byte_end":1640,"line_start":52,"line_end":52,"column_start":60,"column_end":61,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)","highlight_start":60,"highlight_end":61}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1572,"byte_end":1573,"line_start":51,"line_end":51,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":27,"highlight_end":28}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1976,"byte_end":1978,"line_start":65,"line_end":65,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut *x.f));","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":2134,"byte_end":2135,"line_start":69,"line_end":69,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"first borrow ends here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1989,"byte_end":1990,"line_start":65,"line_end":65,"column_start":37,"column_end":38,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut *x.f));","highlight_start":37,"highlight_end":38}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1946,"byte_end":1947,"line_start":64,"line_end":64,"column_start":37,"column_end":38,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut *x.f));","highlight_start":37,"highlight_end":38}],"label":"previous borrow occurs due to use ofon":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":984,"byte_end":986,"line_start":26,"line_end":26,"column_start":11,"column_end":13,"is_primary":false,"text":[{"text":"    drop((c1, c2));","highlight_start":11,"highlight_end":13}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:24:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 4);\n   |                        -- - first borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^ - second borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL |     drop((c1, c2));\n   |           -- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `x` as mutable more than once at a time (Mir)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1087,"byte_end":1089,"line_start":35,"line_end":35,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut x));","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1127,"byte_end":1129,"line_start":36,"line_end":36,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1099,"byte_end":1100,"line_start":35,"line_end":35,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut x));","highlight_start":36,"highlight_end":37}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1139,"byte_end":1140,"line_start":36,"line_end":36,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1267,"byte_end":1269,"line_start":38,"line_end":38,"column_start":11,"column_end":13,"is_primary":false,"text":[{"text":"    drop((c1, c2));","highlight_start":11,"highlight_end":13}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:36:24\n   |\nLL |     let c1 = to_fn_mut(|| set(&mut x));\n   |                        --          - first borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - second borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than o"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1334,"byte_end":1335,"line_start":43,"line_end":43,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":27,"highlight_end":28}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1377,"byte_end":1378,"line_start":44,"line_end":44,"column_start":36,"column_end":37,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":36,"highlight_end":37}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1505,"byte_end":1507,"line_start":46,"line_end":46,"column_start":11,"column_end":13,"is_primary":false,"text":[{"text":"    drop((c1, c2));","highlight_start":11,"highlight_end":13}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:44:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 5);\n   |                        -- - first borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - second borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL |     drop((c1, c2));\n   |           -- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `x` as mutable more than once at a time (Mir)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1569,"byte_end":1571,"line_start":51,"line_end":51,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1603,"byte_end":1605,"line_start":52,"line_end":52,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1572,"byte_end":1573,"line_start":51,"line_end":51,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 5);","highlight_start":27,"highlight_end":28}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1639,"byte_end":1640,"line_start":52,"line_end":52,"column_start":60,"column_end":61,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)","highlight_start":60,"highlight_end":61}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1796,"byte_end":1798,"line_start":55,"line_end":55,"column_start":11,"column_end":13,"is_primary":false,"slice-pattern-element-loan.rs:55:20
[00:43:19] 
[00:43:19] 27 LL |         if let [_, ref mut from_begin1, ..] = *s { //~ERROR
[00:43:19] 28    |                    ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[00:43:19] 29 LL |             nop(&[from_begin1, from_end1, from_end3, from_end4]);
[00:43:19] +    |                                                      --------- borrow used here in later iteration of loop
[00:43:19] 31 
[00:43:19] 31 
[00:43:19] 32 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
[00:43:19] 
[00:43:19] 
[00:43:19] 38 LL |         if let [_, _, ref mut from_begin2, ..] = *s { //~ERROR
[00:43:19] 39    |                       ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[00:43:19] 40 LL |             nop(&[from_begin2, from_end1, from_end3, from_end4]);
[00:43:19] +    |                                           --------- borrow used here in later iteration of loop
[00:43:19] 42 
[00:43:19] 42 
[00:43:19] 43 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
[00:43:19] 
[00:43:19] 
[00:43:19] 49 LL |         if let [_, _, _, ref mut from_begin3, ..] = *s { //~ERROR
[00:43:19] 50    |                          ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
[00:43:19] 51 LL |             nop(&[from_begin3, from_end1, from_endent-loan/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-slice-pattern-element-loan/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"cannot borrow `s[..]` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":900,"byte_end":916,"line_start":28,"line_end":28,"column_start":20,"column_end":36,"is_primary":true,"text":[{"text":"        ---- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `s[..]` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":1367,"byte_end":1381,"line_start":44,"line_end":44,"column_start":21,"column_end":35,"is_primary":true,"text":[{"text":"        if let [.., ref mut third2, _, _] = *s { //~ERROR","highlight_start":21,"highlight_end":35}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":1315,"byte_end":1324,"line_start":43,"line_end":43,"column_start":29,"column_end":38,"is_primary":false,"text":[{"text":"    if let [{"text":"            nop(&[from_begin1, from_end1, from_end3, from_end4]);","highlight_start":54,"highlight_end":63}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs:55:20\n   |\nLL |     if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {\n   |                    ------------- immutable borrow occurs here\n...\nLL |         if let [_, ref mut from_begin1, ..] = *s { //~ERROR\n   |                    ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\nLL |             nop(&[from_begin1, from_end1, from_end3, from_end4]);\n   |                                                      --------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `s[..]` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) e it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs:58:23\n   |\nLL |     if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {\n   |                                   ------------- immutable borrow occurs here\n...\nLL |         if let [_, _, ref mut from_begin2, ..] = *s { //~ERROR\n   |                       ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here\nLL |             nop(&[from_begin2, from_end1, from_end3, from_end4]);\n   |                                           --------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `s[..]` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":2010,"rom_begin3, _, ..] = *s {","highlight_start":50,"highlight_end":65}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":2583,"byte_end":2594,"line_start":73,"line_end":73,"column_start":45,"column_end":56,"is_primary":false,"text":[{"text":"            nop(&[from_begin0, from_begin1, from_begin3, from_end3]);","highlight_start":45,"highlight_end":56}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs:72:21\n   |\nLL |     if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {\n   |                                                  --------------- immutable borrow occurs here\n...\nLL |         if let [.., ref mut from_end3, _,  _] = *s { //~ERROR\n   |                     ^^^^^^^^^^^^^^^^^ mutable borrow occurs here\nLL |             nop(&[from_begin0, from_begin1, from_begin3, from_end3]);\n   |                                             ----------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `s[..]` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":2639,"byte_end":2656,"line_start":75,"line_end":75,"column_start":21,"column_end":38,"is_primary":true,"text":[{"text":"        if let [.., ref mut from_end4, _, _, _] = *s { //~ERROR","highlight_start":21,"highlight_end":38}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":2162,"byte_end":2177,"line_start":65,"line_end":65,"column_start":30,"column_end":45,"is_primary":false,"text":[{"text":"    if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {","highlight_start":30,"highlight_end":45}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":2714,"byte_end":2725,"line_start":76,"line_end":76,"column_start":32,"column_end":43,"is_primary":false,"text":[{"text":"            nop(&[from_begin0, from_begin1, from_begin3, from_end4]);","highlight_start":32,"highlight_end":43}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs:75:21\n   |\nLL |     if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {\n   |                              --------------- immutable borrow occurs here\n...\nLL |         if let [.., ref mut from_end4, _, _, _] = *s { //~ERROR\n   |                     ^^^^^^^^^^^^^^^^^ mutable borrow occurs here\nLL |             nop(&[from_begin0, from_begin1, from_begin3, from_end4]);\n   |                                ----------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `s[..]` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any ot{","highlight_start":22,"highlight_end":28}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs","byte_start":3852,"byte_end":3854,"line_start":120,"line_end":120,"column_start":26,"column_end":28,"is_primary":false,"text":[{"text":"            nop_subslice(s1);","highlight_start":26,"highlight_end":28}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs:119:17\n   |\nLL |     if let [_, _, _, ref s1..] = *s {\n   |                      ------ immutable borrow occurs here\nLL |         if let [ref mut s2.., _, _, _] = *s { //~ERROR\n   |                 ^^^^^^^^^^ mutable borrow occurs here\nLL |             nop_subslice(s1);\n   |                          -- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"aborting due to 11 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 11 previous errors\n\n"}
[00:43:19] {"message":"For more information about this error, try `rustc --explain E0502`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0502`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] 
[00:43:19] thread '[ui] ui/bormut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/two-phase-multi-mut.rs","byte_start":606,"byte_end":609,"line_start":23,"line_end":23,"column_start":5,"column_end":8,"is_primary":false,"text":[{"text":"    foo.method(&mut foo);","highlight_start":5,"highlight_end":8}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-multi-mut.rs","byte_start":617,"byte_end":625,"line_start":23,"line_end":23,"column_start":16,"column_end":24,"is_primary":true,"text":[{"text":"    foo.method(&mut foo);","highlight_start":16,"highlight_end":24}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-multi-mut.rs","byte_start":606,"byte_end":626,"line_start":23,"line_end":23,"column_start":5,"column_end":25,"is_primary":false,"text":[{"text":"    foo.method(&mut foo);","highlight_start":5,"highlight_end":25}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansio
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-27282-move-match-input-into-guard/issue-27282-move-match-input-into-guard.stderr
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-27282-move-match-input-into-guard/issue-27282-move-match-input-into-guard.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args issue-27282-move-match-input-into-guard.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-27282-move-match-input-into-guard.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/issue-27282-move-match-input-into-guard/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/issue-27282-move-match-input-into-guard/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"cannot move out of `b` because it is borrowed","code":{"code":"E0505","explanation":"\nA value was moved out while it was still borrowed.\n\nErroneous code example:\n\n```compile_fail,E0505\nstruct Value {}\n\nfn eat(val: Value) {}\n\nfn main() {\n    let x = Value{};\n    {\n         |\n   |                 move out of `b` occurs here\n...\nLL |         &mut true => { println!(\"You might think we should get here\"); },\n   |         --------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"use of moved value: `*b`","code":{"code":"E0382","explanation":"\nThis error occurs when an attempt is made to use a variable after its contents\nhave been moved elsewhere. For example:\n\n```compile_fail,E0382\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = MyStruct{ s: 5u32 };\n    let y = x;\n    x.s = 6;\n    println!(\"{}\", x.s);\n}\n```\n\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\nof `x` when we set `y`. This is fundamental to Rust's ownership system: outside\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\n\nSometimes we don't need to move the value. Using a reference, we can let another\nfunction borrow the value without changing its ownership. In the example below,\nwe don't actually have to move our string to `calculate_length`, we can give it\na reference to it with `&` instead.\n\n```\nfn main() {\n    let s1 = String::from(\"hello\");\n\n    let len = calculate_length(&s1);\n\n    println!(\"The length of '{}' is {}.\", s1, len);\n}\n\nfn calculate_length(s: &String) -> usize {\n    s.len()\n}\n```\n\nA mutable reference can be created with `&mut`.\n\nSometimes we don't want a reference, but a duplicate. All types marked `Clone`\ncan be duplicated by calling `.clone()`. Subsequent changes to a clone do not\naffect the original variable.\n\nMost types in the standard library are marked `Clone`. The example below\ndemonstrates using `clone()` on a string. `s1` is first set to \"many\", and then\ncopied to `s2`. Then the first character of `s1` is removed, without affecting\n`s2`. \"any many\" is printed to the console.\n\n```\nfn main() {\n    let mut s1 = String::from(\"many\");\n    let s2 = s1.clone();\n    s1.remove(0);\n    println!(\"{} {}\", s1, s2);\n}\n```\n\nIf we control the definition of a type, we can implement `Clone` on it ourselves\nwith `#[derive(Clone)]`.\n\nSome types have no ownership semantics at all and are trivial to duplicate. An\nexample is `i32` and the other number types. We don't have to call `.clone()` to\nclone them, because they are marked `Copy` in addition to `Clone`.  Implicit\ncloning is more convenient in this case. We can mark our own types `Copy` if\nall their members also are marked `Copy`.\n\nIn the example below, we implement a `Point` type. Because it only stores two\nintegers, we opt-out of ownership semantics with `Copy`. Then we can\n`let p2 = p1` without `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n    let mut p1 = Point{ x: -1, y: 2 };\n    let p2 = p1;\n    p1.x = 1;\n    println!(\"p1: {}, {}\", p1.x, p1.y);\n    println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don't control the struct's definition, or mutable shared\nownership is truly required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the chapter in the\nBook:\n\nhttps://doc.rust-lang.org/book/first-edition/ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issue-27282-move-match-input-into-guard.rs","byte_start":980,"byte_end":982,"line_start":26,"line_end":26,"column_start":17,"column_end":19,"is_primary":false,"text":[{"text":"        _ if { (|| { let bar = b; *bar = false; })();","highlight_start":17,"highlight_end":19}],"label":"value moved into closure here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-move-match-input-into-guard.rs","byte_start":995,"byte_end":996,"line_start":26,"line_end":26,"column_start":32,"column_end":33,"is_primary":false,"text":[{"text":"        _ if { (|| { let bar = b; *bar = false; })();","highlight_start":32,"highlight_end":33}],"label":"variable moved due to use in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-move-match-input-into-guard.rs","byte_start":1154,"byte_end":1158,"line_start":29,"line_end":29,"column_start":14,"column_end":18,"is_primary":true,"text":[{"text":"        &mut true => { println!(\"You might think we should get here\"); },","highlight_start":14,"highlight_end":18}],"label":"here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-1.rs","byte_start":1105,"byte_end":1106,"line_start":29,"line_end":29,"column_start":11,"column_end":12,"is_primary":false,"text":[{"text":"    match x {","highlight_start":11,"highlight_end":12}],"label":"borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-1.rs","byte_start":1251,"byte_end":1252,"line_start":33,"line_end":33,"column_start":20,"column_end":21,"is_primary":false,"text":[{"text":"            (|| { *x = None; drop(force_fn_once); })();","highlight_start":20,"highlight_end":21}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-1.rs","byte_start":1426,"byte_end":1439,"line_start":37,"line_end":37,"column_start":9,"column_end":22,"is_primary":false,"text":[{"text":"        &mut Some(&a) if { // this binds to garbage if we've corrupted discriminant","highlight_start":9,"highlight_end":22}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0500]: closure requires unique access to `x` but it is already borrowed\n  --> /checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-1.rs:33:14\n   |\nLL |     match x {\n   |           - borrow occurs here\n...\nLL |             (|| { *x = None; drop(force_fn_once); })();\n   |              ^^    - second borrow occurs due to use of `x` in closure\n   |              |\n   |              closure construction occurs here\n...\nLL |         &mut Some(&a) if { // this binds to garbage if we've corrupted discriminant\n   |         ------------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:43:19] {"message":"For more information about this error, try `rustc --explain E0500`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0500`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/issue-27282-mutate-before-diverging-arm-1.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/issue-27282-mutate-before-diverging-arm-2.rs stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 10    |                  closure construction occurs here
[00:43:19] 11 ...
[00:43:19] 12 LL |         &mut Some(&2)
[00:43:19] +    |         ------------- borrow used here in later iteration of loop
[00:43:19] 14 
[00:43:19] 15 error: aborting due to previous error
[00:43:19] 16 
[00:43:19] 16 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-27282-mutate-before-diverging-arm-2/issue-27282-mutate-before-diverging-arm-2.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args issue-27282-mutate-before-diverging-arm-2.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-2.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/issue-27282-mutate-before-diverging-arm-2/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/issue-27282-mutate-before-diverging-arm-2/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"closure requires unique access to `x` but it is already borrowed","code":{"code":"E0500","explanation":"\nA borrowed variable was used in another closure. Example of erroneous code:\n\n```compile_fail\nfn you_know_nothing(jon_snow: &mut i32) {\n    let nights_watch = || {\n        *jon_snow = 2;\n    };\n    let starks = || {\n        *jon_snow = 3; // error: closure requires unique access to `jon_snow"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-2.rs","byte_start":1416,"byte_end":1417,"line_start":38,"line_end":38,"column_start":24,"column_end":25,"is_primary":false,"text":[{"text":"                (|| { *x = None; drop(force_fn_once); })();","highlight_start":24,"highlight_end":25}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-2.rs","byte_start":1805,"byte_end":1818,"line_start":46,"line_end":46,"column_start":9,"column_end":22,"is_primary":false,"text":[{"text":"        &mut Some(&2)","highlight_start":9,"highlight_end":22}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0500]: closure requires unique access to `x` but it is already borrowed\n  --> /checkout/src/test/ui/issue-27282-mutate-before-diverging-arm-2.rs:38:18\n   |\nLL |     match x {\n   |           - borrow occurs here\n...\nLL |                 (|| { *x = None; drop(force_fn_once); })();\n   |                  ^^    - second borrow occurs due to use of `x` in closure\n   |                  |\n   |                  closure construction occurs here\n...\nLL |         &mut Some(&2)\n   |         ------------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:43:19] {"message":"For more information about this error, try `rustc --explain E0500`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0500`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/issue-27282-mutate-before-diverging-arm-2.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/issue-36082.rs#mir stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 7    |                   temporary value does not live long enough
[00:43:19] 8 ...
[00:43:19] 9 LL |     println!("{}", val);
[00:43:19] +    |                    --- borrow used here in later iteration of loop
[00:43:19] 11 
[00:43:19] 12 error: aborting due to previous error
[00:43:19] 13 
[00:43:19] 13 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-36082.mir/issue-36082.mir.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args issue-36082.rs`
[00:43:19] 
[00:43:19] error in revision `mir`: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-36082.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "mir" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-36082.mir/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-36082.mir/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"borrowed value 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/issue-36082.rs","byte_start":710,"byte_end":720,"line_start":23,"line_end":23,"column_start":19,"column_end":29,"is_primary":true,"text":[{"text":"    let val: &_ = x.borrow().0;","highlight_start":19,"highlight_end":29}],"label":"tem:43:19] {"message":"For more information about this error, try `rustc --explain E0502`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0502`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/issue-45157.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/issue-45697-1.rs stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 15    |         ^^^^^^^^^^^^^^^ use of borrowed `y`
[00:43:19] 16 ...
[00:43:19] 17 LL |         *z.pointer += 1;
[00:43:19] +    |         --------------- borrow used here in later iteration of loop
[00:43:19] 19 
[00:43:19] 19 
[00:43:19] 20 error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
[00:43:19] 
[00:43:19] 
[00:43:19] 26    |         ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
[00:43:19] 27 ...
[00:43:19] 28 LL |         *z.pointer += 1;
[00:43:19] +    |         --------------- borrow used here in later iteration of loop
[00:43:19] 30 
[00:43:19] 31 error: aborting due to 3 previous errors
[00:43:19] 32 
[00:43:19] 32 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-45697-1/issue-45697-1.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless`ng 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/issue-45697-1.rs","byte_start":930,"byte_end":936,"line_start":29,"line_end":29,"column_start":35,"column_end":41,"is_primary":false,"text":[{"text":"        let z = copy_borrowed_ptr(&mut y);","highlight_start":35,"highlight_end":41}],"label":"borrow of `y` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-45697-1.rs","byte_start":947,"byte_end":962,"line_start":30,"line_end":30,"column_start":9,"column_end":24,"is_primary":true,"text":[{"text":"        *y.pointer += 1;","highlight_start":9,"highlight_end":24}],"label":"use of borrowed `y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/srn    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n    let moved_num = fancy_num;\n    fancy_num = FancyNum { num: 6 };\n\n    println!(\"Num: {}, Moved num: {}\", fancy_num.num, moved_num.num);\n}\n```\n\nIf the value has to be borrowed, try limiting the lifetime of the borrow using\na scoped block:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n\n    {\n        let fancy_ref = &fancy_num;\n        println!(\"Ref: {}\", fancy_ref.num);\n    }\n\n    // Works because `fancy_ref` is no longer in scope\n    fancy_num = FancyNum { num: 6 };\n    println!(\"Num: {}\", fancy_num.num);\n}\n```\n\nOr by moving the reference into a function:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n\n    print_fancy_ref(&fancy_num);\n\n    // Works because function borrow has ended\n    fancy_num = FancyNum { num: 6 };\n    println!(\"Num: {}\", fancy_num.num);\n}\n\nfn print_fancy_ref(fancy_ref: &FancyNum){\n    println!(\"Ref: {}\", fancy_ref.num);\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issue-45697-1.rs","byte_start":930,"byte_end":936,"line_start":29,"line_end":29,"column_start":35,"column_end":41,"is_primary":false,"text":[{"text":"        let z = copy_borrowed_ptr(&mut y);","highlight_start":35,"highlight_end":41}],"label":"borrow of `*y.pointer` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-45697-1.rs","byte_start":947,"byte_end":962,"line_start":30,"line_end":30,"column_start"9] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-45697.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/issue-45697/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "emit-end-regions" "-Z" "borrowck=compare" "-C" "overflow-checks=off" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-45697/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"cannot assign to `*y.pointer` because it is borrowed (Ast)","code":{"code":"E0506","explanation":"\nThis error occurs when an attempt is made to assign to a borrowed value.\n\nExample of erroneous code:\n\n```compile_fail,E0506\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n    let fancy_ref = &fancy_num;\n    fancy_num = FancyNum { num: 6 };\n    // error: cannot assign to `fancy_num` because it is borrowed\n\n    println!(\"Num: {}, Ref: {}\", fancy_num.num, fancy_ref.num);\n}\n```\n\nBecause `fancy_ref` still holds a reference to `fancy_num`, `fancy_num` can't\nbe assigned to a new value as it would invalidate the reference.\n\nAlternatively, we can move out of `fancy_num` into a second `fancy_num`:\n\n```\nstruct FancyNum {\n    num: u8,\n, fancy_num.num, moved_num.num);\n}\n```\n\nIf the value has to be borrowed, try limiting the lifetime of the borrow using\na scoped block:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n\n    {\n        let fancy_ref = &fancy_num;\n        println!(\"Ref: {}\", fancy_ref.num);\n    }\n\n    // Works because `fancy_ref` is no longer in scope\n    fancy_num = FancyNum { num: 6 };\n    println!(\"Num: {}\", fancy_num.num);\n}\n```\n\nOr by moving the reference into a function:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n\n    print_fancy_ref(&fancy_num);\n\n    // Works because function borrow has ended\n    fancy_num = FancyNum { num: 6 };\n    println!(\"Num: {}\", fancy_num.num);\n}\n\nfn print_fancy_ref(fancy_ref: &FancyNum){\n    println!(\"Ref: {}\", fancy_ref.num);\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issue-45697.rs","byte_start":931,"byte_end":937,"line_start":29,"line_end":29,"column_start":35,"column_end":41,"is_primary":false,"text":[{"text":"        let z = copy_borrowed_ptr(&mut y);","highlight_start":35,"highlight_end":41}],"label":"borrow of `*y.pointer` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-45697.rs","byte_start":948,"byte_end":963,"line_start":30,"line_end":30,"column_start":9,"column_end":24,"is_primary":true,"text":[{"text":"        *y.pointer += 1;","highlight_start":9,"highlight_end":24}],"label":"assignment to borrowed `*y.pointer` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-45697.rs","byte_start":1234,"byte_end":1249,"line_start":34,"line_end":34,"column_start":9,"column_end":24,"is_primary":false,"text":[{"text":"        *z.pointer += 1;","highlight_start":9,"highlight_end":24}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)\n  --> /checkout/src/test/ui/issue-45697.rs:30:9\n   |\nLL |         let z = copy_borrowed_ptr(&mut y);\n   |                                   ------ borrow of `*y.pointer` occurs here\nLL |         *y.pointer += 1;\n   |         ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here\n...\nLL |         *z.pointer += 1;\n   |         --------------- borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:43:19] {"message":"Some errors occurred: E0503, E0506.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0503, E0506.\n"}
[00:43:19] {"message":"For more information about an error, try `rustc --explain E0503`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0503`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/issue-45697.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/issue-46471-1.rs stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 21    | |     -
[00:43:19] 22    | |     |
[00:43:19] 23    | |_____`z` dropped here while still borrowed
[00:43:19] +    |       borrow used here in later iteration of loop
[00:43:19] 25 
[00:43:19] 26 error: aborting due to 2 previous errors
[00:43:19] 27 
[00:43:19] 27 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46471-1/issue-46471-1.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args issue-46471-1.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-46471-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/issue-46471-1/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "emit-end-regions" "-Z" "borrowck=compare" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46471-1/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] 
[00:43:19] ----------------------:null},{"file_name":"/checkout/src/test/ui/issue-46471-1.rs","byte_start":739,"byte_end":740,"line_start":21,"line_end":21,"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}],"children":[],"rendered":"error[E0597]: `z` does not live long enough (Ast)\n  --> /checkout/src/test/ui/issue-46471-1.rs:16:14\n   |\nLL |         &mut z\n   |              ^ borrowed value does not live long enough\nLL |     };\n   |     - `z` dropped here while still borrowed\n...\nLL | }\n   | - borrowed value needs to live until here\n\n"}
[00:43:19] {"message":"`z` does not live long enough (Mir)","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/issue-46471-1.rs","byte_start":583,"byte_end":589,"line_start":16,"line_end":16,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        &mut z","highlight_start":9,"highlight_end":15}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-46471-1.rs","byte_start":594,"byte_end":595,"line_start":17,"line_end":17,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    };","highlight_start":5,"highlight_end":6}],"label":"`z` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-46471-1.rs","byte_start":550,"byte_end":595,"line_start":14,"line_end":17,"column_start":13,"column_end":6,"is_primary":false,"text":[{"text":"    let y = {","highlight_start":13,"highlight_end":14},{"text":"        let mut z = 0;","highlight_start":1,"highlight_end":23},{"text":"        &mut z","highlight_start":1,"highlight_end":15},{"text":"    };","highlight_start":1,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `z` does not live long enough (Mir)\n  --> /checkout/src/test/ui/issue-46471-1.rs:16:9\n   |\nLL |       let y = {\n   |  _____________-\nLL | |         let mut z = 0;\nLL | |         &mut z\n   | |         ^^^^^^ borrowed value does not live long enough\nLL | |     };\n   | |     -\n   | |     |\n   | |_____`z` dropped here while still borrowed\n   |       borrow used here in later iteration of loop\n\n"}
[00:43:19] {derr:
[00:43:19] 
[00:43:19] 8    |           ^ use of borrowed `e`
[00:43:19] 9 ...
[00:43:19] 10 LL |     *g = Xyz::B;
[00:43:19] +    |     ----------- borrow used here in later iteration of loop
[00:43:19] 12 
[00:43:19] 13 error[E0503]: cannot use `e` because it was mutably borrowed
[00:43:19] 14   --> $DIR/borrowed-match-issue-45045.rs:25:9
[00:43:19] 14   --> $DIR/borrowed-match-issue-45045.rs:25:9
[00:43:19] 
[00:43:19] 20    |         ^^^^^^ use of borrowed `e`
[00:43:19] 21 ...
[00:43:19] 22 LL |     *g = Xyz::B;
[00:43:19] +    |     ----------- borrow used here in later iteration of loop
[00:43:19] 24 
[00:43:19] 25 error: aborting due to 2 previous errors
[00:43:19] 26 
[00:43:19] 26 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/borrowed-match-issue-45045/borrowed-match-issue-45045.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/borrowed-match-issue-45045.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/borrowed-match-issue-45045.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/nll/borrowed-match-issue-45045/a" "-Crpath" "-O" "-Zunstable-o   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/nll/borrowed-match-issue-45045.rs","byte_start":598,"byte_end":604,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"    let f = &mut e;","highlight_start":13,"highlight_end":19}],"label":"borrow of `e` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/borrowed-match-issue-45045.rs","byte_start":702,"byte_end":708,"line_start":25,"line_end":25,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"        Xyz::A => println!(\"a\"),","highlight_start":9,"highlight_end":15}],"label":"use of borrowed `e`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/borrowed-match-issue-45045.rs","byte_start":839,"byte_end":850,"line_start":29,"line_end":29,"column_start":5,"column_end":16,"is_primary":false,"text":[{"text":"    *g = Xyz::B;","highlight_start":5,"highlight_end":16}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggeactual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/borrowed-local-error/borrowed-local-error.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/borrowed-local-error.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/borrowed-local-error.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/nll/borrowed-local-error/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/nll/borrowed-local-error/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"`v` 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\nrop(x);
[00:43:19] +    |          - borrow used here in later iteration of loop
[00:43:19] 12 
[00:43:19] 13 error: aborting due to previous error
[00:43:19] 14 
[00:43:19] 14 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/borrowed-referent-issue-38899/borrowed-referent-issue-38899.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/borrowed-referent-issue-38899.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/borrowed-referent-issue-38899.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/nll/borrowed-referent-issue-38899/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/nll/borrowed-referent-issue-38899/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"cannot borrow `*block.current` as immutable because it is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/borrowed-referent-issue-38899.rs","byte_start":729,"byte_end":744,"line_start":24,"line_end":24,"column_start":21,"column_end":36,"is_primary":true,"text":[{"text":"    let p: &'a u8 = &*block.current;","highlight_start":21,"highlight_end":36}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/borrowed-referent-issue-38899.rs","byte_start":666,"byte_end":676,"line_start":22,"line_end":22,"column_start":13,"column_end":23,"is_primary":false,"text":[{"text":"    let x = &mut block;","highlight_start":13,"highlight_end":23}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkoutorrowed-temporary-error.rs stdout ----
[00:43:19] 
[00:43:19] 
[00:43:19] 7 LL |     });
[00:43:19] 8    |       - temporary value only lives until here
[00:43:19] 9 LL |     println!("{:?}", x);
[00:43:19] +    |                      - borrow used here in later iteration of loop
[00:43:19] 11 
[00:43:19] 12 error: aborting due to previous error
[00:43:19] 13 
[00:43:19] 13 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/borrowed-temporary-error/borrowed-temporary-error.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/borrowed-temporary-error.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/borrowed-temporary-error.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/nll/borrowed-temporary-error/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/nll/borrowed-temporary-error/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] 
[00:43:19] --------------------e_start":38,"line_end":38,"column_start":11,"column_end":12,"is_primary":false,"text":[{"text":"    deref(p);","highlight_start":11,"highlight_end":12}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `y` does not live long enough\n  --> /checkout/src/test/ui/nll/capture-ref-in-struct.rs:31:16\n   |\nLL |             y: &y,\n   |                ^^ borrowed value does not live long enough\n...\nLL |     }\n   |     - `y` dropped here while still borrowed\nLL | \nLL |     deref(p);\n   |           - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:43:19] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/nll/capture-ref-in-struct.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/nll/closure-access-spans.rs stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 8    |     |
[00:43:19] 9    |     immutable borrow occurs here
[00:43:19] 10 LL |     r.use_mut();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 12 
[00:43:19] 12 
[00:43:19] 13 error[E0499]: cannot borrow `x` as mutable more than once at a time
[00:43:19] 
[00:43:19] 20    |     |
[00:43:19] 21    |     second mutable borrow occurs here
[00:43:19] 21    |     second mutable borrow occurs here
[00:43:19] 22 LL |     r.use_mut();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 24 
[00:43:19] 24 
[00:43:19] 25 error[E0500]: closure requires unique access to `x` but it is already borrowed
[00:43:19] 
[00:43:19] 32    |     |
[00:43:19] 33    |     closure construction occurs here
[00:43:19] 33    |     closure construction occurs here
[00:43:19] 34 LL |     r.use_mut();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 36 
[00:43:19] 36 
[00:43:19] 37 error[E0503]: cannot use `x` because it was mutably borrowed
[00:43:19] 
[00:43:19] 
[00:43:19] 42 LL |     move || x; //~ ERROR
[00:43:19] 43    |             ^ use of borrowed `x`
[00:43:19] 44 LL |     r.use_ref();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 46 
[00:43:19] 47 error[E0505]: cannot move out of `x` because it is borrowed
[00:43:19] 48   --> $DIR/closure-access-spans.rs:41:5
[00:43:19] 48   --> $DIR/closure-access-spans.rs:41:5
[00:43:19] 
[00:43:19] 54    |     |
[00:43:19] 55    |     move out of `x` occurs here
[00:43:19] 56 LL |     r.use_ref();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 58 
[00:43:19] 58 
[00:43:19] 59 error[E0382]: borrow of moved value: `x`
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-access-spans/closure-access-spans.stderr
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-access-spans/closure-access-spans.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/closure-access-spans.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/closure-access-spans.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/nll/closure-access-spans/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/nll/closure-access-spans/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] ------------------------------------------
[00:43:19] stderr:
[00:43:19] stderr:
[00:43:19] ------------------------------------------
[00:43:19] {"message":"cannot borrow `x` as immutable because it is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_faioccurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":644,"byte_end":645,"line_start":18,"line_end":18,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    r.use_mut();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/nll/closure-access-spans.rs:17:5\n   |\nLL |     let r = &mut x;\n   |             ------ mutable borrow occurs here\nLL |     || x; //~ ERROR\n   |     ^^ - second borrow occurs due to use of `x` in closure\n   |     |\n   |     immutable borrow occurs here\nLL |     r.use_mut();\n   |     - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":718,"byte_end":724,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"    let r = &mut x;","highlight_start":13,"highlight_end":19}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":730,"byte_end":732,"line_start":23,"line_end":23,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || x = 2; //~ ERROR","highlight_start":5,"highlight_end":7}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":733,"byte_end":734,"line_start":23,"line_end":23,"column_start":8,"column_end":9,"is_primary":false,"text":[{"text":"    || x = 2; //~ ERROR","highlight_start":8,"highlight_end":9}],"label":"second borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":754,"byte_end":755,"line_start":24,"line_end":24,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    r.use_mut();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time\n  --> /checkout/src/test/ui/nll/closure-access-spans.rs:23:5\n   |\nLL |     let r = &mut x;\n   |             ------ first mutable borrow occurs here\nLL |     || x = 2; //~ ERROR\n   |     ^^ - second borrow occurs due to use of `x` in closure\n   |     |\n   |     second mutable borrow occurs here\nLL |     r.use_mut();\n   |     - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"closure requires unique access to `x` but it is already borrowed","code":{"code":"E0500","explanation":"\nA borrowed variable was used in another closure. Example of erroneous code:\n\n```compile_fail\nfn you_know_nothing(jon_snow: &mut i32) {\n    let nights_watch = || {\n        *jon_snow = 2;\n    };\n    let starks = || {\n        *jon_snow = 3; // error: closure requires unique access to `jon_snow`\n                       //        but it is already borrowed\n    };\n}\n```\n\nIn here, `jon_snow` is already borrowed by the `nights_watch` closure, so it\ncannot be borrowed by the `starks` closure at the same time. To fix this issue,\nyou can put the closure in its own scope:\n\n```\nfn you_know_nothing(jon_snow: &mut i32) {\n    {\n        let nights_watch = || {\n            *jon_snow = 2;\n        };\n    } // At this point, `jon_snow` is free.\n    let starks = || {\n        *jon_snow = 3;\n    };\n}\n```\n\nOr, if the type implements the `Clone` trait, you can clone it between\nclosures:\n\n```\nfn you_know_nothing(jon_snow: &mut i32) {\n    let mut jon_copy = jon_snow.clone();\n    let nights_watch = || {\n        jon_copy = 2;\n    };\n  / it will be copied here.\n    }\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1063,"byte_end":1065,"line_start":40,"line_end":40,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let r = &x;","highlight_start":13,"highlight_end":15}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1071,"byte_end":1073,"line_start":41,"line_end":41,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || x; //~ ERROR","highlight_start":5,"highlight_end":7}],"label":"move out of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1074,"byte_end":1075,"line_start":41,"line_end":41,"column_start":8,"column_end":9,"is_primary":false,"text":[{"text":"    || x; //~ ERROR","highlight_start":8,"highlight_end":9}],"label":"move occurs due to use in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1091,"byte_end":1092,"line_start":42,"line_end":42,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    r.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_is_primary":true,"text":[{"text":"    || x.len(); //~ ERROR","highlight_start":5,"highlight_end":7}],"label":"value borrowed here after move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: borrow of moved value: `x`\n  --> /checkout/src/test/ui/nll/closure-access-spans.rs:47:5\n   |\nLL |     let r = x;\n   |             - value moved here\nLL |     || x.len(); //~ ERROR\n   |     ^^ - borrow occurs due to use in closure\n   |     |\n   |     value borrowed here after move\n   |\n   = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait\n\n"}
[00:43:19] {"message":"borrow of moved value: `x`","code":{"code":"E0382","explanation":"\nThis error occurs when an attempt is made to use a variable after its contents\nhave been moved elsewhere. For example:\n\n```compile_fail,E0382\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = MyStruct{ s: 5u32 };\n    let y = x;\n    x.s = 6;\n    println!(\"{}\", x.s);\n}\n```\n\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\nof `x` when we set `y`. This is fundamental to Rust's ownership system: outside\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\n\nSometimes we don't need to move the value. Using a reference, we can let another\nfunction borrow the value without changing its ownership. In the example below,\nwe don't acout `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n    let mut p1 = Point{ x: -1, y: 2 };\n    let p2 = p1;\n    p1.x = 1;\n    println!(\"p1: {}, {}\", p1.x, p1.y);\n    println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don't control the struct's definition, or mutable shared\nownership is truly required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the chapter in the\nBook:\n\nhttps://doc.rust-lang.org/book/first-edition/ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1255,"byte_end":1256,"line_start":51,"line_end":51,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"    let r = x;","highlight_start":13,"highlight_end":14}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1265,"byte_end":1266,"line_start":52,"line_end":52,"column_start":8,"column_end":9,"is_primary":false,"text":[{"text":"    lone()` to\nclone them, because they are marked `Copy` in addition to `Clone`.  Implicit\ncloning is more convenient in this case. We can mark our own types `Copy` if\nall their members also are marked `Copy`.\n\nIn the example below, we implement a `Point` type. Because it only stores two\nintegers, we opt-out of ownership semantics with `Copy`. Then we can\n`let p2 = p1` without `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n    let mut p1 = Point{ x: -1, y: 2 };\n    let p2 = p1;\n    p1.x = 1;\n    println!(\"p1: {}, {}\", p1.x, p1.y);\n    println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don't control the struct's definition, or mutable shared\nownership is truly required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the chapter in the\nBook:\n\nhttps://doc.rust-lang.org/book/first-edition/ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1359,"byte_end":1360,"line_start":56,"line_end":56,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"    let r = x;","highlight_start":13,"highlight_end":14}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1370,"byte_end":1371,"line_start":57,"line_end":57,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"    || *x = String::new(); //~ ERROR","highlight_start":9,"highlight_end":10}],"label":"borrow occurs due to use in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":1366,"byte_end":1368,"line_start":57,"line_end":57,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || *x = String::new(); //~ ERROR","highlight_start":5,"highlight_end":7}],"label":"value borrowed here after move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `&mut std::string::String`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: borrow of moved value: `x`\n  --> /checkout/src/test/ui/nll/closure-access-spans.rs:57:5\n   |\nLL |     let r = x;\n   |             - value moved here\nLL |     || *x = String::new(); //~ ERROR\n   |     ^^  - borrow occurs due to use in closure\n   |     |\n   |     value borrowed here after move\n   |\n   = note: move occurs because `x` has type `&mut std::string::String`, which does not implement the `Copy` trait\n\n"}
[00:43:19] {"message":"u\n    let mut s1 = String::from(\"many\");\n    let s2 = s1.clone();\n    s1.remove(0);\n    println!(\"{} {}\", s1, s2);\n}\n```\n\nIf we control the definition of a type, we can implement `Clone` on it ourselves\nwith `#[derive(Clone)]`.\n\nSome types have no ownership semantics at all and are trivial to duplicate. An\nexample is `i32` and the other number types. We don't have to call `.clone()` to\nclone them, because they are marked `Copy` in addition to `Clone`.  Implicit\ncloning is more convenient in this case. We can mark our own types `Copy` if\nall their members also are marked `Copy`.\n\nIn the example below, we implement a `Point` type. Because it only stores two\nintegers, we opt-out of ownership semantics with `Copy`. Then we can\n`let p2 = p1` without `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n    let mut p1 = Point{ x: -1, y: 2 };\n    let p2 = p1;\n    p1.x = 1;\n    println!(\"p1: {}, {}\", p1.x, p1.y);\n    println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don't control the struct's definition, or mutable shared\nownership is truly required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access orrowed
[00:43:19] 110   --> $DIR/closure-borrow-spans.rs:77:13
[00:43:19] 
[00:43:19] 116 LL |     let y = x; //~ ERROR
[00:43:19] 117    |             ^ move out of `x` occurs here
[00:43:19] 118 LL |     f.use_ref();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 120 
[00:43:19] 120 
[00:43:19] 121 error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access
[00:43:19] 122   --> $DIR/closure-borrow-spans.rs:83:13
[00:43:19] 
[00:43:19] 128 LL |     let y = &x; //~ ERROR
[00:43:19] 129    |             ^^ borrow occurs here
[00:43:19] 130 LL |     f.use_ref();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 132 
[00:43:19] 132 
[00:43:19] 133 error[E0501]: cannot borrow `x` as mutable because previous closure requires unique access
[00:43:19] 134   --> $DIR/closure-borrow-spans.rs:89:13
[00:43:19] 
[00:43:19] 140 LL |     let y = &mut x; //~ ERROR
[00:43:19] 141    |             ^^^^^^ borrow occurs here
[00:43:19] 142 LL |     f.use_ref();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] 144 
[00:43:19] 144 
[00:43:19] 145 error[E0597]: `x` does not live long enough
[00:43:19] 146   --> $DIR/closure-borrow-spans.rs:98:17
[00:43:19] 
[00:43:19] 152 LL |     }
[00:43:19] 153    |     - `x` dropped here while still borrowed
[00:43:19] 154 LL |     f.use_ref();
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:43:19] +    |     - borrow used here in later iteration of loop
[00:/src/test/ui/nll/closure-borrow-spans.rs","byte_start":610,"byte_end":612,"line_start":16,"line_end":16,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let f = || x.len();","highlight_start":13,"highlight_end":15}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":634,"byte_end":635,"line_start":17,"line_end":17,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    let y = x; //~ ERROR","highlight_start":13,"highlight_end":14}],"label":"move out of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":613,"byte_end":614,"line_start":16,"line_end":16,"column_start":16,"column_end":17,"is_primary":false,"text":[{"text":"    let f = || x.len();","highlight_start":16,"highlight_end":17}],"label":"borrow occurs due to use in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":651,"byte_end":652,"line_start":18,"line_end":18,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0505]: cannot move out of `x` because it is borrowed\n  --> /checkout/src/test/ui/nll/closure-borrow-spans.rs:17:13\n   |\nLL |     let f = || x.len();\n   |             -- - borrow occurs due to use in closure\n   |             |\n   |             borrow of `x` occurs here\nLL |     let y = x; //~ ERROR\n   |             ^ move out of `x` occurs here\nLL |     f.use_ref();\n   |     - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `x` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":740,"byte_end":746,"line_start":23,"line_end":23,"column_start":13,"column_end":19,"is_primary":true,"text":[{"text":"    let y = &mut x; //~ ERROR","highlight_start":13,"highlight_end":19}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":722,"byte_end":724,"line_start":22,"line_end":22,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let f = || x;","highlight_start":13,"highlight_end":15}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":725,"byte_end":726,"line_start":22,"line_end":22,"column_start":16,"column_end":17,"is_primary":false,"text":[{"text":"    let f = || x;","highlight_start":16,"highlight_end":17}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":762,"byte_end":763,"line_start":24,"line_end":24,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/nll/closure-borrow-spans.rs:23:13\n   |\nLL |     let f = || x;\n   |             -- - first borrow occurs due to use of `x` in closure\n   |             |\n   |             immutable borrow occurs here\nLL |     let y = &mut x; //~ ERROR\n   |             ^^^^^^ mutable borrow occurs here\nLL |     f.use_ref();\n   |     - borrow used here in later iteration \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/nll/closure-borrow-spans.rs","byte_start":1046,"byte_end":1048,"line_start":43,"line_end":43,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let f = || x = 0;","highlight_start":13,"highlight_end":15}],"label":"borrow of `x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1068,"byte_end":1069,"line_start":44,"line_end":44,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    let y = x; //~ ERROR","highlight_start":13,"highlight_end":14}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1049,"byte_end":1050,"line_start":43,"line_end":43,"column_start":16,"column_end":17,"is_primary":false,"text":[{"text":"    let f = || x = 0;","highlight_start":16,"highlight_end":17}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1085,"byte_end":1086,"line_start":45,"line_end":45,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"s y = &x; //~ ERROR","highlight_start":13,"highlight_end":15}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1156,"byte_end":1158,"line_start":49,"line_end":49,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let f = || x = 0;","highlight_start":13,"highlight_end":15}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1159,"byte_end":1160,"line_start":49,"line_end":49,"column_start":16,"column_end":17,"is_primary":false,"text":[{"text":"    let f = || x = 0;","highlight_start":16,"highlight_end":17}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1196,"byte_end":1197,"line_start":51,"line_end":51,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/nll/closure-borrow-spans.rs:50:13\n   |\nLL |     let f = || x = 0;\n   |             -- - first borrow occurs due to use of `x` in closure\n   |             |\n  597\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/nll/closure-borrow-spans.rs","byte_start":1417,"byte_end":1418,"line_start":64,"line_end":64,"column_start":16,"column_end":17,"is_primary":true,"text":[{"text":"        f = || x = 0; //~ ERROR","highlight_start":16,"highlight_end":17}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1438,"byte_end":1439,"line_start":65,"line_end":65,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1444,"byte_end":1445,"line_start":66,"line_end":66,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1414,"byte_end":1416,"line_start":64,"line_end":64,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"        f = || x = 0; //~ ERROR","highlight_start":13,"highlight_end":15}],"label":"value captured here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/closure-borrow-spans.rs:64:16\n   |\nLL |         f = || x = 0; //~ ERROR\n   |             -- ^ borrowed value does not live long enough\n   |             |\n   |             value captured here\nLL |     }\n   |     - `x` dropped here while still borrowed\nLL |     f.use_ref();\n   |     - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot assign to `x` because it is borrowed","code":{"code":"E0506","explanation":"\nThis error occurs when an attempt is made to assign to a borrowed value.\n\nExample of erroneous code:\n\n```compile_fail,E0506\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n    let fancy_ref = &fancy_num;\n    fancy_num = FancyNum { num: 6 };\n    // error: cannot assign to `fancy_num` because it is borrowed\n\n    println!(\"Num: {}, Ref: {}\", fancy_num.num, fancy_ref.num);\n}\n```\n\nBecause `fancy_ref` still holds a reference to `fancy_num`, `fancy_num` can't\nbe assigned to a new value as it would invalidate the reference.\n\nAlternatively, we can move out of `fancy_num` intoclosure(s)\n    };\n    outside_closure(a);\n    bar(a);\n}\n```\n\nIt may be possible to define the closure later:\n\n```\nfn inside_closure(x: &mut i32) {}\nfn outside_closure(x: &mut i32) {}\n\nfn foo(a: &mut i32) {\n    outside_closure(a);\n    let bar = || {\n        inside_closure(a)\n    };\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1761,"byte_end":1763,"line_start":83,"line_end":83,"column_start":13,"column_end":15,"is_primary":true,"text":[{"text":"    let y = &x; //~ ERROR","highlight_start":13,"highlight_end":15}],"label":"borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1738,"byte_end":1740,"line_start":82,"line_end":82,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let f = || *x = 0;","highlight_start":13,"highlight_end":15}],"label":"closure construction occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1742,"byte_end":1743,"line_start":82,"line_end":82,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"    let f = || *x = 0;","highlight_start":17,"highlight_end":18}],"label":"first borrow occurs due to use of `x` in closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":1779,"byte_end":1780,"line_start":84,"line_end":84,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access\n  --> /checkout/src/test/ui/nll/closure-borrow-spans.rs:83:13\n   |\nLL |     let f = || *x = 0;\n   |             --  - first borrow occurs due to use of `x` in closure\n   |             |\n   |             closure construction occurs here\nLL |     let y = &x; //~ ERROR\n   |             ^^ borrow occurs here\nLL |     f.use_ref();\n   |     - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot borrow `x` as mutable because previous closure requires unique access","code":{"code":"E0501","explanation":"\nThis error indicates that a mutable variable is being used while it is still\ncaptured by a closure. Because the closure has borrowed the variable, it is not\navailable for use until the closure goes out of scope.\n\nNote that a capture will either move or borrow a variable, but in this\nsituation, the closure is borrowing the variable. Take a look at\nhttp://rustbyexample.com/fn/closures/capture.html for more information about\ncapturing.\n\nExample of erroneous code:\n\n```compile_fail,E0501\nfn inside_closure(x: &mut i32) {\n    // Actions which require unique access\n}\n\nfn outside_closure(x: &mut i32) {\n    // Actions which require unique access\n}\n\nfn foo(a: &mut i32) {\n    let bar = || {\n        inside_closure(a)\n    };\n    outsideple 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/nll/closure-borrow-spans.rs","byte_start":2033,"byte_end":2034,"line_start":98,"line_end":98,"column_start":17,"column_end":18,"is_primary":true,"text":[{"text":"        f = || *x = 0; //~ ERROR","highlight_start":17,"highlight_end":18}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":2054,"byte_end":2055,"line_start":99,"line_end":99,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    }","highlight_start":5,"highlight_end":6}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":2060,"byte_end":2061,"line_start":100,"line_end":100,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    f.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow used here in later iteration of loop","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":2029,"byte_end":2031,"line_start":98,"line_end":98,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"        f = || *x = 0; //~ ERROR","highlight_start":13,"highlight_end":15}],"label":"value captured here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/closure-borrow-spans.rs:98:17\n   |\nLL |         f = || *x = 0; //~ ERROR\n   |             --  ^ borrowed value does not live long enough\n   |             |\n   |             value captured here\nLL |     }\n   |     - `x` dropped here while still borrowed\nLL |     f.use_ref();\n   |     - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"cannot assign to `*x` because it is borrowed","code":{"code":"E0506","explanation":"\nThis error occurs when an attempt is made to assign to a borrowed value.\n\nExample of erroneous code:\n\n```compile_fail,E0506\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n    let fancy_ref = &fancy_num;\n    fancy_num = FancyNum { num: 6 };\n    // error: cannot assign to `fancy_num` because it is borrowed\n\n    println!(\"Num: {}, Ref: {}\", fancy_num.num, fancy_ref.num);\n}\n```\n\nBecause `fancy_ref` still holds a reference to `fancy_num`, `fancy_num` can't\nbe assigned to a new value as it would invalidate the reference.\n\nAlternatively, we can move out of `fancy_num` into a second `fancy_num`:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n    let moved_num = fancy_num;\n    fancy_num = FancyNum { num: 6 };\n\n    println!(\"Num: {}, Moved num: {}\", fancy_num.num, moved_num.num);\n}\n```\n\nIf the value has to be borrowed, try limiting the lifetime of the borrow using\na scoped block:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n\n    {\n        let fancy_ref = &fancy_num;\n        println!(\"Ref: {}\", fancy_ref.num);\n    }\n\n    // Works because `fancy_ref` is no longer in scope\n    fancy_num = FancyNum { num: 6 };\n    println!(\"Num: {}\", fancy_num.num);\n}\n```\n\nOr by moving the reference into a function:\n\n```\nstruct FancyNum {\n    num: u8,\n}\n\nfn main() {\n    let mut fancy_num = FancyNum { num: 5 };\n\n    print_fancy_ref(&fancy_num);\n\n    // Works because function borrow has ended\n    fancy_num = FancyNum { num: 6 };\n    println!(\"Num: {}\", fancy_num.num);\n}\n\nfn print_fancy_ref(fancy_ref: &FancyNum){\n    println!(\"Ref: {}\", fancy_ref.num);\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-borrow-spans.rs","byte_start":2135,"byte_end":2137,"line_start":104,"line_end":104,"column_start":13,"column_end":15,"is_primary":false,"text":[{"text":"    let f = || *x = 0;","highlight_start":13,"highlight_end":15}],"label":"borrow of `*x` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/clort":1,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/1:9 ~ escape_upvar_nested[317d]::test[0]::{{closure}}[0]) with closure substs [\n    i16,\n    extern \"rust-call\" fn(()),\n    &'_#1r mut &'_#2r i32,\n    &'_#3r i32\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"number of external vids: 4","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"where '_#3r: '_#2r","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: External requirements\n  --> /checkout/src/test/ui/nll/closure-requirements/escape-upvar-nested.rs:30:27\n   |\nLL |           let mut closure = || {\n   |  ___________________________^\nLL | |             let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]\nLL | |             closure1();\nLL | |         };\n   | |_________^\n   |\n   = note: defining type: DefId(0/1:9 ~ escape_upvar_nested[317d]::test[0]::{{closure}}[0]) with closure substs [\n               i16,\n               extern \"rust-call\" fn(()),\n               &'_#1r mut &'_#2r i32,\n               &'_#3r i32\n           ]\n   = note: number of external vids: 4\n   = note: where '_#3r: '_#2r\n\n"}
[00:43:19] {"message":"No external requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/escape-upvar-nested.rs","byte_start":758,"byte_end":1032,"line_start":23,"line_end":39,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn test() {","highl to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:43:19] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/nll/closure-requirements/escape-upvar-nested.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/nll/closure-requirements/escape-argument.rs stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 33    |     - `y` dropped here while still borrowed
[00:43:19] 34 LL | 
[00:43:19] 35 LL |     deref(p);
[00:43:19] +    |           - borrow used here in later iteration of loop
[00:43:19] 37 
[00:43:19] 38 error: aborting due to previous error
[00:43:19] 39 
[00:43:19] 39 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-requirements/escape-argument/escape-argument.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/closure-requirements/escape-argument.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnun]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: No external requirements\n  --> /checkout/src/test/ui/nll/closure-requirements/escape-argument.rs:36:38\n   |\nLL |         let mut closure = expect_sig(|p, y| *p = y);\n   |                                      ^^^^^^^^^^^^^\n   |\n   = note: defining type: DefId(0/1:9 ~ escape_argument[317d]::test[0]::{{closure}}[0]) with closure substs [\n               i16,\n               for<'r, 's> extern \"rust-call\" fn((&ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) mut &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 's)) i32, &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 's)) i32))\n           ]\n\n"}
[00:43:19] {"message":"No external requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/escape-argument.rs","byte_start":1036,"byte_end":1272,"line_start":30,"line_end":42,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn test() {","highlight_start":1,"highlight_end":12},{"text":"    let x = 44;","highlight_start":1,"highlight_end":16},{"text":"    let mut p = &x;","highlight_start":1,"highlight_end":20},{"text":"","highlight_start":1,"highlight_end":1},{"text":"    {","highlight_start":1,"highlight_end":6},{"text":"        let y = 22;","highlight_start":1,"highlight_end":20},{"text":"        let mut closure = expect_sig(|p, y| *p = y);","highlight_start":1,"highlight_end":53},{"text":"        closure(&mut p, &y);","highlight_start":1,"highlight_end":29},{"text":"        //~^ ERROR `y` does not live long enough [E0597]",nLL | \nLL |     deref(p);\n   |           - borrow used here in later iteration of loop\n\n"}
[00:43:19] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:43:19] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[00:43:19] ------------------------------------------
[00:43:19] 
[00:43:19] thread '[ui] ui/nll/closure-requirements/escape-argument.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:43:19] 
[00:43:19] 
[00:43:19] ---- [ui] ui/nll/closure-requirements/escape-upvar-ref.rs stdout ----
[00:43:19] diff of stderr:
[00:43:19] 
[00:43:19] 39    |     - `y` dropped here while still borrowed
[00:43:19] 40 LL | 
[00:43:19] 41 LL |     deref(p);
[00:43:19] +    |           - borrow used here in later iteration of loop
[00:43:19] 43 
[00:43:19] 44 error: aborting due to previous error
[00:43:19] 45 
[00:43:19] 45 
[00:43:19] 
[00:43:19] 
[00:43:19] The actual stderr differed from the expected stderr.
[00:43:19] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-requirements/escape-upvar-ref/escape-upvar-ref.stderr
[00:43:19] To update references, rerun the tests and pass the `--bless` flag
[00:43:19] To only update this specific test, also pass `--test-args nll/closure-requirements/escape-upvar-ref.rs`
[00:43:19] error: 1 errors occurred comparing output.
[00:43:19] status: exit code: 1
[00:43:19] status: exit code: 1
[00:43:19] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/closure-requirements/escape-upvar-ref.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/nll/closure-requirements/escape-upvar-ref/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=mir" "-Zverbose" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-requirements/escape-upvar-ref/auxiliary" "-A" "unused"
[00:43:19] ------------------------------------------
[00:43:19] 
---
34496 ./obj/build/x86_64-unknown-linux947578231,finish=1533332020954690947,duration=7112716
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0d8c73b4
$ 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 -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:2416bff8
travis_time:start:2416bff8
$ 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:17840754
$ 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)

@pnkfelix
Copy link
Member

pnkfelix commented Aug 3, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Aug 3, 2018

📌 Commit 12af36a has been approved by pnkfelix

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 3, 2018
cramertj added a commit to cramertj/rust that referenced this pull request Aug 3, 2018
…elix

[NLL] Use smaller spans for errors involving closure captures

Closes rust-lang#51170
Closes rust-lang#46599

Error messages involving closures now point to the captured variable/closure args.

r? @pnkfelix
@bors
Copy link
Contributor

bors commented Aug 4, 2018

⌛ Testing commit 12af36a with merge 43488c857944f55f589092e0a312cc00adf5f72a...

@kennytm
Copy link
Member

kennytm commented Aug 4, 2018

@bors treeclosed=12

Travis CI is currently not booting any Linux jobs. Waiting for update from https://www.traviscistatus.com/.

@bors
Copy link
Contributor

bors commented Aug 4, 2018

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 4, 2018
@kennytm
Copy link
Member

kennytm commented Aug 4, 2018

@bors retry

@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 Aug 4, 2018
@nikomatsakis
Copy link
Contributor

@bors p=1 -- NLL-related

@bors
Copy link
Contributor

bors commented Aug 5, 2018

⌛ Testing commit 12af36a with merge c78366a32455960ab4743db636978cc092fae0c5...

@bors
Copy link
Contributor

bors commented Aug 5, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 5, 2018
@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
[00:48:30] -- Looking for sys/types.h
[00:48:40] -- Looking for sys/types.h - found
[00:48:40] -- Looking for termios.h

Broadcast message from root@travis-job-efe1035a-c29b-45db-83c6-c9983df10d07
 (unknown) at 7:05 ...
The system is going down for power off NOW!
[00:48:47] 
[00:48:47] Session terminated, terminating shell... ...terminated.

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

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

@kennytm
Copy link
Member

kennytm commented Aug 5, 2018

@bors retry travis-ci/travis-ci#4924

@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 Aug 5, 2018
@bors
Copy link
Contributor

bors commented Aug 5, 2018

⌛ Testing commit 12af36a with merge 9f9ac89...

bors added a commit that referenced this pull request Aug 5, 2018
[NLL] Use smaller spans for errors involving closure captures

Closes #51170
Closes #46599

Error messages involving closures now point to the captured variable/closure args.

r? @pnkfelix
@bors
Copy link
Contributor

bors commented Aug 5, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: pnkfelix
Pushing 9f9ac89 to master...

@bors bors merged commit 12af36a into rust-lang:master Aug 5, 2018
@matthewjasper matthewjasper deleted the closure-spans branch September 3, 2018 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants