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

Fix variable does not need to be mutable warning #54621

Closed
wants to merge 2 commits into from

Conversation

spastorino
Copy link
Member

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 27, 2018
// requirement that `T: 'static`. This arose because we actually had
// to propagate both that `T: 'a` but also `T: 'b` where `'b` is the
// higher-ranked lifetime that appears in the type of the closure
// parameter `x` -- since `'b` cannot be expressed in the caller's
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems totally wrong :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh, wrong copy & paste

) {
match root_place {
RootPlace {
place: Place::Local(local),
is_local_mutation_allowed,
is_local_mutation_allowed: _,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just remove this field altogether now?

@rust-highfive

This comment has been minimized.

if flow_state.ever_inits.contains(index) {
self.used_mut.insert(*local);
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So it appears I was a bit aggressive in suggesting that this code be cut entirely. Rather, it should be modified. The goal here is to say: "if we see a = 22 and a was previously initialized, then the mut is needed". That is correct.

The problem here is that the actual assignment was to a.0 and — when a is not initialized — we only permit that if a is declared mutable.

I think that to fix this code we probably need to modify add_used_mut so that it knows both the root_place (as now) and also the place that the user was originally writing to; in that case, we could distinguish between a = 5 (which may not need mut, if a was not previously initialized) and a.0 (which always does).

Annoying.

@nikomatsakis nikomatsakis 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 Sep 28, 2018
@nikomatsakis
Copy link
Contributor

Left more detailed notes on Zulip

@spastorino spastorino force-pushed the invalid-no-need-mut branch 2 times, most recently from 43a346d to 1c74f4a Compare October 3, 2018 19:09
self.used_mut.insert(*local);
break;
match accessed_place {
// FIXME(#21232)
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably we want a comment here, but seems good.

@rust-highfive

This comment has been minimized.

@memoryruins memoryruins added the A-NLL Area: Non Lexical Lifetimes (NLL) label Oct 6, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@spastorino spastorino force-pushed the invalid-no-need-mut branch 3 times, most recently from 622327a to c05bb2b Compare October 9, 2018 19:03
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Great! Left some nits

src/librustc/mir/mod.rs Show resolved Hide resolved

}

if let &Place::Projection(_) = place {
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment:


FIXME(#21232). For now, error if assigning to a projection from an uninitialized local variable -- so e.g. doing a.b = 22 when a is not yet initialized is simply an error. In the future, we could sometimes support this.

if let Some(local) = place.base_local() {
let mpi = self.move_data.rev_lookup.find_local(local);
if flow_state.uninits.contains(mpi) {
self.used_mut.insert(local);
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment:

Pre-emptively insert local into the used_mut set to avoid any warnings related to whether the mut declaration is used.

Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to check whether local is actually declared as mut, something like

if let Mutability::Mut = self.mir.local_decls[local].mutability {
    self.used_mut.insert(local);
}

@rust-highfive

This comment has been minimized.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

One last nit

src/test/ui/nll/issue-54499.rs Show resolved Hide resolved
@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.
[00:49:17] 
[00:49:17] running 4579 tests
[00:49:20] .................................................................................................... 100/4579
[00:49:23] .................................................................................................... 200/4579
[00:49:26] ........................................................................F........................... 300/4579
[00:49:29] ...............................................................F.........F.......................... 400/4579
[00:49:35] .......................i............................................................................ 600/4579
[00:49:40] .................................................................................................... 700/4579
[00:49:45] ...................................i...........i.................................................... 800/4579
[00:49:48] ......................................................iiiii......................................... 900/4579
---
[00:51:45] .................................................................................................... 4400/4579
[00:51:48] .................................................................................................... 4500/4579
the `Copy` trait
[00:51:50] 10 
[00:51:50] + error[E0718]: cannot assign to `src.0` when `src` is not initialized
[00:51:50] +   --> $DIR/borrowck-issue-48962.rs:32:5
[00:51:50] +    |
[00:51:50] + LL |     src.0 = 66; //~ ERROR use of moved value: `src` [E0382]
[00:51:50] + 
[00:51:50] + 
[00:51:50] 11 error[E0382]: use of moved value: `src`
[00:51:50] 13    |
[00:51:50] 
[00:51:50] 18    |
[00:51:50] 18    |
[00:51:50] 19    = note: move occurs because `src` has type `&mut (i32, i32)`, which does not implement the `Copy` trait
[00:51:50] - error: aborting due to 2 previous errors
[00:51:50] + error: aborting due to 4 previous errors
[00:51:50] 22 
[00:51:50] - For more information about this error, try `rustc --explain E0382`.
[00:51:50] - For more information about this error, try `rustc --explain E0382`.
[00:51:50] + Some errors occurred: E0382, E0718.
[00:51:50] + For more information about an error, try `rustc --explain E0382`.
[00:51:50] 24 
[00:51:50] 
[00:51:50] 
[00:51:50] The actual stderr differed from the expected stderr.
[00:51:50] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-issue-48962/borrowck-issue-48962.stderr
[00:51:50] To update references, rerun the tests and pass the `--bless` flag
[00:51:50] To only update this specific test, also pass `--test-args borrowck/borrowck-issue-48962.rs`
[00:51:50] error: 1 errors occurred comparing output.
[00:51:50] status: exit code: 1
[00:51:50] status: exit code: 1
[00:51:50] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-issue-48962.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-issue-48962/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-issue-48962/auxiliary" "-A" "unused"
[00:51:50] ------------------------------------------
[00:51:50] 
[00:51:50] ------------------------------------------
[00:51:50] stderr:
[00:51:50] stderr:
[00:51:50] ------------------------------------------
[00:51:50] {"message":"cannot assign to `src.next` when `src` is not initialized","code":{"code":"E0718","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-issue-48962.rs","byte_start":670,"byte_end":678,"line_start":26,"line_end":26,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":"    src.next = None; //~ ERROR use of moved value: `src` [E0382]","highlight_start":5,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0718]: cannot assign to `src.next` when `src` is not initialized\n  --> /checkout/src/test/ui/borrowck/borrowck-issue-48962.rs:26:5\n   |\nLL |     src.next = None; //~ ERROR use of moved value: `src` [E0382]\n   |     ^^^^^^^^\n\n"}
[00:51:50] {"message":"use of moved value: `src`","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``ement the `Copy` trait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0382]: use of moved value: `src`\n  --> /checkout/src/test/ui/borrowck/borrowck-issue-48962.rs:32:5\n   |\nLL |     {src};\n   |      --- value moved here\nLL |     src.0 = 66; //~ ERROR use of moved value: `src` [E0382]\n   |     ^^^^^^^^^^ value used here after move\n   |\n   = note: move occurs because `src` has type `&mut (i32, i32)`, which does not implement the `Copy` trait\n\n"}
[00:51:50] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:499:22
[00:51:50] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:51:50] {"message":"Some errors occurred: E0382, E0718.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0382, E0718.\n"}
[00:51:50] {"message":"For more information about an error, try `rustc --explain E0382`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0382`.\n"}
[00:51:50] ------------------------------------------
[00:51:50] 
[00:51:50] thread '[ui] ui/borrowck/borrowck-issue-48962.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3267:9
[00:51:50] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:51:50] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:51:50] 
[00:51:50] ---- [ui] ui/borrowck/borrowck-uninit-ref-chain.rs#mir stdout ----
[00:51:50] diff of stderr:
[00:51:50] 
[00:51:50] 16 LL |     let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable:use of possibly uninitialized variable: `**a.y` [E0381]
[00:51:50] 29    |              ^^^^^^ use of possibly uninitialized `**a.y`
[00:51:50] - error: aborting due to 5 previous errors
[00:51:50] + error: aborting due to 9 previous errors
[00:51:50] 32 
[00:51:50] - For more information about this error, try `rustc --explain E0381`.
[00:51:50] - For more information about this error, try `rustc --explain E0381`.
[00:51:50] + Some errors occurred: E0381, E0718.
[00:51:50] + For more information about an error, try `rustc --explain E0381`.
[00:51:50] 34 
[00:51:50] 
[00:51:50] 
[00:51:50] The actual stderr differed from the expected stderr.
[00:51:50] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-uninit-ref-chain.mir/borrowck-uninit-ref-chain.mir.stderr
[00:51:50] To update references, rerun the tests and pass the `--bless` flag
[00:51:50] To only update this specific test, also pass `--test-args borrowck/borrowck-uninit-ref-chain.rs`
[00:51:50] 
[00:51:50] error in revision `mir`: 1 errors occurred comparing output.
[00:51:50] status: exit code: 1
[00:51:50] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.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-uninit-ref-chain.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-uninit-ref-chain.mir/auxiliary" "-A" "unused"
[00:51:50] ------------------------------------------
[00:51:50] 
[00:51:50] ------------------------------------------
[00:51:50] stderr:
[00:51:50] stderr:
[00:51:50] ------------------------------------------
[00:51:50] {"message":"borrow of possibly uninitialized variable: `**x`","code":{"code":"E0381","explanation":"\nIt is not allowed to use or capture an uninitialized variable. For example:\n\n```compile_fail,E0381\nfn main() {\n    let x: i32;\n    let y = x; // error, use 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/borrowck/borrowck-uninit-ref-chain.rs","byte_start":616,"byte_end":620,"line_start":21,"line_end":21,"column_start":14,"column_end":18,"is_primary":true,"text":[{"text":"    let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]","highlight_start":14,"highlight_end":18}],"label":"use of possibly uninitialized `**x`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0381]: borrow of possibly uninitialized variable: `**x`\n  --> /checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs:21:14\n   |\nLL |     let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]\n   |              ^^^^ use of possibly uninitialized `**x`\n\n"}
[00:51:50] {"message":"borrow of possibly uninitialized variable: `**x`","code":{"code":"E0381","":{"code":"E0718","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs","byte_start":1263,"byte_end":1272,"line_start":39,"line_end":39,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    a.x = &&0;","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0718]: cannot assign to `a.x` when `a` is not initialized\n  --> /checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs:39:5\n   |\nLL |     a.x = &&0;\n   |     ^^^^^^^^^\n\n"}
[00:51:50] {"message":"cannot assign to `a.x` when `a` is not initialized","code":{"code":"E0718","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs","byte_start":1473,"byte_end":1480,"line_start":45,"line_end":45,"column_start":5,"column_end":12,"is_primary":true,"text":[{"text":"    a.x = 0;","highlight_start":5,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0718]: cannot assign to `a.x` when `a` is not initialized\n  --> /checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs:45:5\n   |\nLL |     a.x = 0;\n   |     ^^^^^^^\n\n"}
[00:51:50] {"message":"borrow of possibly uninitialized variable: `a.y`","code":{"code":"E0381","explanation":"\nIt is not allowed to use or capture an uninitialized variable. For example:\n\n```compile_fail,E0381\nfn main() {\n    let x: i32;\n    let y = x; // error, use 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/borrowck/borrowck-uninit-ref-chain.rs","byte_start":1495,"byte_end":1499,"line_start":46,"line_end":46,"column_start":14,"column_end":18,"is_primary":true,"text":[{"text":"    let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381]","highlight_start":14,"highlight_end":18}],"label":"use of possibly uninitialized `a.y`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0381]: borrow of possibly uninitialized variable: `a.y`\n  --> /checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs:46:14\n   |\nLL |     let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381]\n   |              ^^^^ use of possibly uninitialized `a.y`\n\n"}
[00:51:50] {"message":"cannot assign to `a.x` when `a` is not initialized","code":{"code":"E0718","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs","byte_start":1650,"byte_end":1659,"line_start":50,"line_end":50,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    a.x = &&0;","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0718]: cannot assign to `a.x` when `a` is not initialized\n  --> /checkout/src/test/ui/borrowck/borrowck-uninit-ref-cowck-use-in-index-lvalue.rs:20:5
[00:51:50] +    |
[00:51:50] + LL |     w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
[00:51:50] 14 
[00:51:50] - For more information about this error, try `rustc --explain E0381`.
[00:51:50] + error: aborting due to 4 previous errors
[00:51:50] + 
[00:51:50] + 
[00:51:50] + Some errors occurred: E0381, E0718.
[00:51:50] + For more information about an error, try `rustc --explain E0381`.
[00:51:50] 16 
[00:51:50] 
[00:51:50] 
[00:51:50] The actual stderr differed from the expected stderr.
[00:51:50] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-use-in-index-lvalue.mir/borrowck-use-in-index-lvalue.mir.stderr
[00:51:50] To update references, rerun the tests and pass the `--bless` flag
[00:51:50] To only update this specific test, also pass `--test-args borrowck/borrowck-use-in-index-lvalue.rs`
[00:51:50] 
[00:51:50] error in revision `mir`: 1 errors occurred comparing output.
[00:51:50] status: exit code: 1
[00:51:50] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-use-in-index-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-use-in-index-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-use-inull},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs","byte_start":569,"byte_end":577,"line_start":16,"line_end":16,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":"    w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]","highlight_start":5,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0718]: cannot assign to `w[..]` when `w` is not initialized\n  --> /checkout/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs:16:5\n   |\nLL |     w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]\n   |     ^^^^^^^^\n\n"}
[00:51:50] {"message":"use of possibly uninitialized variable: `*w`","code":{"code":"E0381","explanation":"\nIt is not allowed to use or capture an uninitialized variable. For example:\n\n```compile_fail,E0381\nfn main() {\n    let x: i32;\n    let y = x; // error, use 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/borrowck/borrowck-use-in-index-lvalue.rs","byte_start":719,"byte_end":723,"line_start":20,"line_end":20,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]","highlight_start":5,"highlight_end":9}],"label":"use of possibly uninitialized `*w`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0381]: use of possibly uninitialized variable: `*w`\n  --> /checkout/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs:20:5\n   |\nLL |     w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]\n   |     ^^^^ use of possibly uninitialized `*w`\n\n"}
[00:51:50] {"message":"cannot assign to `w[..]` when `w` is not initialized","code":{"code":"E0718","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs","byte_start":719,"byte_end":727,"line_start":20,"line_end":20,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":"    w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]","highlight_start":5,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0718]: cannot assign to `w[..]` when `w` is not initialized\n  --> /checkout/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs:20:5\n   |\nLL |     w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]\n   |     ^^^^^^^^\n\n"}
[00:51:50] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:51:50] {"message":"Some errors occurred: E0381, E0718.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0381, E0718.\n"}
[00:51:50] {"message":"For more information about an error, try `rustc --explain E0381`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0381`.\n"}
[00:51:50] ------------------------------------------
[00:51:50] 
[00:51:50] thread '[ui] ui/borrowck/borrowck-use-in-index-lvalue.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3267:9
[00:51:50] 
---
[00:51:50] test result: FAILED. 4556 passed; 3 failed; 20 ignored; 0 measured; 0 filtered out
[00:51:50] 
[00:51:50] 
[00:51:50] 
[00:51:50] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/p4327288 .
2479164 ./obj/build
1846652 ./obj/build/x86_64-unknown-linux-gnu
1069648 ./src
777924 ./.git
---
151464 ./obj/build/bootstrap/debug/incremental
151412 ./src/tools/clang
149124 ./src/llvm-emscripten/test
135996 ./obj/build/bootstrap/debug/incremental/bootstrap-3ivyub3ic2113
135992 ./obj/build/bootstrap/debug/incremental/bootstrap-3ivyub3ic2113/s-f5klit5ye0-9w4ug0-1akhp35ixzhyj
135632 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu
135628 ./objE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:09e5c6e9
travis_time:start:09e5c6e9
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:16c1bf3c
$ dmesg | grep -i kill

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

@spastorino
Copy link
Member Author

@nikomatsakis we don't want these kind of errors 56011eb#diff-27087a37a3701eb55da69c6420fb0fa8R1 Need to figure out how to get rid of the error when there's already a move error.

error[E0718]: cannot assign to `src.next` when `src` is not initialized
--> $DIR/borrowck-issue-48962.rs:26:5
|
LL | src.next = None; //~ ERROR use of moved value: `src` [E0382]
Copy link
Member

Choose a reason for hiding this comment

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

(I've already chatted with @spastorino about this; we can avoid this (IMO redundant/unnecessary) error if we revise the strategy slightly. PR #54941 has some hidden suggestions )

@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.
[00:50:55] 
[00:50:55] running 4579 tests
[00:50:58] .................................................................................................... 100/4579
[00:51:01] .................................................................................................... 200/4579
[00:51:04] ........................................................................F........................... 300/4579
[00:51:07] ...............................................................F.........F.......................... 400/4579
[00:51:14] .......................i............................................................................ 600/4579
[00:51:20] .................................................................................................... 700/4579
[00:51:26] ...................................i...........i.................................................... 800/4579
[00:51:29] ......................................................iiiii......................................... 900/4579
---
[00:53:24] .................................................................................................... 4100/4579
[00:53:28] ................................................................i................................... 4200/4579
[00:53:32] .................................................................................................... 4300/4579
[00:53:35] .................................................................................................... 4400/4579
wck/borrowck-uninit-ref-chain.rs:39: unexpected error: '39:5: 39:14: cannot assign to `a.x` when `a` is not initialized [E0718]'
[00:53:41] 
[00:53:41] error in revision `mir`: /checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs:45: unexpected error: '45:5: 45:12: cannot assign to `a.x` when `a` is not initialized [E0718]'
[00:53:41] 
[00:53:41] error in revision `mir`: /checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs:50: unexpected error: '50:5: 50:14: cannot assign to `a.x` when `a` is not initialized [E0718]'
[00:53:41] 
[00:53:41] error in revision `mir`: 4 unexpected errors found, 0 expected errors not found
[00:53:41] status: exit code: 1
[00:53:41] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-uninit-ref-chain.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-uninit-ref-chain.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-uninit-ref-chain.mir/auxiliary" "-A" "unused"
[00:53:41]     Error {
[00:53:41]         line_num: 34,
[00:53:41]         kind: Some(
[00:53:41]             Error
[00:53:41]             Error
[00:53:41]         ),
[00:53:41]         msg: "34:5: 34:12: cannot assign to `a.x` when `a` is not initialized [E0718]"
[00:53:41]     Error {
[00:53:41]     Error {
[00:53:41]       eckout/src/test/ui/borrowck/borrowck-use-in-index-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-use-in-index-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-use-in-index-lvalue.mir/auxiliary" "-A" "unused"
[00:53:41]     Error {
[00:53:41]         line_num: 16,
[00:53:41]         kind: Some(
[00:53:41]             Error
[00:53:41]             Error
[00:53:41]         ),
[00:53:41]         msg: "16:5: 16:13: cannot assign to `w[..]` when `w` is not initialized [E0718]"
[00:53:41]     Error {
[00:53:41]         line_num: 20,
[00:53:41]         kind: Some(
[00:53:41]             Error
[00:53:41]             Error
[00:53:41]         ),
[00:53:41]         msg: "20:5: 20:13: cannot assign to `w[..]` when `w` is not initialized [E0718]"
[00:53:41] ]
[00:53:41] 
[00:53:41] thread '[ui] ui/borrowck/borrowck-use-in-index-lvalue.rs#mir' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1341:13
[00:53:41] 

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)

@spastorino
Copy link
Member Author

I'm closing this given @pnkfelix is taking care of this now.

@spastorino spastorino closed this Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non Lexical Lifetimes (NLL) 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.

None yet

5 participants