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

[wip] add condition to check if the value is moved #56811

Closed

Conversation

Dylan-DPC-zz
Copy link

closes #56657

r? @davidtwco

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 14, 2018
@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
travis_time:end:11fb78cb:start=1544784677412815879,finish=1544784735745678828,duration=58332862949
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:45:03] 
[00:45:03] running 5169 tests
[00:45:05] .................................................................................................... 100/5169
[00:45:08] .................................................................................................... 200/5169
[00:45:11] ..........F.....................................F....F.......................F...................... 300/5169
[00:45:14] ..........FF.......................................F...............F................................ 400/5169
[00:45:18] ............F.F..............................F...................................................... 500/5169
[00:45:25] .................................................................................................... 700/5169
[00:45:30] .................................................................................................... 800/5169
[00:45:35] .i...............i.................................................................................. 900/5169
[00:45:38] ........................iiiii....................................................................... 1000/5169
---
[00:46:07] .......................................i............................................................ 2000/5169
[00:46:11] .................................................................................................... 2100/5169
[00:46:15] .................................................................................................... 2200/5169
[00:46:19] .................................................................................................... 2300/5169
[00:46:23] .........................F.......................................................................... 2400/5169
[00:46:30] .................................................................................................... 2600/5169
[00:46:35] .................................................................................................... 2700/5169
[00:46:38] .................................................................................................... 2800/5169
[00:46:41] .................................................................................................... 2900/5169
[00:46:41] .................................................................................................... 2900/5169
[00:46:45] .................................................................................................... 3000/5169
[00:46:48] ....................................................................................i............... 3100/5169
[00:46:51] .................................................................................................... 3200/5169
[00:46:54] ...............................................ii..i..ii.....................F...................... 3300/5169
[00:46:58] ...............FF..........................F...........F....F............................F.......... 3400/5169
[00:47:02] .....................F.............................................................................. 3500/5169
[00:47:06] ...................................................i................................................ 3700/5169
[00:47:08] .................................................................................................... 3800/5169
[00:47:09] ......i............................................................................................. 3900/5169
[00:47:14] .................................................................................................... 4000/5169
---
[00:47:37] .................................................................................................... 4500/5169
[00:47:41] .................................................................................................... 4600/5169
[00:47:44] .................................................................................................... 4700/5169
[00:47:47] ........................i........................................................................... 4800/5169
[00:47:51] ....................F...F........................................................................... 4900/5169
[00:47:54] .................................................................................................... 5000/5169
t/src/test/ui/borrowck/borrowck-asm.rs","byte_start":1405,"byte_end":1406,"line_start":48,"line_end":48,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let z = y;","highlight_start":17,"highlight_end":18}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-asm.rs:45:32\n   |\nLL |         let y = &mut x;\n   |                 ------ borrow of `x` occurs here\nLL |         unsafe {\nLL |             asm!(\"nop\" : : \"r\"(x)); //[ast]~ ERROR cannot use\n   |                                ^ use of borrowed `x`\n...\nLL |         let z = y;\n   |                 - borrow later used here\n\n"}
[00:47:58] {"message":"cannot assign twice to immutable variable `x`","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/borrowck-asm.rs","byte_start":1452,"byte_end":1453,"line_start":52,"line_end":52,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"        let x = 3;","highlight_start":13,"highlight_end":14}],"labep-from-guard.rs stdout ----
[00:47:58] 
[00:47:58] 5    |                           ------ value moved here
[00:47:58] 5    |                           ------ value moved here
[00:47:58] 6 LL |         Some(_) => {}
[00:47:58] 7 LL |         None => { foo(my_str); } //~ ERROR [E0382]
[00:47:58] -    |                       ^^^^^^ value used here after move
[00:47:58] +    |                       ^^^^^^ value used here after partial move
[00:47:58] 9    |
[00:47:58] 10    = note: move occurs because `my_str` has type `std::string::String`, which does not implement the `Copy` trait
[00:47:58] 
[00:47:58] 
[00:47:58] The actual stderr differed from the expected stderr.
[00:47:58] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-drop-from-guard/borrowck-drop-from-guard.stderr
[00:47:58] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-drop-from-guard/borrowck-drop-from-guard.stderr
[00:47:58] To update references, rerun the tests and pass the `--bless` flag
[00:47:58] To only update this specific test, also pass `--test-args borrowck/borrowck-drop-from-guard.rs`
[00:47:58] error: 1 errors occurred comparing output.
[00:47:58] status: exit code: 1
[00:47:58] status: exit code: 1
[00:47:58] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-drop-from-guard.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-drop-from-guard/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrow] 
[00:47:58] The actual stderr differed from the expected stderr.
[00:47:58] The actual stderr differed from the expected stderr.
[00:47:58] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/borrowck-describe-lvalue.mir.stderr
[00:47:58] To update references, rerun the tests and pass the `--bless` flag
[00:47:58] To only update this specific test, also pass `--test-args borrowck/borrowck-describe-lvalue.rs`
[00:47:58] 
[00:47:58] error in revision `mir`: 1 errors occurred comparing output.
[00:47:58] status: exit code: 1
[00:47:58] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "mir" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-describe-lvalue.mir/auxiliary" "-A" "unused"
[00:47:58] ------------------------------------------
[00:47:58] 
[00:47:58] ------------------------------------------
[00:47:58] stderr:
[00:47:58] stderr:
[00:47:58] ------------------------------------------
[00:47:58] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10093,"byte_end":10099,"line_start":294,"line_end":294,"column_start":21,"column_end":27,"is_primary":false,"text":[{"text":"            let y = &mut x;","highlight_start":21,"highlight_end":27}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10113,"byte_end":10119,"line_start":295,"line_end":295,"column_start":13,"column_end":19,"is_primary":true,"text":[{"text":"            &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time","highlight_start":13,"highlight_end":19}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":10294,"byte_end":10300,"line_start":297,"line_end":297,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"            *y = 1;","highlight_start":13,"highlight_end":19}],"label":"first borrow latyte_start":1326,"byte_end":1327,"line_start":60,"line_end":60,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"        let x = g.x();","highlight_start":17,"highlight_end":18}],"label":"borrow of `g` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1341,"byte_end":1344,"line_start":61,"line_end":61,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `g`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":1501,"byte_end":1502,"line_start":63,"line_end":63,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `g.0` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:61:9\n   |\nLL |         let x = g.x();\n   |                 - borrow of `g` occurs here\nLL |         g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed\n   |         ^^^ use of borrowed `g`\nLL |              //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[alue\n   |                    ^^^^^ use of borrowed `e`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:47:58] {"message":"cannot use `u.a` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2215,"byte_end":2223,"line_start":87,"line_end":87,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":17,"highlight_end":25}],"label":"borrow of `u.a` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2233,"byte_end":2236,"line_start":88,"line_end":88,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `u.a`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":2393,"byte_end":2394,"line_start":90,"line_end":90,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `u.a` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:88:9\n   |\nLL |         let x = &mut u.a;\n   |                 -------- borrow of `u.a` occurs here\nLL |    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3712,"byte_end":3720,"line_start":130,"line_end":130,"column_start":17,"column_end":25,"is_primary":false,"text":[{"text":"        let x = &mut u.a;","highlight_start":17,"highlight_end":25}],"label":"borrow of `u.a` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3730,"byte_end":3733,"line_start":131,"line_end":131,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"        u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed","highlight_start":9,"highlight_end":12}],"label":"use of borrowed `u.a`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3890,ility":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:140:15\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\nLL |         match v {\nLL |             &[x, _, .., _, _] => println!(\"{}\", x),\n   |               ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:47:58] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutability rules.\n\nYou can fix this error by limiting the scope of the borrow:\n\n```\nfn main() {\n r by limiting the scope of the borrow:\n\n```\nfn main() {\n    let mut value = 3;\n    // By creating a new block, you can limit the scope\n    // of the reference.\n    {\n        let _borrow = &mut value; // Use `_borrow` inside this block.\n    }\n    // The block has ended and with it the borrow.\n    // You can now use `value` again.\n    let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n    let mut value = 3;\n    // We clone `value`, creating a copy.\n    let value_cloned = value.clone();\n    // The mutable borrow is a reference to `value` and\n    // not to `value_cloned`...\n    let _borrow = &mut value;\n    // ... which means we can still use `value_cloned`,\n    let _sum = value_cloned + 1;\n    // even though the borrow only ends here.\n}\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/stable/book/references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":3998,"byte_end":4004,"line_start":138,"line_end":138,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut v;","highlight_start":17,"highlight_end":23}],"label":"borrow of `v` occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":4957,"byte_end":4958,"line_start":158,"line_end":158,"column_start":28,"column_end":29,"is_primary":true,"text":[{"text":"            &[_, _, .., _, x] => println!(\"{}\", x),","highlight_start":28,"highlight_end":29}],"label":"use of borrowed `v`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":5227,"byte_end":5228,"line_start":163,"line_end":163,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `v[..]` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:158:28\n   |\nLL |         let x = &mut v;\n   |                 ------ borrow of `v` occurs here\n...\nLL |             &[_, _, .., _, x] => println!(\"{}\", x),\n   |                            ^ use of borrowed `v`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:47:58] {"message":"cannot use `v[..]` because it was mutably borrowed","code":{"code":"E0503","explanation":"\nA value was used after it was mutably borrowed.\n\nExample of erroneous code:\n\n```compile_fail,E0503\nfn main() {\n    let mut value = 3;\n    // Create a mutable borrow of `value`. This borrow\n    // lives until the end of this function.\n    let _borrow = &mut value;\n    let _sum = value + 1; // error: cannot use `value` because\n                          //        it was mutably borrowed\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust's mutabis_primary":true,"text":[{"text":"            E::A(ref ax) =>","highlight_start":13,"highlight_end":25}],"label":"use of borrowed `e`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7278,"byte_end":7279,"line_start":212,"line_end":212,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `e` because it was mutably borrowed\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:202:13\n   |\nLL |         let x = &mut e;\n   |                 ------ borrow of `e` occurs here\nLL |         match e {\nLL |             E::A(ref ax) =>\n   |             ^^^^^^^^^^^^ use of borrowed `e`\n...\nLL |         drop(x);\n   |              - borrow later used here\n\n"}
[00:47:58] {"message":"cannot borrow `e.0` as immutable because it is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nva","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:221:22\n   |\nLL |         let x = &mut s;\n   |                 ------ mutable borrow occurs here\nLL |         match s {\nLL |             S  { y: (ref y0, _), .. } =>\n   |                      ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow later used here\n\n"}
[00:47:58] {"message":"cannot borrow `s.x.y` as immutable because it is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7890,"byte_end":7896,"line_start":228,"line_end":228,"column_start":28,"column_end":34,"is_primary":true,"text":[{"text":"            S  { x: F { y: ref x0, .. }, .. } =>","highlight_start":28,"highlight_end":34}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":7473,"byte_end":7479,"line_start":219,"line_end":219,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let x = &mut s;","highlight_start":17,"highlight_end":23}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs","byte_start":8230,"byte_end":8231,"line_start":234,"line_end":234,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":"        drop(x);","highlight_start":14,"highlight_end":15}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-describe-lvalue.rs:228:28\n   |\nLL |         let x = &mut s;\n   |                 ------ mutable borrow occurs here\n...\nLL |             S  { x: F { y: ref x0, .. }, .. } =>\n   |                            ^^^^^^ immutable borrow occurs here\n...\nLL |         drop(x);\n   |              - mutable borrow later used here\n\n"}
[00:47:58] {"message":"cannot use `*v` because it was mutably borrowed","code":{"code":"E0503"`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\n 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-issue-48962.rs","byte_start":660,"byte_end":663,"line_start":25,"line_end":25,"column_start":6,"column_end":9,"is_primary":false,"text":[{"text":"    {src};","highlight_start":6,"highlight_end":9}],"label":"value moved here","suggested_replacement":null,"sugting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:47:58] {"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:47:58] ------------------------------------------
[00:47:58] 
[00:47:58] thread '[ui] ui/borrowck/borrowck-move-moved-value-into-closure.rs#mir' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3252:9
[00:47:58] 
[00:47:58] 
[00:47:58] ---- [ui] ui/borrowck/borrowck-move-out-from-array.rs#mir stdout ----
[00:47:58] diff of stderr:
[00:47:58] 
[00:47:58] 4 LL |     let [_, _x] = a;
[00:47:58] 5    |             -- value moved here
[00:47:58] 6 LL |     let [.., _y] = a; //[ast]~ ERROR [E0382]
[00:47:58] -    |              ^^ value used here after move
[00:47:58] +    |              ^^ value used here after partial move
[00:47:58] 8 
[00:47:58] 9 error[E0382]: use of moved value: `a[..]`
[00:47:58] 
[00:47:58] 
[00:47:58] 12 LL |     let [_x, _] = a;
[00:47:58] 13    |          -- value moved here
[00:47:58] 14 LL |     let [_y..] = a; //[ast]~ ERROR [E0382]
[00:47:58] -    |          ^^ value used here after move
[00:47:58] +    |          ^^ value used here after partial move
[00:47:58] 17 error: aborting due to 2 previous errors
[00:47:58] 18 
[00:47:58] 
[00:47:58] 
[00:47:58] 
[00:47:58] The actual stderr differed from the expected stderr.
[00:47:58] Actual stderr 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-move-out-from-array.rs","byte_start":840,"byte_end":842,"line_start":26,"line_end":26,"column_start":10,"column_end":12,"is_primary":false,"text":[{"text":"    let [_x, _] = a;","highlight_start":10,"highlight_end":12}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/chec 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,"suggestion_applicability":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 partial move","suggested_replacement":null,"suggestion_applicability":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 partial move\n   |\n   = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait\n\n"}
[00:47:58] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aboove occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `line1.origin`\n  --> /checkout/src/test/ui/borrowck/borrowck-uninit-field-access.rs:39:13\n   |\nLL |     let _moved = line1.origin;\n   |                  ------------ value moved here\nLL |     let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x`\n   |             ^^^^^^^^^^^^^^ value used here after move\n   |\n   = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait\n\n"}
[00:47:58] {"message":"use of moved value: `line2`","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 = cath `#[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_n to `t.1`, as `t` is not declared as mutable","code":{"code":"E0594","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs","byte_start":748,"byte_end":755,"line_start":27,"line_end":27,"column_start":9,"column_end":16,"is_primary":true,"text":[{"text":"        t.1 = 2;","highlight_start":9,"highlight_end":16}],"label":"cannot assign","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider changing this to be mutable","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs","byte_start":441,"byte_end":442,"line_start":21,"line_end":21,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"        let t: Tuple = (S(0), 0);","highlight_start":13,"highlight_end":14}],"label":null,"suggested_replacement":"mut t","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0594]: cannot assign to `t.1`, as `t` is not declared as mutable\n  --> /checkout/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs:27:9\n   |\nLL |         let t: Tuple = (S(0), 0);\n   |             - help: consider changing this to be mutable: `mut t`\n...\nLL |         t.1 = 2;\n   |         ^^^^^^^ cannot assign\n\n"}
[00:47:58] {"message":"cannot assign to `u.0`, as `u` is not declared as mutable","code":{"code":"E0594","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs","byte_start":1164,"by/checkout/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs","byte_start":1788,"byte_end":1789,"line_start":51,"line_end":51,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"        let v: Spair = Spair { x: S(0), y: 0 };","highlight_start":13,"highlight_end":14}],"label":null,"suggested_replacement":"mut v","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0594]: cannot assign to `v.x`, as `v` is not declared as mutable\n  --> /checkout/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs:53:9\n   |\nLL |         let v: Spair = Spair { x: S(0), y: 0 };\n   |             - help: consider changing this to be mutable: `mut v`\nLL |         drop(v);\nLL |         v.x = S(1);\n   |         ^^^^^^^^^^ cannot assign\n\n"}
[00:47:58] {"message":"assign to part of moved value: `v`","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  |
[00:47:58] 13 LL |         f(f(10));
[00:47:58] -    |         - ^ value used here after move
[00:47:58] +    |         - ^ value used here after partial move
[00:47:58] 16    |         value moved here
[00:47:58] 17 
[00:47:58] 
[00:47:58] 40   --> $DIR/two-phase-nonrecv-autoref.rs:95:11
[00:47:58] 40   --> $DIR/two-phase-nonrecv-autoref.rs:95:11
[00:47:58] 41    |
[00:47:58] 42 LL |         f(f(10));
[00:47:58] -    |         - ^ value used here after move
[00:47:58] +    |         - ^ value used here after partial move
[00:47:58] 45    |         value moved here
[00:47:58] 46 
[00:47:58] 
[00:47:58] 
[00:47:58] 
[00:47:58] The actual stderr differed from the expected stderr.
[00:47:58] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-nonrecv-autoref.nll/two-phase-nonrecv-autoref.nll.stderr
[00:47:58] To update references, rerun the tests and pass the `--bless` flag
[00:47:58] To only update this specific test, also pass `--test-args borrowck/two-phase-nonrecv-autoref.rs`
[00:47:58] 
[00:47:58] error in revision `nll`: 1 errors occurred comparing output.
[00:47:58] status: exit code: 1
[00:47:58] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "nll" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/two-phase-nonrecv-autoref.nll/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "borrow,"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3496,"byte_end":3497,"line_start":86,"line_end":86,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"        f(f(10));","highlight_start":11,"highlight_end":12}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs","byte_start":3494,"byte_end":3495,"line_start":86,"line_end":86,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        f(f(10));","highlight_start":9,"highlight_end":10}],"label":"first borrow later used by call","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0499]: cannot borrow `*f` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs:86:11\n   |\nLL |         f(f(10));\n   |         - ^ second mutable borrow occurs here\n   |         |\n   |         first mutable borrow occurs here\n   |         first borrow later used by call\n\n"}
[00:47:58] {"message":"cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined","code":{"code":"E0161","explanation":"\nA value was moved. However, its size was not known at compile time, and only\nvalues of a known size can be moved.\n\nErroneous code example:\n\n```compile_fail\n#![feature(box_sysrc/test/ui/borrowck/two-phase-nonrecv-autoref.rs:173:7\n   |\nLL |     i[i[3]] = i[4];\n   |     --^----\n   |     | |\n   |     | immutable borrow occurs here\n   |     mutable borrow occurs here\n   |     mutable borrow later used here\n\n"}
[00:47:58] {"message":"aborting due to 9 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 9 previous errors\n\n"}
[00:47:58] {"message":"Some errors occurred: E0161, E0382, E0499, E0502.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0161, E0382, E0499, E0502.\n"}
[00:47:58] {"message":"For more information about an error, try `rustc --explain E0161`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0161`.\n"}
[00:47:58] ------------------------------------------
[00:47:58] 
[00:47:58] thread '[ui] ui/borrowck/two-phase-nonrecv-autoref.rs#nll' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3252:9
[00:47:58] 
[00:47:58] 
[00:47:58] ---- [ui] ui/issues/issue-29723.rs stdout ----
[00:47:58] diff of stderr:
[00:47:58] 
[00:47:58] 5    |                     - value moved here
[00:47:58] 6 ...
[00:47:58] 7 LL |             s
[00:47:58] -    |             ^ value used here after move
[00:47:58] +    |             ^ value used here after partial move
[00:47:58] 9    |
[00:47:58] 10    = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
[00:47:58] 
[00:47:58] 
[00:47:58] The actual stderr differed from the expected stderr.
58] stdout:
58] stdout:
[00:47:58] ------------------------------------------
[00:47:58] 
[00:47:58] ------------------------------------------
[00:47:58] stderr:
[00:47:58] ------------------------------------------
[00:47:58] {"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 exe_mut();\n   |     - mutable borrow later used here\n\n"}
[00:47:58] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/stable/book/references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":718,"byte_end":724,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"    let r = &mut x;","highlight_start":13,"highlight_end":19}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":730,"byte_end":732,"line_start":23,"line_end":23,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || x = 2; //~ ERROR","highlight_start":5,"highlight_end":7}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":73ine_end":35,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    move || x; //~ ERROR","highlight_start":13,"highlight_end":14}],"label":"use of borrowed `x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/closure-access-spans.rs","byte_start":985,"byte_end":986,"line_start":36,"line_end":36,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    r.use_ref();","highlight_start":5,"highlight_end":6}],"label":"borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0503]: cannot use `x` because it was mutably borrowed\n  --> /checkout/src/test/ui/nll/closure-access-spans.rs:35:13\n   |\nLL |     let r = &mut x;\n   |             ------ borrow of `x` occurs here\nLL |     move || x; //~ ERROR\n   |             ^ use of borrowed `x`\nLL |     r.use_ref();\n   |     - borrow later used here\n\n"}
[00:47:58] {"message":"cannot move out of `x` because it is borrowed","code":{"code":"E0505","explanation":"\nA value was moved out while it was still borrowed.\n\nErroneous code example:\n\n```compile_fail,E0505\nstruct Value {}\n\nfn eat(val: Value) {}\n\nfn main() {\n    let x = Value{};\n    {\n        let _ref_to_val: &Value = &x;\n        eat(x);\n    }\n}\n```\n\nHere, the function `eat` takes the ownership of `x`. However,\n`x` cannot be moved because it was borrowed to `_ref_to_val`.\nTo fix that you can do few different things:\n\n* Try to avoid moving the variable.\n* Release borrow before move.\n* Implement the `Copy` trait on the type.\n\ntart":1469,"byte_end":1471,"line_start":62,"line_end":62,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":"    || x; //~ ERROR","highlight_start":5,"highlight_end":7}],"label":"value used here after partial move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `x` has type `&mut std::string::String`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `x`\n  --> /checkout/src/test/ui/nll/closure-access-spans.rs:62:5\n   |\nLL |     let r = x;\n   |             - value moved here\nLL |     || x; //~ ERROR\n   |     ^^ - use occurs due to use in closure\n   |     |\n   |     value used here after partial move\n   |\n   = note: move occurs because `x` has type `&mut std::string::String`, which does not implement the `Copy` trait\n\n"}
[00:47:58] {"message":"aborting due to 9 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 9 previous errors\n\n"}
[00:47:58] {"message":"Some errors occurred: E0382, E0499, E0500, E0502, E0503, E0505.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0382, E0499, E0500, E0502, E0503, E0505.\n"}
[00:47:58] {"message":"For more information about an error, try `rustc --explain E0382`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0382`.\n"}
[00:47:58] ------------------------------------------
[00:47:58] 
[00:47:58] 
[00:47:58] thread '[()` 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 apt":644,"byte_end":658,"line_start":23,"line_end":23,"column_start":5,"column_end":19,"is_primary":false,"text":[{"text":"    $wrapper.inner","highlight_start":5,"highlight_end":19}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/nll/decl-macro-illegal-copy.rs","byte_start":780,"byte_end":800,"line_start":31,"line_end":31,"column_start":9,"column_end":29,"is_primary":false,"text":[{"text":"        inner_copy!(wrapper),","highlight_start":9,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"inner_copy!","def_site_span":{"file_name":"/checkout/src/test/ui/nll/decl-macro-illegal-copy.rs","byte_start":605,"byte_end":660,"line_start":22,"line_end":24,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro inner_copy($wrapper:ident) {","highlight_start":1,"highlight_end":35},{"text":"    $wrapper.inner","highlight_start":1,"highlight_end":19},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/nll/decl-macro-illegal-copy.rs","byte_start":810,"byte_end":823,"line_start":32,"line_end":32,"column_start":9,"column_end":22,"is_primary":true,"text":[{"text":"        wrapper.inner,","highlight_start":9,"highlight_end":22}],"label":"value used here after partial move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `wrapper.inner` has type `NonCot in this case. We can mark our own types `Copy` if\nall their members also are marked `Copy`.\n\nIn the example below, we implement a `Point` type. Because it only stores two\nintegers, we opt-out of ownership semantics with `Copy`. Then we can\n`let p2 = p1` without `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n    let mut p1 = Point{ x: -1, y: 2 };\n    let p2 = p1;\n    p1.x = 1;\n    println!(\"p1: {}, {}\", p1.x, p1.y);\n    println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don't control the struct's definition, or mutable shared\nownership is truly required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the chapter in the\nBook:\n\nhttps://doc.rust-lang.org/book/first-edition/ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.rs","byte_start":1516,"byte_end":1517,"line_start":61,"line_end":61,"column_start":10,"column_end":11,"is_primary":false,"text":[{"text":"    drop(d);","highlight_start":10,"highlight_end":11}],"label":"value moved h   ^^^^^^^^ use of possibly uninitialized `t`\n\n"}
[00:47:58] {"message":"assign to part of moved value: `s`","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 removue-21232-partial-init-and-use.rs","byte_start":4124,"byte_end":4132,"line_start":141,"line_end":141,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":"    s.x = 10;","highlight_start":5,"highlight_end":13}],"label":"value partially assigned here after partial move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `s` has type `S<std::boxed::Box<u32>>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: assign to part of moved value: `s`\n  --> /checkout/src/test/ui/nll/issue-21232-partial-init-and-use.rs:141:5\n   |\nLL |     let mut s: S<B> = S::new(); drop(s);\n   |                                      - value moved here\nLL |     s.x = 10;\n   |     ^^^^^^^^ value partially assigned here after partial move\n   |\n   = note: move occurs because `s` has type `S<std::boxed::Box<u32>>`, which does not implement the `Copy` trait\n\n"}
[00:47:58] {"message":"assign to part of moved value: `t`","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 variabe of possibly uninitialized variable\n}\n```\n\nTo fix this, ensure that any declared variables are initialized before being\nused. Example:\n\n```\nfn main() {\n    let x: i32 = 0;\n    let y = x; // ok!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/issue-21232-partial-init-and-use.rs","byte_start":5557,"byte_end":5569,"line_start":185,"line_end":185,"column_start":5,"column_end":17,"is_primary":true,"text":[{"text":"    q.r.f.0 = 10; q.r.f.1 = Box::new(20);","highlight_start":5,"highlight_end":17}],"label":"use of possibly uninitialized `q.r.f`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0381]: assign to part of possibly uninitialized variable: `q`\n  --> /checkout/src/test/ui/nll/issue-21232-partial-init-and-use.rs:185:5\n   |\nLL |     q.r.f.0 = 10; q.r.f.1 = Box::new(20);\n   |     ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f`\n\n"}
[00:47:58] {"message":"assign to part of moved value: `q.r`","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 referenceuct { s: u32 }\n\nfn main() {\n    let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n    let y = x.clone();\n    x.borrow_mut().s = 6;\n    println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the chapter in the\nBook:\n\nhttps://doc.rust-lang.org/book/first-edition/ownership.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/issue-21232-partial-init-and-use.rs","byte_start":6682,"byte_end":6685,"line_start":219,"line_end":219,"column_start":49,"column_end":52,"is_primary":false,"text":[{"text":"    let mut q: Q<S<B>> = Q::new(S::new()); drop(q.r);","highlight_start":49,"highlight_end":52}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/issue-21232-partial-init-and-use.rs","byte_start":6692,"byte_end":6704,"line_start":220,"line_end":220,"column_start":5,"column_end":17,"is_primary":true,"text":[{"text":"    q.r.f.x = 10;","highlight_start":5,"highlight_end":17}],"label":"value partially assigned here after move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `q.r` has type `R<S<std::boxed::Box<u32>>>`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E5u32 };\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 47:58] 
[00:47:58] status: exit code: 1
[00:47:58] status: exit code: 1
[00:47:58] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/issue-52669.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-52669/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-52669/auxiliary" "-A" "unused"
[00:47:58] ------------------------------------------
[00:47:58] 
[00:47:58] ------------------------------------------
[00:47:58] stderr:
[00:47:58] stderr:
[00:47:58] ------------------------------------------
[00:47:58] {"message":"borrow of moved value: `a.b`","code":{"code":"E0382","explanation":"\nThis error occurs when an attempt is made to use a variable after its contents\nhave been moved elsewhere. For example:\n\n```compile_fail,E0382\nstruct MyStruct { s: u32 }\n\nfn main() {\n    let mut x = MyStruct{ s: 5u32 };\n    let y = x;\n    x.s = 6;\n    println!(\"{}\", x.s);\n}\n```\n\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\nof `x` when we set `y`. This is fundamental to Rust's ownership system: outside\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\n\nSometimes we don't need to move the value. Using a reference, we can let another\nfunction borrow the value without changing its ownership. In the example below,\nwe don't actually have to m```\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/try-block/try-block-bad-lifetime.rs","byte_start":1308,"byte_end":1309,"line_start":38,"line_end":38,"column_start":17,"column_end":18,"is_primary":false,"text":[{"text":"            Err(k) ?;","highlight_start":17,"highlight_end":18}],"label":"value moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-lifetime.rs","byte_start":1424,"byte_end":1425,"line_start":41,"line_end":41,"column_start":26,"column_end":27,"is_primary":true,"text":[{"text":"        ::std::mem::drop(k); //~ ERROR use of moved value: `k`","highlight_start":26,"highlight_end":27}],"label":"value used here after partial move","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[],"children":[0:47:58] 
[00:47:58] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:47:58] Build completed unsuccessfully in 0:03:54
[00:47:58] Build completed unsuccessfully in 0:03:54
[00:47:58] make: *** [check] Error 1
[00:47:58] Makefile:58: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0d08d050
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Dec 14 11:40:23 UTC 2018

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

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

This is a good start, just need to check for a partial move.

desired_action.as_verb_in_past_tense()
),
);
if used_place.is_prefix_of(&moved_place) {
Copy link
Member

Choose a reason for hiding this comment

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

You should be checking that if, for any of the MoveSite in move_site_vec, the Place associated with that MoveSite is a prefix of used_place. I describe how to get the Place for a MoveSite in the mentor instructions.

err.span_label(
span,
format!(
"value {} here after partial move",
Copy link
Member

Choose a reason for hiding this comment

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

Would you be able to change the message based on an if rather than the entire span_label call? ie.

err.span_label(
    span,
    format!(
        "value {} here{}",
        desired_action.as_verb_in_past_tense(),
        if is_partial_move { " after partial move" } else { "" },
    )
);

@Dylan-DPC-zz Dylan-DPC-zz 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 Dec 14, 2018
@davidtwco
Copy link
Member

@Dylan-DPC are you still working on this and able to address the feedback?

@Dylan-DPC-zz
Copy link
Author

@davidtwco was working on something else, will get back to it in a few days

@XAMPPRocky
Copy link
Member

Triage; @Dylan-DPC Hello, have you been able to get back to this PR?

@Dylan-DPC-zz
Copy link
Author

@Aaronepower will work on it this week

@TimNN
Copy link
Contributor

TimNN commented Jan 22, 2019

Ping from triage @Dylan-DPC: What is the status of this PR?

@Dylan-DPC-zz
Copy link
Author

@TimNN thanks. this week or i'll close it myself and work on it in the future. 👍

@davidtwco
Copy link
Member

Going to close this as it seems this is being handled by someone else. Feel free to re-open.

@davidtwco davidtwco closed this Jan 28, 2019
@Dylan-DPC-zz Dylan-DPC-zz deleted the feature/missing-note branch April 1, 2020 20:28
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.

NLL Diagnostic Review 3: missing indication that a "partial move" has occurred
6 participants