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

Issue 48697 -- ICE in old borrowck mode #49666

Closed

Conversation

nikomatsakis
Copy link
Contributor

NLL can mask regionck failures, leading borrowck to get itself into surprising situations. Rather than ICE, just ignore that.

Fixes #48697

r? @pnkfelix

@TimNN
Copy link
Contributor

TimNN commented Apr 4, 2018

Your PR failed on Travis. 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.
Resolving deltas: 100% (607738/607738), completed with 4798 local objects.
---
[00:02:13] configure: rust.quiet-tests     := True
---
[00:41:27] ...........................F.....FF..F....................................i.........................
[00:41:34] .................i..................................................................................
[00:41:38] ....................................................................................................
[00:41:42] ....................................................................................................
[00:41:46] ....................................................................................................
[00:41:51] .....................................................................F.........F....................
[00:41:57] ....................................................................................................
[00:42:04] ........................................FF...FFF....................................................
[00:42:11] ...........F................................................................................i.......
[00:42:19] F................................F......F........................i..................................
---
[00:42:43] - error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] + error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] 2   --> $DIR/borrowck-closures-two-mut.rs:24:24
[00:42:43] 3    |
[00:42:43] 4 LL |     let c1 = to_fn_mut(|| x = 4);
[00:42:43]
[00:42:43] 14    | - first borrow ends here
[00:42:43] 15
[00:42:43] 16 error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:35:24
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:24:24
[00:42:43] 18    |
[00:42:43] - LL |     let c1 = to_fn_mut(|| set(&mut x));
[00:42:43] -    |                        --          - previous borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c1 = to_fn_mut(|| x = 4);
[00:42:43] +    |                        -- - previous borrow occurs due to use of `x` in closure
[00:42:43] 21    |                        |
[00:42:43] 22    |                        first mutable borrow occurs here
[00:42:43] - LL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43] -    |                        ^^          - borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43] +    |                        ^^ - borrow occurs due to use of `x` in closure
[00:42:43] 25    |                        |
[00:42:43] 26    |                        second mutable borrow occurs here
[00:42:43] 27 LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:42:43]
[00:42:43] 28 LL | }
[00:42:43] 29    | - first borrow ends here
[00:42:43] 30
[00:42:43] - error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:42:24
[00:42:43] + error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:35:24
[00:42:43] 33    |
[00:42:43] - LL |     let c1 = to_fn_mut(|| x = 5);
[00:42:43] -    |                        -- - previous borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c1 = to_fn_mut(|| set(&mut x));
[00:42:43] +    |                        --          - previous borrow occurs due to use of `x` in closure
[00:42:43] 36    |                        |
[00:42:43] 37    |                        first mutable borrow occurs here
[00:42:43] 38 LL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43]
[00:42:43] 44    | - first borrow ends here
[00:42:43] 45
[00:42:43] 46 error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:49:24
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:35:24
[00:42:43] 48    |
[00:42:43] - LL |     let c1 = to_fn_mut(|| x = 5);
[00:42:43] -    |                        -- - previous borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c1 = to_fn_mut(|| set(&mut x));
[00:42:43] +    |                        --          - previous borrow occurs due to use of `x` in closure
[00:42:43] 51    |                        |
[00:42:43] 52    |                        first mutable borrow occurs here
[00:42:43] - LL |     let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
[00:42:43] -    |                        ^^                                  - borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43] +    |                        ^^          - borrow occurs due to use of `x` in closure
[00:42:43] 55    |                        |
[00:42:43] 56    |                        second mutable borrow occurs here
[00:42:43] - ...
[00:42:43] + LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:42:43] 58 LL | }
[00:42:43] 59    | - first borrow ends here
[00:42:43] 60
[00:42:43]
[00:42:43] - error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:61:24
[00:42:43] -    |
[00:42:43] - LL |     let c1 = to_fn_mut(|| set(&mut *x.f));
[00:42:43] -    |                        --           - previous borrow occurs due to use of `x` in closure
[00:42:43] -    |                        |
[00:42:43] -    |                        first mutable borrow occurs here
[00:42:43] - LL |     let c2 = to_fn_mut(|| set(&mut *x.f));
[00:42:43] -    |                        ^^           - borrow occurs due to use of `x` in closure
[00:42:43] -    |                        |
[00:42:43] -    |                        second mutable borrow occurs here
[00:42:43] - ...
[00:42:43] - LL | }
[00:42:43] -    | - first borrow ends here
[00:42:43] -
[00:42:43] 76 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:24:24
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:42:24
[00:42:43] 78    |
[00:42:43] - LL |     let c1 = to_fn_mut(|| x = 4);
[00:42:43] + LL |     let c1 = to_fn_mut(|| x = 5);
[00:42:43] 80    |                        -- - previous borrow occurs due to use of `x` in closure
[00:42:43] 81    |                        |
[00:42:43] 82    |                        first mutable borrow occurs here
[00:42:43]
[00:42:43] - LL |     let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43] -    |                        ^^ - borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43] +    |                        ^^          - borrow occurs due to use of `x` in closure
[00:42:43] 85    |                        |
[00:42:43] 86    |                        second mutable borrow occurs here
[00:42:43] 87 LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:42:43]
[00:42:43] 88 LL | }
[00:42:43] 89    | - first borrow ends here
[00:42:43] 90
[00:42:43] - error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:35:24
[00:42:43] + error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:42:24
[00:42:43] 93    |
[00:42:43] - LL |     let c1 = to_fn_mut(|| set(&mut x));
[00:42:43] -    |                        --          - previous borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c1 = to_fn_mut(|| x = 5);
[00:42:43] +    |                        -- - previous borrow occurs due to use of `x` in closure
[00:42:43] 96    |                        |
[00:42:43] 97    |                        first mutable borrow occurs here
[00:42:43] 98 LL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43]
[00:42:43] 104    | - first borrow ends here
[00:42:43] 105
[00:42:43] 106 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] -   --> $DIR/borrowck-closures-two-mut.rs:42:24
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:49:24
[00:42:43] 108    |
[00:42:43] 109 LL |     let c1 = to_fn_mut(|| x = 5);
[00:42:43] 110    |                        -- - previous borrow occurs due to use of `x` in closure
[00:42:43]
[00:42:43] 111    |                        |
[00:42:43] 112    |                        first mutable borrow occurs here
[00:42:43] - LL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
[00:42:43] -    |                        ^^          - borrow occurs due to use of `x` in closure
[00:42:43] + LL |     let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
[00:42:43] +    |                        ^^                                  - borrow occurs due to use of `x` in closure
[00:42:43] 115    |                        |
[00:42:43] 116    |                        second mutable borrow occurs here
[00:42:43] - LL |     //~| ERROR cannot borrow `x` as mutable more than once
[00:42:43] + ...
[00:42:43] 118 LL | }
[00:42:43] 119    | - first borrow ends here
[00:42:43] 120
[00:42:43]
[00:42:43] - error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] + error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] 122   --> $DIR/borrowck-closures-two-mut.rs:49:24
[00:42:43] 123    |
[00:42:43] 124 LL |     let c1 = to_fn_mut(|| x = 5);
[00:42:43]
[00:42:43] 134    | - first borrow ends here
[00:42:43] 135
[00:42:43] 136 error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
[00:42:43] +   --> $DIR/borrowck-closures-two-mut.rs:61:24
[00:42:43] +    |
[00:42:43] + LL |     let c1 = to_fn_mut(|| set(&mut *x.f));
[00:42:43] +    |                        --           - previous borrow occurs due to use of `x` in closure
[00:42:43] +    |                        |
[00:42:43] +    |                        first mutable borrow occurs here
[00:42:43] + LL |     let c2 = to_fn_mut(|| set(&mut *x.f));
[00:42:43] +    |                        ^^           - borrow occurs due to use of `x` in closure
[00:42:43] +    |                        |
[00:42:43] +    |                        second mutable borrow occurs here
[00:42:43] + ...
[00:42:43] + LL | }
[00:42:43] +    | - first borrow ends here
[00:42:43] +
[00:42:43] + error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
[00:42:43] 137   --> $DIR/borrowck-closures-two-mut.rs:61:24
[00:42:43] 138    |
[00:42:43] 139 LL |     let c1 = to_fn_mut(|| set(&mut *x.f));
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-closures-two-mut.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'borrowck/borrowck-closures-two-mut.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-closures-two-mut.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"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":816,"byte_end":818,"line_start":23,"line_end":23,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 4);","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":850,"byte_end":852,"line_start":24,"line_end":24,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":974,"byte_end":975,"line_start":26,"line_end":26,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":819,"byte_end":820,"line_start":23,"line_end":23,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 4);","highlight_start":27,"highlight_end":28}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":853,"byte_end":854,"line_start":24,"line_end":24,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":27,"highlight_end":28}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":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   |                        -- - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^ - borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL | }\n   | - first borrow ends here\n\n"}
[00:42:43] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":816,"byte_end":818,"line_start":23,"line_end":23,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 4);","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":850,"byte_end":852,"line_start":24,"line_end":24,"column_start":24,"column_end":26,"is_primary":true,"text":[{"text":"    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":24,"highlight_end":26}],"label":"second mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":974,"byte_end":975,"line_start":26,"line_end":26,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":853,"byte_end":854,"line_start":24,"line_end":24,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once","highlight_start":27,"highlight_end":28}],"label":"borrow occurs due to use of `x` in closure","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":819,"byte_end":820,"line_start":23,"line_end":23,"column_start":27,"column_end":28,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| x = 4);","highlight_start":27,"highlight_end":28}],"label":"previous borrow occurs due to use of `x` in closure","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs:24:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 4);\n   |                        -- - previous borrow occurs dckout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1107,"byte_end":1109,"line_start":35,"line_end":35,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1237,"byte_end":1238,"line_start":37,"line_end":37,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1079,"byte_end":1080,"line_start":34,"line_end":34,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1119,"byte_end":1120,"line_start":35,"line_end":35,"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,"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:35: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\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL | }\n   | - first borrow ends here\n\n"}
[00:42:43] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1067,"byte_end":1069,"line_start":34,"line_end":34,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1107,"byte_end":1109,"line_start":35,"line_end":35,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1237,"byte_end":1238,"line_start":37,"line_end":37,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1119,"byte_end":1120,"line_start":35,"line_end":35,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1079,"byte_end":1080,"line_start":34,"line_end":34,"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,"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:35: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\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL | }\n   | - first borrow ends here\n\n"}
[00:42:43] {"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 aheckout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1337,"byte_end":1338,"line_start":42,"line_end":42,"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,"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:42:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 5);\n   |                        -- - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL | }\n   | - first borrow ends here\n\n"}
[00:42:43] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1291,"byte_end":1293,"line_start":41,"line_end":41,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1325,"byte_end":1327,"line_start":42,"line_end":42,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1455,"byte_end":1456,"line_start":44,"line_end":44,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1337,"byte_end":1338,"line_start":42,"line_end":42,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1294,"byte_end":1295,"line_start":41,"line_end":41,"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,"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:42:24\n   |\nLL |     let c1 = to_fn_mut(|| x = 5);\n   |                        -- - previous borrow occurs due to use of `x` in closure\n   |                        |\n   |                        first mutable borrow occurs here\nLL |     let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once\n   |                        ^^          - borrow occurs due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\nLL |     //~| ERROR cannot borrow `x` as mutable more than once\nLL | }\n   | - first borrow ends here\n\n"}
[00:42:43] {"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":1509,"byte_end":1511,"line_start":48,"line_end":48,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1543,"byte_end":1545,"line_start":49,"line_end":49,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1726,"byte_end":1727,"line_start":52,"line_end":52,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1512,"byte_end":1513,"line_start":48,"line_end":48,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1579,"byte_end":1580,"line_start":49,"line_end":49,"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,"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:49: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(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)\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:42:43] {"message":"cannot borrow `x` nd":52,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1579,"byte_end":1580,"line_start":49,"line_end":49,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1512,"byte_end":1513,"line_start":48,"line_end":48,"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,"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:49: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(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)\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:42:43] {"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":1853,"byte_end":1855,"line_start":60,"line_end":60,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut *x.f));","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1896,"byte_end":1898,"line_start":61,"line_end":61,"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,"expansion":null}s due to use of `x` in closure\n   |                        |\n   |                        second mutable borrow occurs here\n...\nLL | }\n   | - first borrow ends here\n\n"}
[00:42:43] {"message":"cannot borrow `x` as mutable more than once at a time (Ast)","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1853,"byte_end":1855,"line_start":60,"line_end":60,"column_start":24,"column_end":26,"is_primary":false,"text":[{"text":"    let c1 = to_fn_mut(|| set(&mut *x.f));","highlight_start":24,"highlight_end":26}],"label":"first mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1896,"byte_end":1898,"line_start":61,"line_end":61,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":2034,"byte_end":2035,"line_start":64,"line_end":64,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1909,"byte_end":1910,"line_start":61,"line_end":61,"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,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-closures-two-mut.rs","byte_start":1866,"byte_end":1867,"line_start":60,"line_end":60,"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 of `x` in closure","suggested_replacement":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:61:24\n   |\nLL |     let c1 = to_fn_mut(|| set(&mut *x.f));\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.f));\n   |   3]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-reinit.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'borrowck/borrowck-reinit.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-reinit.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-reinit.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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-reinit.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"use of moved value: `x` (Mir)","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/borrowck/borrowck-reinit.rs","byte_start":627,"byte_end":628,"line_start":17,"line_end":17,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    drop(x);","highlight_start":10,"highlight_end":11}],"label":"value moved here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-reinit.rs","byte_start":646,"byte_end":647,"line_start":18,"line_end":18,"column_start":16,"column_end":17,"is_primary":true,"text":[{"text":"    let _ = (1,x); //~ ERROR use of moved value: `x` (Ast)","highlight_start":16,"highlight_end":17}],"label":"value used here after move","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x` (Mir)\n  --> /checkout/src/test/ui/borrowck/borrowck-reinit.rs:18:16\n   |\nLL |     drop(x);\n   |          - value moved here\nLL |     let _ = (1,x); //~ ERROR use of moved value: `x` (Ast)\n   |                ^ value used here after move\n   |\n   = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"use of moved value: `x` (Ast)","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/borrowck/borrowck-reinit.rs","byte_start":646,"byte_end":647,"line_start":18,"line_end":18,"column_start":16,"column_end":17,"is_primary":true,"text":[{"text":"    let _ = (1,x); //~ ERROR use of moved value: `x` (Ast)","highlight_start":16,"highlight_end":17}],"label":"value used here after move","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-reinit.rs","byte_start":627,"byte_end":628,"line_start":17,"line_end":17,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    drop(x);","highlight_start":10,"highlight_end":11}],"label":"value moved here","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x` (Ast)\n  --> /checkout/src/test/ui/borrowck/borrowck-reinit.rs:18:16\n   |\nLL |     drop(x);\n   |          - value moved here\nLL |     let _ = (1,x); //~ ERROR use of moved value: `x` (Ast)\n   |                ^ value used here after move\n   |\n   = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:42:43] {"message":"For more information about this error, try `rustc --explain E0382`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0382`.\n"}
---
[00:42:43] - error[E0384]: cannot assign twice to immutable variable `_x` (Ast)
[00:42:43] + error[E0384]: cannot assign to immutable argument `_x` (Mir)
[00:42:43] 2   --> $DIR/immutable-arg.rs:14:5
[00:42:43] 3    |
[00:42:43] 4 LL | fn foo(_x: u32) {
[00:42:43]
[00:42:43] -    |        -- first assignment to `_x`
[00:42:43] +    |        -- argument not declared as `mut`
[00:42:43] 6 LL |     _x = 4;
[00:42:43] -    |     ^^^^^^ cannot assign twice to immutable variable
[00:42:43] +    |     ^^^^^^ cannot assign to immutable argument
[00:42:43] 8
[00:42:43] - error[E0384]: cannot assign to immutable argument `_x` (Mir)
[00:42:43] + error[E0384]: cannot assign twice to immutable variable `_x` (Ast)
[00:42:43] 10   --> $DIR/immutable-arg.rs:14:5
[00:42:43] 11    |
[00:42:43] 12 LL | fn foo(_x: u32) {
[00:42:43]
[00:42:43] -    |        -- argument not declared as `mut`
[00:42:43] +    |        -- first assignment to `_x`
[00:42:43] 14 LL |     _x = 4;
[00:42:43] -    |     ^^^^^^ cannot assign to immutable argument
[00:42:43] +    |     ^^^^^^ cannot assign twice to immutable variable
---
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'borrowck/immutable-arg.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/immutable-arg.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/immutable-arg.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/borrowck/immutable-arg.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"cannot assign to immutable argument `_x` (Mir)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/immutable-arg.rs","byte_start":532,"byte_end":534,"line_start":13,"line_end":13,"column_start":8,"column_end":10,"is_primary":false,"text":[{"text":"fn foo(_x: u32) {","highlight_start":8,"highlight_end":10}],"label":"argument not declared as `mut`","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/immutable-arg.rs","byte_start":547,"byte_end":553,"line_start":14,"line_end":14,"column_start":5,"column_end":11,"is_primary":true,"text":[{"text":"    _x = 4;","highlight_start":5,"highlight_end":11}],"label":"cannot assign to immutable argument","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign to immutable argument `_x` (Mir)\n  --> /checkout/src/test/ui/borrowck/immutable-arg.rs:14:5\n   |\nLL | fn foo(_x: u32) {\n   |        -- argument not declared as `mut`\nLL |     _x = 4;\n   |     ^^^^^^ cannot assign to immutable argument\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `_x` (Ast)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/immutable-arg.rs","byte_start":547,"byte_end":553,"line_start":14,"line_end":14,"column_start":5,"column_end":11,"is_primary":true,"text":[{"text":"    _x = 4;","highlight_start":5,"highlight_end":11}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/immutable-arg.rs","byte_start":532,"byte_end":534,"line_start":13,"line_end":13,"column_start":8,"column_end":10,"is_primary":false,"text":[{"text":"fn foo(_x: u32) {","highlight_start":8,"highlight_end":10}],"label":"first assignment to `_x`","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `_x` (Ast)\n  --> /checkout/src/test/ui/borrowck/immutable-arg.rs:14:5\n   |\nLL | fn foo(_x: u32) {\n   |        -- first assignment to `_x`\nLL |     _x = 4;\n   |     ^^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:42:43] {"message":"For more information about this error, try `rustc --explain E0384`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0384`.\n"}
---
[00:42:43] - error[E0382]: use of partially moved value: `maybe` (Ast)
[00:42:43] -   --> $DIR/issue-41962.rs:17:30
[00:42:43] -    |
[00:42:43] - LL |         if let Some(thing) = maybe {
[00:42:43] -    |                     -----    ^^^^^ value used here after move
[00:42:43] -    |                     |
[00:42:43] -    |                     value moved here
[00:42:43] -    |
[00:42:43] -    = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
[00:42:43] -
[00:42:43] - error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast)
[00:42:43] -   --> $DIR/issue-41962.rs:17:21
[00:42:43] -    |
[00:42:43] - LL |         if let Some(thing) = maybe {
[00:42:43] -    |                     ^^^^^ value moved here in previous iteration of loop
[00:42:43] -    |
[00:42:43] -    = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
[00:42:43] -
[00:42:43] 19 error[E0382]: use of moved value: `maybe` (Mir)
[00:42:43] 20   --> $DIR/issue-41962.rs:17:9
[00:42:43] 21    |
[00:42:43]
[00:42:43] 51    |                     ^^^^^ value moved here in previous iteration of loop
[00:42:43] 52    |
[00:42:43] 53    = note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
[00:42:43] +
[00:42:43] + error[E0382]: use of partially moved value:/issue-41962.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/issue-41962.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/issue-41962.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"use of moved value: `maybe` (Mir)","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 cat 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/borrowck/issue-41962.rs","byte_start":593,"byte_end":598,"line_start":17,"line_end":17,"column_start":21,"column_end":26,"is_primary":false,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":21,"highlight_end":26}],"label":"value moved here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/issue-41962.rs","byte_start":581,"byte_end":966,"line_start":17,"line_end":23,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":9,"highlight_end":37},{"text":"        //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]","highlight_start":1,"highlight_end":71},{"text":"        //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]","highlight_start":1,"highlight_end":91},{"text":"        //~| ERROR use of moved value: `maybe` (Mir) [E0382]","highlight_start":1,"highlight_end":61},{"text":"        //~| ERROR use of moved value: `maybe` (Mir) [E0382]","highlight_start":1,"highlight_end":61},{"text":"        //~| ERROR use of moved value: `maybe.0` (Mir) [E0382]","highlight_start":1,"highlight_end":63},{"text":"        }","highlight_start":1,"highlight_end":10}],"label":"value used here after move","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `maybe` (Mir)\n  --> /checkout/src/test/ui/borrowck/issue-41962.rs:17:9\n   |\nLL |           if let Some(thing) = maybe {\n   |           ^           ----- value moved here\n   |  _________|\n   | |\nLL | |         //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]\nLL | |         //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]\nLL | |         //~| ERROR use of moved value: `maybe` (Mir) [E0382]\nLL | |         //~| ERROR use of moved value: `maybe` (Mir) [E0382]\nLL | |         //~| ERROR use of moved value: `maybe.0` (Mir) [E0382]\nLL | |         }\n   | |_________^ value used here after move\n   |\n   = note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"use of moved value: `maybe` (Mir)","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/borrowck/issue-41962.rs","byte_start":593,"byte_end":598,"line_start":17,"line_end":17,"column_start":21,"column_end":26,"is_primary":false,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":21,"highlight_end":26}],"label":"value moved here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/issue-41962.rs","byte_start":588,"byte_end":599,"line_start":17,"line_end":17,"column_start":16,"column_end":27,"is_primary":true,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":16,"highlight_end":27}],"label":"value used here after move","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `maybe` (Mir)\n  --> /checkout/src/test/ui/borrowck/issue-41962.rs:17:16\n   |\nLL |         if let Some(thing) = maybe {\n   |                ^^^^^-----^\n   |                |    |\n   |                |    value moved here\n   |                value used here after move\n   |\n   = note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"use of moved value: `maybe.0` (Mir)","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/borrowck/issue-41962.rs","byte_start":593,"byte_end":598,"line_start":17,"line_end":17,"column_start":21,"column_end":26,"is_primary":true,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":21,"highlight_end":26}],"label":"value moved here in previous iteration of loop","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `maybe.0` (Mir)\n  --> /checkout/src/test/ui/borrowck/issue-41962.rs:17:21\n   |\nLL |         if let Some(thing) = maybe {\n   |                     ^^^^^ value moved here in previous iteration of loop\n   |\n   = note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"use of partially moved value: `maybe` (Ast)","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: 5u3all 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/borrowck/issue-41962.rs","byte_start":602,"byte_end":607,"line_start":17,"line_end":17,"column_start":30,"column_end":35,"is_primary":true,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":30,"highlight_end":35}],"label":"value used here after move","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/issue-41962.rs","byte_start":593,"byte_end":598,"line_start":17,"line_end":17,"column_start":21,"column_end":26,"is_primary":false,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":21,"highlight_end":26}],"label":"value moved here","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of partially moved value: `maybe` (Ast)\n  --> /checkout/src/test/ui/borrowck/issue-41962.rs:17:30\n   |\nLL |         if let Some(thing) = maybe {\n   |                     -----    ^^^^^ value used here after move\n   |                     |\n   |                     value moved here\n   |\n   = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast)","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/borrowck/issue-41962.rs","byte_start":593,"byte_end":598,"line_start":17,"line_end":17,"column_start":21,"column_end":26,"is_primary":true,"text":[{"text":"        if let Some(thing) = maybe {","highlight_start":21,"highlight_end":26}],"label":"value moved here in previous iteration of loop","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast)\n  --> /checkout/src/test/ui/borrowck/issue-41962.rs:17:21\n   |\nLL |         if let Some(thing) = maybe {\n   |                     ^^^^^ value moved here in previous iteration of loop\n   |\n   = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"aborting due to 5 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 5 previous errors\n\n"}
[00:42:43] {"message":"For more information about this error, try `rustc --explain E0382`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0382`.\n"}
---
[00:42:43] + error[E0626]: borrow may still be in use when generator yields (Mir)
[00:42:43] +   --> $DIR/generator-with-nll.rs:20:17
[00:42:43] +    |
[00:42:43] + LL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
[00:42:43] +    |                 ^^^^^^^^^
[00:42:43] + LL |         //~^ borrow may still be in use when generator yields (Mir)
[00:42:43] + LL |         yield ();
[00:42:43] +    |         -------- possible yield occurs here
[00:42:43] +
[00:42:43] 1 error[E0626]: borrow may still be in use when generator yields (Ast)
[00:42:43] 2   --> $DIR/generator-with-nll.rs:19:23
[00:42:43] 3    |
[00:42:43]
[00:42:43] 12    |
[00:42:43] 13 LL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
[00:42:43] 14    |                      ^^^^
[00:42:43] - LL |         //~^ borrow may still be in use when generator yields (Mir)
[00:42:43] - LL |         yield ();
[00:42:43] -    |         -------- possible yield occurs here
[00:42:43] -
[00:42:43] - error[E0626]: borrow may still be in use when generator yields (Mir)
[00:42:43] -   --> $DIR/generator-with-nll.rs:20:17
[00:42:43] -    |
[00:42:43] - LL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
[00:42:43] -    |                 ^^^^^^^^^
[00:42:43] 24 LL |         //~^ borrow may still be in use when generator yields (Mir)
[00:42:43] 25 LL |         yield ();
[00:42:43] 26    |         -------- possible yield occurs here
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generator/generator-with-nll.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'generator/generator-with-nll.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/generator/generator-with-nll.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generator/generator-with-nll.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/generator/generator-with-nll.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"borrow may still be in use when generator yields (Mir)","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = &String: is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/generator/generator-with-nll.rs","byte_start":914,"byte_end":922,"line_start":22,"line_end":22,"column_start":9,"column_end":17,"is_primary":false,"text":[{"text":"        yield ();","highlight_start":9,"highlight_end":17}],"label":"possible yield occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/generator-with-nll.rs","byte_start":762,"byte_end":771,"line_start":20,"line_end":20,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"        let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Mir)\n  --> /checkout/src/test/ui/generator/generator-with-nll.rs:20:17\n   |\nLL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)\n   |                 ^^^^^^^^^\nLL |         //~^ borrow may still be in use when generator yields (Mir)\nLL |         yield ();\n   |         -------- possible yield ocd by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/generator/generator-with-nll.rs","byte_start":914,"byte_end":922,"line_start":22,"line_end":22,"column_start":9,"column_end":17,"is_primary":false,"text":[{"text":"        yield ();","highlight_start":9,"highlight_end":17}],"label":"possible yield occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/generator-with-nll.rs","byte_start":675,"byte_end":679,"line_start":19,"line_end":19,"column_start":23,"column_end":27,"is_primary":true,"text":[{"text":"        let _a = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)","highlight_start":23,"highlight_end":27}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Ast)\n  --> /checkout/src/test/ui/generator/generator-with-nll.rs:19:23\n   |\nLL |         let _a = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)\n   |                       ^^^^\n...\nLL |         yield ();\n   |         -------- possible yield occurs here\n\n"}
[00:42:43] {"message":"borrow may still be in use when generator yields (Ast)","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![[{"text":"        let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)","highlight_start":22,"highlight_end":26}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Ast)\n  --> /checkout/src/test/ui/generator/generator-with-nll.rs:20:22\n   |\nLL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)\n   |                      ^^^^\nLL |         //~^ borrow may still be in use when generator yields (Mir)\nLL |         yield ();\n   |         -------- possible yield occurs here\n\n"}
[00:42:43] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:42:43] {"message":"For more information about this error, try `rustc --explain E0626`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0626`.\n"}
---
[00:42:43] - error[E0626]: borrow may still be in use when generator yields (Ast)
[00:42:43] -   --> $DIR/yield-while-local-borrowed.rs:24:22
[00:42:43] + error[E0626]: borrow may still be in use when generator yields (Mir)
[00:42:43] +   --> $DIR/yield-while-local-borrowed.rs:24:17
[00:42:43] 3    |
[00:42:43] 4 LL |         let a = &mut 3;
[00:42:43] -    |                      ^
[00:42:43] +    |                 ^^^^^^
[00:42:43] 6 ...
[00:42:43] 7 LL |         yield();
[00:42:43] 8    |         ------- possible yield occurs here
[00:42:43]
[00:42:43] 9
[00:42:43] 10 error[E0626]: borrow may still be in use when generator yields (Ast)
[00:42:43] -   --> $DIR/yield-while-local-borrowed.rs:52:22
[00:42:43] +   --> $DIR/yield-while-local-borrowed.rs:24:22
[00:42:43] 12    |
[00:42:43] - LL |             let b = &a;
[00:42:43] + LL |         let a = &mut 3;
[00:42:43] 14    |                      ^
[00:42:43] 15 ...
[00:42:43] - LL |             yield();
[00:42:43] -    |             ------- possible yield occurs here
[00:42:43] -
[00:42:43] - error[E0626]: borrow may still be in use when generator yields (Mir)
[00:42:43] -   --> $DIR/yield-while-local-borrowed.rs:24:17
[00:42:43] -    |
[00:42:43] - LL |         let a = &mut 3;
[00:42:43] -    |                 ^^^^^^
[00:42:43] - ...
[00:42:43] 25 LL |         yield();
[00:42:43] 26    |         ------- possible yield occurs here
[00:42:43] 27
[00:42:43]
[00:42:43] 30    |
[00:42:43] 31 LL |             let b = &a;
[00:42:43] 32    |                     ^^
[00:42:43] + ...
[00:42:43] + LL |             yield();
[00:42:43] +    |             ------- possible yield occurs here
[00:42:43] +
[00:42:43] + error[E0626]: borrow may still be in use when generator yields (Ast)
[00:42:43] +   --> $DIR/yield-while-local-borrowed.rs:52:22
[00:42:43] +    |
[00:42:43] + LL |             let b = &a;
[00:42:43] +    |                      ^
[00:42:43] 33 ...
[00:42:43] 34 LL |             yield();
[00:42:43] 35    |             ------- possible yield occurs here
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generator/yield-while-local-borrowed.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'generator/yield-while-local-borrowed.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/generator/yield-while-local-borrowed.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generator/yield-while-local-borrowed.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/generator/yield-while-local-borrowed.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"borrow may still be in use when generator yields (Mir)","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for &x in &v { // <-- borrow of `v` is still in scope...\n    yield x; // ...when this yield occurs.\n  }\n};\nunsafe { b.resume() };\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":1033,"byte_end":1040,"line_start":27,"line_end":27,"column_start":9,"column_end":16,"is_primary":false,"text":[{"text":"        yield();","highlight_start":9,"highlight_end":16}],"label":"possible yield occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":869,"byte_end":875,"line_start":24,"line_end":24,"column_start":17,"column_end":23,"is_primary":true,"text":[{"text":"        let a = &mut 3;","highlight_start":17,"highlight_end":23}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Mir)\n  --> /checkout/src/test/ui/generator/yield-while-local-borrowed.rs:24:17\n   |\nLL |         let a = &mut 3;\n   |                 ^^^^^^\n...\nLL |         yield();\n   |         ------- possible yield occurs here\n\n"}
[00:42:43] {"message":"borrow may still be in use when generator yields (Ast)","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for &x in &v { // <-- borrow of `v` is still in scope...\n    yield x; // ...when this yield occurs.\n  }\n};\nunsafe { b.resume() };\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":1033,"byte_end":1040,"line_start":27,"line_end":27,"column_start":9,"column_end":16,"is_primary":false,"text":[{"text":"        yield();","highlight_start":9,"highlight_end":16}],"label":"possible yield occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":874,"byte_end":875,"line_start":24,"line_end":24,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":"        let a = &mut 3;","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Ast)\n  --> /checkout/src/test/ui/generator/yield-while-local-borrowed.rs:24:22\n   |\nLL |         let a = &mut 3;\n   |                      ^\n...\nLL |         yield();\n   |         ------- possible yield occurs here\n\n"}
[00:42:43] {"message":"borrow may still be in use when generator yields (Mir)","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for &x in &v { // <-- borrow of `v` is still in scope...\n    yield x; // ...when this yield occurs.\n  }\n};\nunsafe { b.resume() };\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":1774,"byte_end":1781,"line_start":55,"line_end":55,"column_start":13,"column_end":20,"is_primary":false,"text":[{"text":"            yield();","highlight_start":13,"highlight_end":20}],"label":"possible yield occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":1602,"byte_end":1604,"line_start":52,"line_end":52,"column_start":21,"column_end":23,"is_primary":true,"text":[{"text":"            let b = &a;","highlight_start":21,"highlight_end":23}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Mir)\n  --> /checkout/src/test/ui/generator/yield-while-local-borrowed.rs:52:21\n   |\nLL |             let b = &a;\n   |                     ^^\n...\nLL |             yield();\n   |             ------- possible yield occurs here\n\n"}
[00:42:43] {"message":"borrow may still be in use when generator yields (Ast)","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nunsafe { b.resume() };\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for &x in &v { // <-- borrow of `v` is still in scope...\n    yield x; // ...when this yield occurs.\n  }\n};\nunsafe { b.resume() };\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait)]\n# use std::ops::Generator;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nunsafe { b.resume() };\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":1774,"byte_end":1781,"line_start":55,"line_end":55,"column_start":13,"column_end":20,"is_primary":false,"text":[{"text":"            yield();","highlight_start":13,"highlight_end":20}],"label":"possible yield occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/yield-while-local-borrowed.rs","byte_start":1603,"byte_end":1604,"line_start":52,"line_end":52,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":"            let b = &a;","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0626]: borrow may still be in use when generator yields (Ast)\n  --> /checkout/src/test/ui/generator/yield-while-local-borrowed.rs:52:22\n   |\nLL |             let b = &a;\n   |                      ^\n...\nLL |             yield();\n   |             ------- possible yield occurs here\n\n"}
[00:42:43] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:42:43] {"message":"For more information about this error, try `rustc --explain E0626`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0626`.\n"}
---
[00:42:43] - error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
[00:42:43] + error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
[00:42:43] 2   --> $DIR/issue-45697-1.rs:30:9
[00:42:43] 3    |
[00:42:43] 4 LL |         let z = copy_borrowed_ptr(&mut y);
[00:42:43]
[00:42:43] -    |                                        - borrow of `*y.pointer` occurs here
[00:42:43] +    |                                   ------ borrow of `y` occurs here
[00:42:43] 6 LL |         *y.pointer += 1;
[00:42:43] -    |         ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
[00:42:43] +    |         ^^^^^^^^^^^^^^^ use of borrowed `y`
[00:42:43] 8
[00:42:43] - error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
[00:42:43] + error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
[00:42:43] 10   --> $DIR/issue-45697-1.rs:30:9
[00:42:43] 11    |
[00:42:43] 12 LL |         let z = copy_borrowed_ptr(&mut y);
[00:42:43]
[00:42:43] -    |                                   ------ borrow of `y` occurs here
[00:42:43] +    |                                        - borrow of `*y.pointer` occurs here
[00:42:43] 14 LL |         *y.pointer += 1;
[00:42:43] -    |         ^^^^^^^^^^^^^^^ use of borrowed `y`
[00:42:43] +    |         ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
---
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'issue-45697-1.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-45697-1.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-45697-1.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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=on" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-45697-1.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"cannot use `*y.pointer` because it was mutably borrowed (Mir)","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/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,"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,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)\n  --> /checkout/src/test/ui/issue-45697-1.rs:30:9\n   |\nLL |         let z = copy_borrowed_ptr(&mut y);\n   |                                   ------ borrow of `y` occurs here\nLL |         *y.pointer += 1;\n   |         ^^^^^^^^^^^^^^^ use of borrowed `y`\n\n"}
[00:42:43] {"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}\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":935,"byte_end":936,"line_start":29,"line_end":29,"column_start":40,"column_end":41,"is_primary":false,"text":[{"text":"        let z = copy_borrowed_ptr(&mut y);","highlight_start":40,"highlight_end":41}],"label":"borrow of `*y.pointer` occurs here","suggested_replacement":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":"assignment to borrowed `*y.pointer` occurs here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)\n  --> /checkout/src/test/ui/issue-45697-1.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\n"}
[00:42:43] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:42:43] {"message":"Some errors occurred: E0503, E0506.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0503, E0506.\n"}
[00:42:43] {"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:42:43] - error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
[00:42:43] + error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
[00:42:43] 2   --> $DIR/issue-45697.rs:30:9
[00:42:43] 3    |
[00:42:43] 4 LL |         let z = copy_borrowed_ptr(&mut y);
[00:42:43]
[00:42:43] -    |                                        - borrow of `*y.pointer` occurs here
[00:42:43] +    |                                   ------ borrow of `y` occurs here
[00:42:43] 6 LL |         *y.pointer += 1;
[00:42:43] -    |         ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
[00:42:43] +    |         ^^^^^^^^^^^^^^^ use of borrowed `y`
[00:42:43] 8
[00:42:43] - error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
[00:42:43] + error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
[00:42:43] 10   --> $DIR/issue-45697.rs:30:9
[00:42:43] 11    |
[00:42:43] 12 LL |         let z = copy_borrowed_ptr(&mut y);
[00:42:43]
[00:42:43] -    |                                   ------ borrow of `y` occurs here
[00:42:43] +    |                                        - borrow of `*y.pointer` occurs here
[00:42:43] 14 LL |         *y.pointer += 1;
[00:42:43] -    |         ^^^^^^^^^^^^^^^ use of borrowed `y`
[00:42:43] +    |         ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
---
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'issue-45697.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-45697.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-45697.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"cannot use `*y.pointer` because it was mutably borrowed (Mir)","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/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` occurs here","suggested_replacement":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":"use of borrowed `y`","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)\n  --> /checkout/src/test/ui/is= 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":936,"byte_end":937,"line_start":29,"line_end":29,"column_start":40,"column_end":41,"is_primary":false,"text":[{"text":"        let z = copy_borrowed_ptr(&mut y);","highlight_start":40,"highlight_end":41}],"label":"borrow of `*y.pointer` occurs here","suggested_replacement":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,"expansion":null}],"children":[],"rendered":"error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)\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\n"}
[00:42:43] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:42:43] {"message":"Some errors occurred: E0503, E0506.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0503, E0506.\n"}
[00:42:43] {"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:42:43] - error[E0597]: `z` does not live long enough (Ast)
[00:42:43] -   --> $DIR/issue-46471-1.rs:16:14
[00:42:43] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:478:22
[00:42:43] + error[E0597]: `z` does not live long enough (Mir)
[00:42:43] +   --> $DIR/issue-46471-1.rs:16:9
[00:42:43] 3    |
[00:42:43] 4 LL |         &mut z
[00:42:43] -    |              ^ borrowed value does not live long enough
[00:42:43] +    |         ^^^^^^ borrowed value does not live long enough
[00:42:43] 6 LL |     };
[00:42:43] 7    |     - `z` dropped here while still borrowed
[00:42:43] 8 ...
[00:42:43]
[00:42:43] 9 LL | }
[00:42:43] 10    | - borrowed value needs to live until here
[00:42:43] 11
[00:42:43] - error[E0597]: `z` does not live long enough (Mir)
[00:42:43] -   --> $DIR/issue-46471-1.rs:16:9
[00:42:43] + error[E0597]: `z` does not live long enough (Ast)
[00:42:43] +   --> $DIR/issue-46471-1.rs:16:14
[00:42:43] 14    |
[00:42:43] 15 LL |         &mut z
[00:42:43] -    |         ^^^^^^ borrowed value does not live long enough
[00:42:43] +    |              ^ borrowed value does not live long enough
[00:42:43] 17 LL |     };
[00:42:43] 18    |     - `z` dropped here while still borrowed
[00:42:43] 19 ...
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46471-1.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'issue-46471-1.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-46471-1.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46471-1.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"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,"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,"expansion":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,"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 |         &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:42:43] {"message":"`z` does not live long enough (Ast)","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":588,"byte_end"}
---
[00:42:43] - error[E0597]: `x` does not live long enough (Ast)
[00:42:43] -   --> $DIR/issue-46471.rs:15:6
[00:42:43] + error[E0597]: `x` does not live long enough (Mir)
[00:42:43] +   --> $DIR/issue-46471.rs:15:5
[00:42:43] 3    |
[00:42:43] 4 LL |     &x
[00:42:43] -    |      ^ borrowed value does not live long enough
[00:42:43] +    |     ^^ borrowed value does not live long enough
[00:42:43] 6 ...
[00:42:43] 7 LL | }
[00:42:43] 8    | - borrowed value only lives until here
[00:42:43]
[00:42:43] 9    |
[00:42:43] 10    = note: borrowed value must be valid for the static lifetime...
[00:42:43] 11
[00:42:43] - error[E0597]: `x` does not live long enough (Mir)
[00:42:43] -   --> $DIR/issue-46471.rs:15:5
[00:42:43] + error[E0597]: `x` does not live long enough (Ast)
[00:42:43] +   --> $DIR/issue-46471.rs:15:6
[00:42:43] 14    |
[00:42:43] 15 LL |     &x
[00:42:43] -    |     ^^ borrowed value does not live long enough
[00:42:43] +    |      ^ borrowed value does not live long enough
[00:42:43] 17 ...
[00:42:43] 18 LL | }
[00:42:43] 19    | - borrowed value only lives until here
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46471.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'issue-46471.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-46471.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46471.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"`x` 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 haeater 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.rs","byte_start":573,"byte_end":574,"line_start":15,"line_end":15,"column_start":6,"column_end":7,"is_primary":true,"text":[{"text":"    &x","highlight_start":6,"highlight_end":7}],"label":"borrowed value does not live long enough","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-46471.rs","byte_start":693,"byte_end":694,"line_start":18,"line_end":18,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"borrowed value only lives until here","suggested_replacement":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0597]: `x` does not live long enough (Ast)\n  --> /checkout/src/test/ui/issue-46471.rs:15:6\n   |\nLL |     &x\n   |      ^ borrowed value does not live long enough\n...\nLL | }\n   pdate references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'issue-46472.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-46472.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-46472.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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-46472.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"borrowed value 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-46472.rs","byte_start":565,"byte_end":566,"line_start":14,"line_end":14,"column_start":10,"column_end":11,"is_primary":true,"text":[{"text":"    &mut 4","highlight_start":10,"highlight_end":11}],"label":"temporary value does not live long enough","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/issue-46472.rs","byte_start":707,"byte_end":708,"line_start":17,"line_end":17,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value only lives until here","suggested_replacement":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issue-46472.rs","byte_start":526,"byte_end":553,"line_start":13,"line_end":13,"column_start":1,"column_end":28,"is_primary":true,"text":[{"text":"fn bar<'a>() -> &'a mut u32 {","highlight_start":1,"highlight_end":28}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0597]: borrowed value does not live long enough (Mir)\n  --> /checkout/src/test/ui/issue-46472.rs:14:t":17,"line_end":17,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value only lives until here","suggested_replacement":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issue-46472.rs","byte_start":526,"byte_end":553,"line_start":13,"line_end":13,"column_start":1,"column_end":28,"is_primary":true,"text":[{"text":"fn bar<'a>() -> &'a mut u32 {","highlight_start":1,"highlight_end":28}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0597]: borrowed value does not live long enough (Ast)\n  --> /checkout/src/test/ui/issue-46472.rs:14:10\n   |\nLL |     &mut 4\n   |          ^ temporary value does not live long enough\n...\nLL | }\n   | - temporary value only lives until here\n   |\nnote: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1...\n  --> /checkout/src/test/ui/issue-46472.rs:13:1\n   |\nLL | fn bar<'a>() -> &'a mut u32 {\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:42:43] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:42:43] {"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:42:43]
[00:42:43] -----first assignment to `x`
[00:42:43] + LL |             x = 3;      //~ ERROR (Ast) [E0384]
[00:42:43] +    |             ^^^^^ cannot assign twice to immutable variable
[00:42:43] +
[00:42:43] + error[E0384]: cannot assign twice to immutable variable `x` (Mir)
[00:42:43] 18   --> $DIR/liveness-assign-imm-local-notes.rs:45:13
[00:42:43] 19    |
[00:42:43] 20 LL |             x = 1;      //~ ERROR (Ast) [E0384]
[00:42:43]
[00:42:43] 21    |             ^^^^^ cannot assign twice to immutable variable
[00:42:43] 22
[00:42:43] - error[E0384]: cannot assign twice to immutable variable `x` (Ast)
[00:42:43] + error[E0384]: cannot assign twice to immutable variable `x` (Mir)
[00:42:43] 24   --> $DIR/liveness-assign-imm-local-notes.rs:48:13
[00:42:43] 25    |
[00:42:43] 26 LL |             x = 1;      //~ ERROR (Ast) [E0384]
[00:42:43]
[00:42:43] 29 LL |             x = 2;      //~ ERROR (Ast) [E0384]
[00:42:43] 30    |             ^^^^^ cannot assign twice to immutable variable
[00:42:43] 31
[00:42:43] - error[E0384]: cannot assign twice to immutable variable `x` (Mir)
[00:42:43] -   --> $DIR/liveness-assign-imm-local-notes.rs:23:9
[00:42:43] -    |
[00:42:43] - LL |         x = 2;
[00:42:43] -    |         ----- first assignment to `x`
[00:42:43] - LL |         x = 3;      //~ ERROR (Ast) [E0384]
[00:42:43] -    |         ^^^^^ cannot assign twice to immutable variable
[00:42:43] -
[00:42:43] - error[E0384]: cannot assign twice to immutable variable `x` (Mir)
[00:42:43] -   --> $DIR/liveness-assign-imm-local-notes.rs:35:13
[00:42:43] -    |
[00:42:43] - LL |             x = 2;
[00:42:43] -    |             ----- first assignment to `x`
[00:42:43] - LL |             x = 3;      //~ ERROR (Ast) [E0384]
[00:42:43] -    |             ^^^^^ cannot assign twice to immutable variable
[00:42:43] -
[00:42:43] - error[E0384]: cannot assign twice to immutable variable `x` (Mir)
[00:42:43] + error[E0384]: cannot assign twice to immutable variable `x` (Ast)
[00:42:43] 49   --> $DIR/liveness-assign-imm-local-notes.rs:45:13
[00:42:43] 50    |
[00:42:43] 51 LL |             x = 1;      //~ ERROR (Ast) [E0384]
[00:42:43]
[00:42:43] 52    |             ^^^^^ cannot assign twice to immutable variable
[00:42:43] 53
[00:42:43] - error[E0384]: cannot assign twice to immutable variable `x` (Mir)
[00:42:43] + error[E0384]: cannot assign twice to immutable variable `x` (Ast)
[00:42:43] 55   --> $DIR/liveness-assign-imm-local-notes.rs:48:13
[00:42:43] 56    |
[00:42:43] 57 LL |             x = 1;      //~ ERROR (Ast) [E0384]
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lifetime-errors/liveness-assign-imm-local-notes.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'lifetime-errors/liveness-assign-imm-local-notes.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/lifetime-errors/liveness-assign-ight_start":9,"highlight_end":14}],"label":"first assignment to `x`","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":774,"byte_end":779,"line_start":23,"line_end":23,"column_start":9,"column_end":14,"is_primary":true,"text":[{"text":"        x = 3;      //~ ERROR (Ast) [E0384]","highlight_start":9,"highlight_end":14}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Mir)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:23:9\n   |\nLL |         x = 2;\n   |         ----- first assignment to `x`\nLL |         x = 3;      //~ ERROR (Ast) [E0384]\n   |         ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Ast)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":774,"byte_end":779,"line_start":23,"line_end":23,"column_start":9,"column_end":14,"is_primary":true,"text":[{"text":"        x = 3;      //~ ERROR (Ast) [E0384]","highlight_start":9,"highlight_end":14}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":759,"byte_end":764,"line_start":22,"line_end":22,"column_start":9,"column_end":14,"is_primary":false,"text":[{"text":"        x = 2;","highlight_start":9,"highlight_end":14}],"label":"first assignment to `x`","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Ast)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:23:9\n   |\nLL |         x = 2;\n   |         ----- first assignment to `x`\nLL |         x = 3;      //~ ERROR (Ast) [E0384]\n   |         ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Mir)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":976,"byte_end":981,"line_start":34,"line_end":34,"column_start":13,"column_end":18,"is_primary":false,"text":[{"text":"            x = 2;","highlight_start":13,"highlight_end":18}],"label":"first assignment to `x`","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":995,"byte_end":1000,"line_start":35,"line_end":35,"column_start":13,"column_end":18,"is_primary":true,"text":[{"text":"            x = 3;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Mir)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:35:13\n   |\nLL |             x = 2;\n   |             ----- first assignment to `x`\nLL |             x = 3;      //~ ERROR (Ast) [E0384]\n   |             ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Ast)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":995,"byte_end":1000,"line_start":35,"line_end":35,"column_start":13,"column_end":18,"is_primary":true,"text":[{"text":"            x = 3;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":976,"byte_end":981,"line_start":34,"line_end":34,"column_start":13,"column_end":18,"is_primary":false,"text":[{"text":"            x = 2;","highlight_start":13,"highlight_end":18}],"label":"first assignment to `x`","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Ast)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:35:13\n   |\nLL |             x = 2;\n   |             ----- first assignment to `x`\nLL |             x = 3;      //~ ERROR (Ast) [E0384]\n   |             ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Mir)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":1174,"byte_end":1179,"line_start":45,"line_end":45,"column_start":13,"column_end":18,"is_primary":true,"text":[{"text":"            x = 1;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Mir)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:45:13\n   |\nLL |             x = 1;      //~ ERROR (Ast) [E0384]\n   |             ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Mir)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":1174,"byte_end":1179,"line_start":45,"line_end":45,"column_start":13,"column_end":18,"is_primary":false,"text":[{"text":"            x = 1;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"first assignment to `x`","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":1288,"byte_end":1293,"line_start":48,"line_end":48,"column_start":13,"column_end":18,"is_primary":true,"text":[{"text":"            x = 2;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Mir)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:48:13\n   |\nLL |             x = 1;      //~ ERROR (Ast) [E0384]\n   |             ----- first assignment to `x`\n...\nLL |             x = 2;      //~ ERROR (Ast) [E0384]\n   |             ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Ast)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":1174,"byte_end":1179,"line_start":45,"line_end":45,"column_start":13,"column_end":18,"is_primary":true,"text":[{"text":"            x = 1;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Ast)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:45:13\n   |\nLL |             x = 1;      //~ ERROR (Ast) [E0384]\n   |             ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"cannot assign twice to immutable variable `x` (Ast)","code":{"code":"E0384","explanation":"\nThis error occurs when an attempt is made to reassign an immutable variable.\nFor example:\n\n```compile_fail,E0384\nfn main() {\n    let x = 3;\n    x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n    let mut x = 3;\n    x = 5;\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":1288,"byte_end":1293,"line_start":48,"line_end":48,"column_start":13,"column_end":18,"is_primary":true,"text":[{"text":"            x = 2;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"cannot assign twice to immutable variable","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs","byte_start":1174,"byte_end":1179,"line_start":45,"line_end":45,"column_start":13,"column_end":18,"is_primary":false,"text":[{"text":"            x = 1;      //~ ERROR (Ast) [E0384]","highlight_start":13,"highlight_end":18}],"label":"first assignment to `x`","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0384]: cannot assign twice to immutable variable `x` (Ast)\n  --> /checkout/src/test/ui/lifetime-errors/liveness-assign-imm-local-notes.rs:48:13\n   |\nLL |             x = 1;      //~ ERROR (Ast) [E0384]\n   |             ----- first assignment to `x`\n...\nLL |             x = 2;      //~ ERROR (Ast) [E0384]\n   |             ^^^^^ cannot assign twice to immutable variable\n\n"}
[00:42:43] {"message":"aborting due to 8 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 8 previous errors\n\n"}
[00:42:43] {"message":"For more information about this error, try `rustc --explain E0384`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0384`.\n"}
---
[00:42:43] - error[E0382]: use of moved value: `x` (Ast)
[00:42:43] + error[E0382]: use of moved value: `x` (Mir)
[00:42:43] 2   --> $DIR/moves-based-on-type-tuple.rs:16:13
[00:42:43] 3    |
[00:42:43] 4 LL |     box (x, x)
[00:42:43]
[00:42:43] 8    |
[00:42:43] 9    = note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
[00:42:43] 10
[00:42:43] - error[E0382]: use of moved value: `x` (Mir)
[00:42:43] + error[E0382]: use of moved value: `x` (Ast)
[00:42:43] 12   --> $DIR/moves-based-on-type-tuple.rs:16:13
[00:42:43] 13    |
[00:42:43] 14 LL |     box (x, x)
[00:42:43]
[00:42:43]
[00:42:43] The actual stderr differed from the expected stderr.
[00:42:43] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/moves-based-on-type-tuple.stderr
[00:42:43] To update references, run this command from build directory:
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'moves-based-on-type-tuple.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/moves-based-on-type-tuple.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/moves-based-on-type-tuple.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/moves-based-on-type-tuple.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"use of moved value: `x` (Mir)","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/moves-based-on-type-tuple.rs","byte_start":616,"byte_end":617,"line_start":16,"line_end":16,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    box (x, x)","highlight_start":10,"highlight_end":11}],"label":"value moved here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/moves-based-on-type-tuple.rs","byte_start":619,"byte_end":620,"line_start":16,"line_end":16,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    box (x, x)","highlight_start":13,"highlight_end":14}],"label":"value used here after move","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x` (Mir)\n  --> /checkout/src/test/ui/moves-based-on-type-tuple.rs:16:13\n   |\nLL |     box (x, x)\n   |          -  ^ value used here after move\n   |          |\n   |          value moved here\n   |\n   = note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"use of moved value: `x` (Ast)","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/moves-based-on-type-tuple.rs","byte_start":619,"byte_end":620,"line_start":16,"line_end":16,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    box (x, x)","highlight_start":13,"highlight_end":14}],"label":"value used here after move","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/moves-based-on-type-tuple.rs","byte_start":616,"byte_end":617,"line_start":16,"line_end":16,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    box (x, x)","highlight_start":10,"highlight_end":11}],"label":"value moved here","suggested_replacement":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x` (Ast)\n  --> /checkout/src/test/ui/moves-based-on-type-tuple.rs:16:13\n   |\nLL |     box (x, x)\n   |          -  ^ value used here after move\n   |          |\n   |          value moved here\n   |\n   = note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait\n\n"}
[00:42:43] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous err   --- immutable borrow occurs here
[00:42:43]
[00:42:43] - ...
[00:42:43] - LL |                 map.set(String::new()); // Just AST errors here
[00:42:43] + LL |             Some(v) => {
[00:42:43] + LL |                 map.set(String::new()); // Both AST and MIR error here
[00:42:43] 32    |                 ^^^ mutable borrow occurs here
[00:42:43] 33 ...
[00:42:43] 34 LL | }
[00:42:43]
[00:42:43] 35    | - immutable borrow ends here
[00:42:43] 36
[00:42:43] - error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
[00:42:43] -   --> $DIR/get_default.rs:44:17
[00:42:43] + error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
[00:42:43] +   --> $DIR/get_default.rs:50:17
[00:42:43] 39    |
[00:42:43] 40 LL |         match map.get() {
[00:42:43] 41    |               --- immutable borrow occurs here
[00:42:43]
[00:42:43] - LL |             Some(v) => {
[00:42:43] - LL |                 map.set(String::new()); // Both AST and MIR error here
[00:42:43] + ...
[00:42:43] + LL |                 map.set(String::new()); // Just AST errors here
[00:42:43] 44    |                 ^^^ mutable borrow occurs here
[00:42:43] 45 ...
[00:42:43] - LL |                 return v;
[00:42:43] -    |                        - borrow later used here
[00:42:43] + LL | }
[00:42:43] +    | - immutable borrow ends here
---
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'nll/get_default.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 101
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/get_default.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/get_default.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Znll" "-Zborrowck=compare" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/get_default.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
---
[00:42:43] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1059,"byte_end":1062,"line_start":33,"line_end":33,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Just AST errors here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":944,"byte_end":947,"line_start":28,"line_end":28,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1192,"byte_end":1193,"line_start":38,"line_end":38,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"immutable borrow ends here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)\n  --> /checkout/src/test/ui/nll/get_default.rs:33:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\n...\nLL |                 map.set(String::new()); // Just AST errors here\n   |                 ^^^ mutable borrow occurs here\n...\nLL | }\n   | - immutable borrow ends here\n\n"}
[00:42:43] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1308,"byte_end":1311,"line_start":44,"line_end":44,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Both AST and MIR error here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1255,"byte_end":1258,"line_start":42,"line_end":42,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1496,"byte_end":1497,"line_start":47,"line_end":47,"column_start":24,"column_end":25,"is_primary":false,"text":[{"text":"                return v;","highlight_start":24,"highlight_end":25}],"label":"borrow later used here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)\n  --> /checkout/src/test/ui/nll/get_default.rs:44:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\nLL |             Some(v) => {\nLL |                 map.set(String::new()); // Both AST and MIR error here\n   |                 ^^^ mutable borrow occurs here\n...\nLL |                 return v;\n   |                        - borrow later used here\n\n"}
[00:42:43] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1308,"byte_end":1311,"line_start":44,"line_end":44,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Both AST and MIR error here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1255,"byte_end":1258,"line_start":42,"line_end":42,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1684,"byte_end":1685,"line_start":55,"line_end":55,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"immutable borrow ends here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)\n  --> /checkout/src/test/ui/nll/get_default.rs:44:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\nLL |             Some(v) => {\nLL |                 map.set(String::new()); // Both AST and MIR error here\n   |                 ^^^ mutable borrow occurs here\n...\nLL | }\n   | - immutable borrow ends here\n\n"}
[00:42:43] {"message":"cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1551,"byte_end":1554,"line_start":50,"line_end":50,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"                map.set(String::new()); // Just AST errors here","highlight_start":17,"highlight_end":20}],"label":"mutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1255,"byte_end":1258,"line_start":42,"line_end":42,"column_start":15,"column_end":18,"is_primary":false,"text":[{"text":"        match map.get() {","highlight_start":15,"highlight_end":18}],"label":"immutable borrow occurs here","suggested_replacement":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/get_default.rs","byte_start":1684,"byte_end":1685,"line_start":55,"line_end":55,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"immutable borrow ends here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)\n  --> /checkout/src/test/ui/nll/get_default.rs:50:17\n   |\nLL |         match map.get() {\n   |               --- immutable borrow occurs here\n...\nLL |                 map.set(String::new()); // Just AST errors here\n   |                 ^^^ mutable borrow occurs here\n...\nLL | }\n   | - immutable borrow ends here\n\n"}
[00:42:43] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:42:43] {"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:42:43] - error: internal compiler error: unexpected region for local data ReFree(DefId(0/0:3 ~ issue_48697[317d]::foo[0]), BrAnon(0))
[00:42:43] -   --> $DIR/issue-48697.rs:22:16
[00:42:43] -    |
[00:42:43] - LL |     let k = f(&z);
---
[00:42:43] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'nll/issue-48697.rs'
[00:42:43]
[00:42:43] error: 1 errors occurred comparing output.
[00:42:43] status: exit code: 0
[00:42:43] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/issue-48697.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-48697.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/check_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zmiri -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zmiri -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:42:43] expected success, got: exit code: 101
[00:42:43]
[00:42:43]
[00:42:43] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:42:43] Build completed unsuccessfully in 0:02:36
[00:42:43] Makefile:58: recipe for target 'check' failed
[00:42:43] make: *** [check] Error 1
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:0b810e38:start=1522878484570860216,finish=1522878484588336626,duration=17476410
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:077b3140
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:077b3140:start=1522878484598197237,finish=1522878484609219249,duration=11022012
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:11a0a08f
$ dmesg | grep -i kill
[   10.518774] init: failsafe main process (1095) killed by TERM signal

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.

@pietroalbini pietroalbini added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 5, 2018
@pietroalbini
Copy link
Member

Ping from triage! @pnkfelix this PR needs your review!
Also @nikomatsakis, the build is currently failing.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 9, 2018

@nikomatsakis (I suspect that test "just" needs updating to reflect the changes in your PR?)

@@ -0,0 +1,8 @@
error: internal compiler error: unexpected region for local data ReFree(DefId(0/0:3 ~ issue_48697[317d]::foo[0]), BrAnon(0))
Copy link
Member

Choose a reason for hiding this comment

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

@nikomatsakis : You say you are removing the ICE, but the expected stderr you have encoded here is an ICE?

// thief, `optimized_mir()`, forces borrowck, so we know that
// is not yet stolen.
tcx.mir_validated(owner_def_id).borrow();
// Force the MIR-based borrow checker to run; this also forces the
Copy link
Member

Choose a reason for hiding this comment

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

I don't 100% understand your logic in making this change part of this PR.

If you had not already added a guard elsewhere with a "if tcx.sess.nll(), then do not call bug()", then maybe I could understand forcing MIR borrowck to run.

But why do you need to force MIR borrow check to be run when you have the aforementioned guard in place on the ICE? Doesn't that avoid the problem (since we will call bug() when we are not in feature(nll) mode in that case?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are correct that this change is not needed. I thought it would allow me to use span-delay-bug initially but that turned out not to be the case.

@bors
Copy link
Contributor

bors commented Apr 10, 2018

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

@pnkfelix pnkfelix added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2018
@pietroalbini
Copy link
Member

Ping from triage @nikomatsakis! The reviewer left some comments, could you address them? Also, there is a merge conflict that needs to be fixed.

@pietroalbini pietroalbini added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 23, 2018
@shepmaster
Copy link
Member

We haven't heard from @nikomatsakis in a few weeks, so closing this to keep the queue tidy. Please feel free to reopen when you have time to get back to this!

@shepmaster shepmaster closed this Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants