{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/54343","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/54343/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/54343/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/54343/events","html_url":"https://github.com/rust-lang/rust/pull/54343","id":361578086,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NTE0MDAy","number":54343,"title":"[Work in progress] First shot at rust-lang/rust/issues/54015","user":{"login":"blitzerr","id":28721905,"node_id":"MDQ6VXNlcjI4NzIxOTA1","avatar_url":"https://avatars0.githubusercontent.com/u/28721905?v=4","gravatar_id":"","url":"https://api.github.com/users/blitzerr","html_url":"https://github.com/blitzerr","followers_url":"https://api.github.com/users/blitzerr/followers","following_url":"https://api.github.com/users/blitzerr/following{/other_user}","gists_url":"https://api.github.com/users/blitzerr/gists{/gist_id}","starred_url":"https://api.github.com/users/blitzerr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blitzerr/subscriptions","organizations_url":"https://api.github.com/users/blitzerr/orgs","repos_url":"https://api.github.com/users/blitzerr/repos","events_url":"https://api.github.com/users/blitzerr/events{/privacy}","received_events_url":"https://api.github.com/users/blitzerr/received_events","type":"User","site_admin":false},"labels":[{"id":604489711,"node_id":"MDU6TGFiZWw2MDQ0ODk3MTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-NLL","name":"A-NLL","color":"d7e102","default":false},{"id":867465998,"node_id":"MDU6TGFiZWw4Njc0NjU5OTg=","url":"https://api.github.com/repos/rust-lang/rust/labels/NLL-diagnostics","name":"NLL-diagnostics","color":"f799ea","default":false},{"id":583436937,"node_id":"MDU6TGFiZWw1ODM0MzY5Mzc=","url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-author","name":"S-waiting-on-author","color":"d3dddd","default":false}],"state":"open","locked":false,"assignee":{"login":"nikomatsakis","id":155238,"node_id":"MDQ6VXNlcjE1NTIzOA==","avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"assignees":[{"login":"nikomatsakis","id":155238,"node_id":"MDQ6VXNlcjE1NTIzOA==","avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false}],"milestone":null,"comments":11,"created_at":"2018-09-19T04:54:54Z","updated_at":"2018-09-28T12:37:35Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/54343","html_url":"https://github.com/rust-lang/rust/pull/54343","diff_url":"https://github.com/rust-lang/rust/pull/54343.diff","patch_url":"https://github.com/rust-lang/rust/pull/54343.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/425422067","html_url":"https://github.com/rust-lang/rust/pull/54343#issuecomment-425422067","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/54343","id":425422067,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTQyMjA2Nw==","user":{"login":"rust-highfive","id":7378925,"node_id":"MDQ6VXNlcjczNzg5MjU=","avatar_url":"https://avatars3.githubusercontent.com/u/7378925?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-highfive","html_url":"https://github.com/rust-highfive","followers_url":"https://api.github.com/users/rust-highfive/followers","following_url":"https://api.github.com/users/rust-highfive/following{/other_user}","gists_url":"https://api.github.com/users/rust-highfive/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-highfive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-highfive/subscriptions","organizations_url":"https://api.github.com/users/rust-highfive/orgs","repos_url":"https://api.github.com/users/rust-highfive/repos","events_url":"https://api.github.com/users/rust-highfive/events{/privacy}","received_events_url":"https://api.github.com/users/rust-highfive/received_events","type":"User","site_admin":false},"created_at":"2018-09-28T12:37:35Z","updated_at":"2018-09-28T12:37:35Z","author_association":"COLLABORATOR","body":"\nThe job `x86_64-gnu-llvm-5.0` of your PR [failed on Travis](https://travis-ci.org/rust-lang/rust/jobs/434577633) ([raw log](https://api.travis-ci.org/v3/job/434577633/log.txt)). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.\n\n<details><summary><i>Click to expand the log.</i></summary>\n\n```plain\n[00:46:32] running 4308 tests\n[00:46:35] ....................................................................................................\n[00:46:38] ....................................................................................................\n[00:46:41] ....................................................................................................\n[00:46:44] ....................F......................................................................F........\n[00:46:50] .......................i............................................................................\n[00:46:55] ....................................................................................................\n[00:47:00] ................................i...........i.......................................................\n[00:47:03] ...................................................iiiii............................................\n---\n[00:47:50] ....................................................................................................\n[00:47:54] ................................................................................................i...\n[00:47:57] ....................................................................................................\n[00:48:00] ........................................................i.i..ii.....................................\n[00:48:03] ..............................................F.....................................................\n[00:48:10] ....................................................................................................\n[00:48:13] ....................................................................................................\n[00:48:15] ....................................................................................................\n[00:48:18] ....................................................................................................\n---\n[00:48:45] \n[00:48:45] ---- [ui] ui/borrowck/borrowck-mut-borrow-linear-errors.rs#mir stdout ----\n[00:48:45] diff of stderr:\n[00:48:45] \n[00:48:45] 4 LL |             1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\n[00:48:45] 5    |                    ----      ^^^^^^ second mutable borrow occurs here\n[00:48:45] -    |                    borrow used here in later iteration of loop\n[00:48:45] -    |                    borrow used here in later iteration of loop\n[00:48:45] +    |                    borrow used here, in later iteration of loop\n[00:48:45] 8 ...\n[00:48:45] 9 LL |             _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\n[00:48:45] 10    |                              ------ first mutable borrow occurs here\n[00:48:45] 13   --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30\n[00:48:45] 14    |\n[00:48:45] 14    |\n[00:48:45] 15 LL |             1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\n[00:48:45] -    |                    ---- borrow used here in later iteration of loop\n[00:48:45] +    |                    ---- borrow used here, in later iteration of loop\n[00:48:45] 17 LL |             //[mir]~^ ERROR [E0499]\n[00:48:45] 18 LL |             2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\n[00:48:45] 19    |                              ^^^^^^ second mutable borrow occurs here\n[00:48:45] \n[00:48:45] The actual stderr differed from the expected stderr.\n[00:48:45] The actual stderr differed from the expected stderr.\n[00:48:45] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir/bome\\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-mut-borrow-linear-errors.rs\",\"byte_start\":1066,\"byte_end\":1072,\"line_start\":27,\"line_end\":27,\"column_start\":30,\"column_end\":36,\"is_primary\":false,\"text\":[{\"text\":\"            _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\",\"highlight_start\":30,\"highlight_end\":36}],\"label\":\"first mutable borrow occurs here\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null},{\"file_name\":\"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs\",\"byte_start\":868,\"byte_end\":874,\"line_start\":23,\"line_end\":23,\"column_start\":30,\"column_end\":36,\"is_primary\":true,\"text\":[{\"text\":\"            1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\",\"highlight_start\":30,\"highlight_end\":36}],\"label\":\"second mutable borrow occurs here\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null},{\"file_name\":\"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs\",\"byte_start\":858,\"byte_end\":862,\"line_start\":23,\"line_end\":23,\"column_start\":20,\"column_end\":24,\"is_primary\":false,\"text\":[{\"text\":\"            1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\",\"highlight_start\":20,\"highlight_end\":24}],\"label\":\"borrow used here, in la        _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\",\"highlight_start\":30,\"highlight_end\":36}],\"label\":\"first mutable borrow occurs here\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null},{\"file_name\":\"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs\",\"byte_start\":967,\"byte_end\":973,\"line_start\":25,\"line_end\":25,\"column_start\":30,\"column_end\":36,\"is_primary\":true,\"text\":[{\"text\":\"            2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\",\"highlight_start\":30,\"highlight_end\":36}],\"label\":\"second mutable borrow occurs here\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null},{\"file_name\":\"/checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs\",\"byte_start\":858,\"byte_end\":862,\"line_start\":23,\"line_end\":23,\"column_start\":20,\"column_end\":24,\"is_primary\":false,\"text\":[{\"text\":\"            1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\",\"highlight_start\":20,\"highlight_end\":24}],\"label\":\"borrow used here, in later iteration of loop\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null}],\"children\":[],\"rendered\":\"error[E0499]: cannot borrow `x` as mutable more than once at a time\\n  --> /checkout/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs:25:30\\n   |\\nLL |             1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\\n   |                    ---- borrow used here, in later iteration of loop\\nLL |             //[mir]~^ ERROR [E0499]\\nLL |             2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]\\n   |                              ^^^^^^ second mutable borrow occurs here\\nLL |                                       ^^^^^^ mutable borrow starts here in previous iteration of loop\\n\\n\"}\n[00:48:45] {\"message\":\"aborting due to 3 previous errors\",\"code\":null,\"level\":\"error\",\"spans\":[],\"children\":[],\"rendered\":\"error: aborting due to 3 previous errors\\n\\n\"}\n[00:48:45] {\"message\":\"For more information about this error, try `rustc --explain E0499`.\",\"code\":null,\"level\":\"\",\"spans\":[],\"children\":[],\"rendered\":\"For more information about this error, try `rustc --explain E0499`.\\n\"}\n[00:48:45] ------------------------------------------\n[00:48:45] \n[00:48:45] thread '[ui] ui/borrowck/borrowck-mut-borrow-linear-errors.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3258:9\n[00:48:45] note: Run with `RUST_BACKTRACE=1` for a backtrace.\n[00:48:45] note: Run with `RUST_BACKTRACE=1` for a backtrace.\n[00:48:45] \n[00:48:45] ---- [ui] ui/borrowck/issue-41962.rs stdout ----\n[00:48:45] diff of stderr:\n[00:48:45] \n[00:48:45] 20   --> $DIR/issue-41962.rs:17:21\n[00:48:45] 21    |\n[00:48:45] 22 LL |         if let Some(thing) = maybe {\n[00:48:45] -    |                     ^^^^^ value moved here in previous iteration of loop\n[00:48:45] +    |                     ^^^^^ value moved here, in previous iteration of loop\n[00:48:45] 24    |\n[00:48:45] 25    = note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait\n[00:48:45] \n[00:48:45] \n[00:48:45] The actual stderr differed from the expected stderr.\n[00:48:45] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/issue-41962/issue-41962.stderr\n[00:48:45] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/issue-41962/issue-41962.stderr\n[00:48:45] To update references, rerun the tests and pass the ed 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/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,\"suggestion_applicability\":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\"}\n[00:48:45] {\"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   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,\"suggestion_applicability\":null,\"expansion\":null}],\"children\":[{\"message\":\"move occurs because 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 (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 value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait\\n\\n\"}\n[00:48:45] {\"message\":\"aborting due to 3 previous errors\",\"code\":null,\"level\":\"error\",\"spans\":[],\"children\":[],\"rendered\":\"error: aborting due to 3 previous errors\\n\\n\"}\n[00:48:45] {\"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\"}\n[00:48:45] ------------------------------------------\n[00:48:45] \n[00:48:45] thread '[ui] ui/borrowck/issue-41962.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3258:9\n[00:48:45] \n[00:48:45] \n[00:48:45] ---- [ui] ui/nll/closures-in-loops.rs stdout ----\n[00:48:45] diff of stderr:\n[00:48:45] \n[00:48:45] 4 LL |         || x; //~ ERROR\n[00:48:45] 5    |         ^^ - use occurs due to use in closure\n[00:48:45] 6    |         |\n[00:48:45] -    |         value moved into closure here in previous iteration of loop\n[00:48:45] +    |         value moved into closure here, in previous iteration of loop\n[00:48:45] 8    |\n[00:48:45] 9    = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait\n[00:48:45] \n[00:48:45] \n[00:48:45] The actual stderr differed from the expected stderr.\n[00:48:45] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closures-in-loops/closures-in-loops.stderr\n[00:48:45] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closures-in-loops/closures-in-loops.stderr\n[00:48:45] To update references, rerun the tests and pass the `--bless` flag\n[00:48:45] To only update this specific test, also pass `--test-args nll/closures-in-loops.rs`\n[00:48:45] error: 1 errors occurred comparing output.\n[00:48:45] status: exit code: 1\n[00:48:45] status: exit code: 1\n[00:48:45] command: \"/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc\" \"/checkout/src/test/ui/nll/closures-in-loops.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/closures-in-loops/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/closures-in-loops/auxiliary\" \"-A\" \"unused\"\n[00:48:45] ------------------------------------------\n[00:48:45] \n[00:48:45] ------------------------------------------\n[00:48:45] stderr:\n[00:48:45] stderr:\n[00:48:45] ------------------------------------------\n[00:48:45] {\"message\":\"use of moved value: `x`\",\"code\":{\"code\":\"E0382\",\"explanation\":\"\\nThis error occurs when an attempt is made to use a variable after its contents\\nhave been moved elsewhere. For example:\\n\\n```compile_fail,E0382\\nstruct MyStruct { s: u32 }\\n\\nfn main() {\\n    let mut x = MyStruct{ s: 5u32 };\\n    let y = x;\\n    x.s = 6;\\n    println!(\\\"{}\\\", x.s);\\n}\\n```\\n\\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\\nof `x` when we set `y`. This is fundamental to Rust's ownership system: outside\\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\\n\\nSometimes we don't need to move the value. Using a refpe. 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/closures-in-loops.rs\",\"byte_start\":636,\"byte_end\":638,\"line_start\":18,\"line_end\":18,\"column_start\":9,\"column_end\":11,\"is_primary\":true,\"text\":[{\"text\":\"        || x; //~ ERROR\",\"highlight_start\":9,\"highlight_end\":11}],\"label\":\"value moved into closure here, in previous iteration of loop\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null},{\"file_name\":\"/checkout/src/test/ui/nll/closures-in-loops.rs\",\"byte_start\":639,\"byte_end\":640,\"line_start\":18,\"line_end\":18,\"column_start\":12,\"column_end\":13,\"is_primary\":false,\"text\":[{\"text\":\"        || x; //~ ERROR\",\"highlight_start\":12,\"highlight_end\":13}],\"label\":\"use occurs due to use in closure\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null}],\"children\":[{\"message\":\"move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait\",\"code\":null,\"level\":\"note\",\"spans\":[],\"children\":[],\"rendered\":null}],\"rendered\":\"error[E0382]: use of moved value: `x`\\n  --> /checkout/src/test/ui/nll/closures-in-loops.rs:18:9\\n   |\\nLL |         || x; //~ ERROR\\n   |         ^^ - use occurs due to use in closure\\n   |         |\\n   |         value moved into closure here, in previous iteration of loop\\n   |\\n   = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait\\n\\n\"}\n[00:48:45] {\"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= String::new()); //~ ERROR\",\"highlight_start\":16,\"highlight_end\":18}],\"label\":\"closures are constructed here in different iterations of loop\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null},{\"file_name\":\"/checkout/src/test/ui/nll/closures-in-loops.rs\",\"byte_start\":921,\"byte_end\":922,\"line_start\":32,\"line_end\":32,\"column_start\":20,\"column_end\":21,\"is_primary\":false,\"text\":[{\"text\":\"        v.push(|| *x = String::new()); //~ ERROR\",\"highlight_start\":20,\"highlight_end\":21}],\"label\":\"borrows occur due to use of `x` in closure\",\"suggested_replacement\":null,\"suggestion_applicability\":null,\"expansion\":null}],\"children\":[],\"rendered\":\"error[E0524]: two closures require unique access to `x` at the same time\\n  --> /checkout/src/test/ui/nll/closures-in-loops.rs:32:16\\n   |\\nLL |         v.push(|| *x = String::new()); //~ ERROR\\n   |                ^^  - borrows occur due to use of `x` in closure\\n   |                |\\n   |                closures are constructed here in different iterations of loop\\n\\n\"}\n[00:48:45] {\"message\":\"aborting due to 3 previous errors\",\"code\":null,\"level\":\"error\",\"spans\":[],\"children\":[],\"rendered\":\"error: aborting due to 3 previous errors\\n\\n\"}\n[00:48:45] {\"message\":\"Some errors occurred: E0382, E0499, E0524.\",\"code\":null,\"level\":\"\",\"spans\":[],\"children\":[],\"rendered\":\"Some errors occurred: E0382, E0499, E0524.\\n\"}\n[00:48:45] {\"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\"}\n[00:48:45] \n[00:48:45] -------------------path\" \"adb\" \"--adb-test-dir\" \"/data/tmp/work\" \"--android-cross-path\" \"\" \"--color\" \"always\"\n[00:48:45] \n[00:48:45] \n[00:48:45] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test\n[00:48:45] Build completed unsuccessfully in 0:03:16\n[00:48:45] Build completed unsuccessfully in 0:03:16\n[00:48:45] Makefile:58: recipe for target 'check' failed\n[00:48:45] make: *** [check] Error 1\n\nThe command \"stamp sh -x -c \"$RUN_SCRIPT\"\" exited with 2.\ntravis_time:start:116b0c36\n$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)\n```\n\n</details><p></p>\n\n[I'm a bot](https://github.com/rust-ops/rust-log-analyzer)! 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](https://github.com/rust-ops/rust-log-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request))\n        "}}
{"actor":{"display_login":"rust-highfive"}}