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

rustc_mir: split qualify_consts' "value qualification" bitflags into separate computations. #58403

Merged
merged 10 commits into from
Feb 15, 2019

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Feb 12, 2019

Prerequisite for computing those bits through a dataflow algorithm (which I might do in this PR later).

This PR should not change behavior overall, other than treating simd_shuffle* identically to #[rustc_args_required_const] (maybe we should just have #[rustc_args_required_const] on the intrinsic imports of simd_shuffle*? cc @gnzlbg)

cc @oli-obk @alexreg

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 12, 2019
@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 12, 2019

@eddyb would you mind running packed_simd tests (e.g. cargo test) and stdsimd/crates/core_arch tests (using cargo test --release) using a toolchain containing this patch ? There should be enough tests using the shuffle intrinsics in both of those crates.

@eddyb
Copy link
Member Author

eddyb commented Feb 12, 2019

It accepts strictly more and if our CI doesn't run those tests that sounds like an infra bug.

Abi::RustIntrinsic |
Abi::PlatformIntrinsic => {
assert!(!cx.tcx.is_const_fn(def_id));
match &cx.tcx.item_name(def_id).as_str()[..] {
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern seems to mostly (not entirely) duplicate the whitelist check in the qualify_min_const.. logic; de-duplicate it by using that function?

@Centril
Copy link
Contributor

Centril commented Feb 12, 2019

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned varkor Feb 12, 2019
@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 12, 2019

It accepts strictly more and if our CI doesn't run those tests that sounds like an infra bug.

cc @pietroalbini

@bors

This comment has been minimized.

src/librustc_mir/transform/qualify_consts.rs Outdated Show resolved Hide resolved
src/librustc_mir/transform/qualify_consts.rs Show resolved Hide resolved
src/librustc_mir/transform/qualify_consts.rs Show resolved Hide resolved
src/librustc_mir/transform/qualify_consts.rs Outdated Show resolved Hide resolved
src/librustc_mir/transform/qualify_consts.rs Outdated Show resolved Hide resolved
src/librustc_mir/transform/qualify_consts.rs Outdated Show resolved Hide resolved
@eddyb eddyb force-pushed the requalify branch 3 times, most recently from a8ec409 to 0924a19 Compare February 13, 2019 10:05
@eddyb
Copy link
Member Author

eddyb commented Feb 13, 2019

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Feb 13, 2019

📌 Commit 0924a19d19450b882dc716b7f57ae9f2b290baf8 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 13, 2019
@Centril
Copy link
Contributor

Centril commented Feb 13, 2019

In-between-rollups-filler, @bors p=1

@bors
Copy link
Contributor

bors commented Feb 13, 2019

⌛ Testing commit 0924a19d19450b882dc716b7f57ae9f2b290baf8 with merge cbc038fcc0bc89c385b42a3013b319d9697f0700...

@bors
Copy link
Contributor

bors commented Feb 13, 2019

💔 Test failed - checks-travis

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-nopt 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.
[01:29:35] 
[01:29:35] ---- [ui (nll)] ui/error-codes/E0017.rs stdout ----
[01:29:35] diff of stderr:
[01:29:35] 
[01:29:35] 4 LL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017
[01:29:35] 5    |                              ^^^^^^ constants require immutable values
[01:29:35] - error: cannot mutate statics in the initializer of another static
[01:29:35] - error: cannot mutate statics in the initializer of another static
[01:29:35] + error[E0017]: references in statics may only refer to immutable values
[01:29:35] 8   --> $DIR/E0017.rs:5:39
[01:29:35] 9    |
[01:29:35] 10 LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
[01:29:35] -    |                                       ^^^^^^
[01:29:35] +    |                                       ^^^^^^ statics require immutable values
[01:29:35] 12 
[01:29:35] 12 
[01:29:35] - error[E0017]: references in statics may only refer to immutable values
[01:29:35] + error: cannot mutate statics in the initializer of another static
[01:29:35] 14   --> $DIR/E0017.rs:5:39
[01:29:35] 15    |
[01:29:35] 16 LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
[01:29:35] -    |                                       ^^^^^^ statics require immutable values
[01:29:35] +    |                                       ^^^^^^
[01:29:35] 18 
[01:29:35] 18 
[01:29:35] 19 error[E0596]: cannot borrow immutable static item `X` as mutable
[01:29:35] 20   --> $DIR/E0017.rs:5:39
[01:29:35] 
[01:29:35] The actual stderr differed from the expected stderr.
[01:29:35] The actual stderr differed from the expected stderr.
[01:29:35] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0017.nll/E0017.nll.stderr
[01:29:35] To update references, rerun the tests and pass the `--bless` flag
[01:29:35] To only update this specific test, also pass `--test-args error-codes/E0017.rs`
[01:29:35] error: 1 errors occurred comparing output.
[01:29:35] status: exit code: 1
[01:29:35] status: exit code: 1
[01:29:35] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/error-codes/E0017.rs" "-Zthreads=1" "--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/error-codes/E0017.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-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/error-codes/E0017.nll/auxiliary" "-A" "unused"
[01:29:35] ------------------------------------------
[01:29:35] 
[01:29:35] ------------------------------------------
[01:29:35] stderr:
[01:29:35] stderr:
[01:29:35] ------------------------------------------
[01:29:35] {"message":"references in constants may only refer to immutable values","code":{"code":"E0017","explanation":"\nReferences in statics and constants may only refer to immutable values.\nErroneous code example:\n\n```compile_fail,E0017\nstatic X: i32 = 1;\nconst C: i32 = 2;\n\n// these three are not allowed:\nconst CR: &mut i32 = &mut C;\nstatic STATIC_REF: &'static mut i32 = &mut X;\nstatic CONST_REF: &'static mut i32 = &mut C;\n```\n\nStatics are shared everywhere, and if they refer to mutable data one might\nviolate memory safety since holding multiple mutable references to shared data\nis not allowed.\n\nIf you really want global mutable state, try using `static mut` or a global\n`UnsafeCell`.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0017.rs","byte_start":67,"byte_end":73,"line_start":4,"line_end":4,"column_start":30,"column_end":36,"is_primary":true,"text":[{"text":"const CR: &'static mut i32 = &mut C; //~ ERROR E0017","highlight_start":30,"highlight_end":36}],"label":"constants require immutable values","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0017]: references in constants may only refer to immutable values\n  --> /checkout/src/test/ui/error-codes/E0017.rs:4:30\n   |\nLL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017\n   |                              ^^^^^^ constants require immutable values\n\n"}
[01:29:35] {"message":"references in statics may only refer to immutable values","code":{"code":"E0017","explanation":"\nReferences in statics and constants may only refer to immutable values.\nErroneous code example:\n\n```compile_fail,E0017\nstatic X: i32 = 1;\nconst C: i32 = 2;\n\n// these three are not allowed:\nconst CR: &mut i32 = &mut C;\nstatic STATIC_REF: &'static mut i32 = &mut X;\nstatic CONST_REF: &'static mut i32 = &mut C;\n```\n\nStatics are shared everywhere, and if they refer to mutable data one might\nviolate memory safety since holding multiple mutable references to shared data\nis not allowed.\n\nIf you really want global mutable state, try using `static mut` or a global\n`UnsafeCell`.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0017.rs","byte_start":129,"byte_end":135,"line_start":5,"line_end":5,"column_start":39,"column_end":45,"is_primary":true,"text":[{"text":"static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017","highlight_start":39,"highlight_end":45}],"label":"statics require immutable values","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0017]: references in statics may only refer to immutable values\n  --> /checkout/src/test/ui/error-codes/E0017.rs:5:39\n   |\nLL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017\n   |                                       ^^^^^^ statics require immutable values\n\n"}
[01:29:35] {"message":"cannot mutate statics in the initializer of another static","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0017.rs","byte_start":129,"byte_end":135,"line_start":5,"line_end":5,"column_start":39,"column_end":45,"is_primary":true,"text":[{"text":"static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017","highlight_start":39,"highlight_end":45}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: cannot mutate statics in the initializer of another static\n  --> /checkout/src/test/ui/error-codes/E0017.rs:5:39\n   |\nLL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017\n   |                                       ^^^^^^\n\n"}
[01:29:35] {"message":"cannot borrow immutable static item `X` as mutable","code":{"code":"E0596","explanation":"\nThis error occurs because you tried to mutably borrow a non-mutable variable.\n\nExample of erroneous code:\n\n```compile_fail,E0596\nlet x = 1;\nlet y = &mut x; // error: cannot borrow mutably\n```\n\nIn here, `x` isn't mutable, so when we try to mutably borrow it in `y`, it\nfails. To fix this error, you need to make `x` mutable:\n\n```\nlet mut x = 1;\nlet y = &mut x; // ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0017.rs","byte_start":129,"byte_end":135,"line_start":5,"line_end":5,"column_start":39,"column_end":45,"is_primary":true,"text":[{"text":"static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017","highlight_start":39,"highlight_end":45}],"label":"cannot borrow as mutable","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0596]: cannot borrow immutable static item `X` as mutable\n  --> /checkout/src/test/ui/error-codes/E0017.rs:5:39\n   |\nLL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017\n   |                                       ^^^^^^ cannot borrow as mutable\n\n"}
[01:29:35] {"message":"references in statics may only refer to immutable values","code":{"code":"E0017","explanation":"\nReferences in statics and constants may only refer to immutable values.\nErroneous code example:\n\n```compile_fail,E0017\nstatic X: i32 = 1;\nconst C: i32 = 2;\n\n// these three are not allowed:\nconst CR: &mut i32 = &mut C;\nstatic STATIC_REF: &'static mut i32 = &mut X;\nstatic CONST_REF: &'static mut i32 = &mut C;\n```\n\nStatics are shared everywhere, and if they refer to mutable data one might\nviolate memory safety since holding multiple mutable references to shared data\nis not allowed.\n\nIf you really want global mutable state, try using `static mut` or a global\n`UnsafeCell`.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0017.rs","byte_start":340,"byte_end":346,"line_start":8,"line_end":8,"column_start":38,"column_end":44,"is_primary":true,"text":[{"text":"static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017","highlight_start":38,"highlight_end":44}],"label":"statics require immutable values","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0017]: references in statics may only refer to immutable values\n  --> /checkout/src/test/ui/error-codes/E0017.rs:8:38\n   |\nLL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017\n   |                                      ^^^^^^ statics require immutable values\n\n"}
[01:29:35] {"message":"aborting due to 5 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 5 previous errors\n\n"}
[01:29:35] {"message":"Some errors occurred: E0017, E0596.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0017, E0596.\n"}
[01:29:35] 
[01:29:35] ------------------------------------------
[01:29:35] 
[01:29:35] thread '[ui (nll)] ui/error-codes/E0017.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:29:35] thread '[ui (nll)] ui/error-codes/E0017.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:29:35] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:29:35] 
[01:29:35] ---- [ui (nll)] ui/error-codes/E0388.rs stdout ----
[01:29:35] diff of stderr:
[01:29:35] 
[01:29:35] 4 LL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017
[01:29:35] 5    |                              ^^^^^^ constants require immutable values
[01:29:35] - error: cannot mutate statics in the initializer of another static
[01:29:35] - error: cannot mutate statics in the initializer of another static
[01:29:35] + error[E0017]: references in statics may only refer to immutable values
[01:29:35] 8   --> $DIR/E0388.rs:5:39
[01:29:35] 9    |
[01:29:35] 10 LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
[01:29:35] -    |                                       ^^^^^^
[01:29:35] +    |                                       ^^^^^^ statics require immutable values
[01:29:35] 12 
[01:29:35] 12 
[01:29:35] - error[E0017]: references in statics may only refer to immutable values
[01:29:35] + error: cannot mutate statics in the initializer of another static
[01:29:35] 14   --> $DIR/E0388.rs:5:39
[01:29:35] 15    |
[01:29:35] 16 LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
[01:29:35] -    |                                       ^^^^^^ statics require immutable values
[01:29:35] +    |                                       ^^^^^^
[01:29:35] 18 
[01:29:35] 18 
[01:29:35] 19 error[E0596]: cannot borrow immutable static item `X` as mutable
[01:29:35] 20   --> $DIR/E0388.rs:5:39
[01:29:35] 
[01:29:35] The actual stderr differed from the expected stderr.
[01:29:35] The actual stderr differed from the expected stderr.
[01:29:35] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0388.nll/E0388.nll.stderr
[01:29:35] To update references, rerun the tests and pass the `--bless` flag
[01:29:35] To only update this specific test, also pass `--test-args error-codes/E0388.rs`
[01:29:35] error: 1 errors occurred comparing output.
[01:29:35] status: exit code: 1
[01:29:35] status: exit code: 1
[01:29:35] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/error-codes/E0388.rs" "-Zthreads=1" "--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/error-codes/E0388.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-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/error-codes/E0388.nll/auxiliary" "-A" "unused"
[01:29:35] ------------------------------------------
[01:29:35] 
[01:29:35] ------------------------------------------
[01:29:35] stderr:
[01:29:35] stderr:
[01:29:35] ------------------------------------------
[01:29:35] {"message":"references in constants may only refer to immutable values","code":{"code":"E0017","explanation":"\nReferences in statics and constants may only refer to immutable values.\nErroneous code example:\n\n```compile_fail,E0017\nstatic X: i32 = 1;\nconst C: i32 = 2;\n\n// these three are not allowed:\nconst CR: &mut i32 = &mut C;\nstatic STATIC_REF: &'static mut i32 = &mut X;\nstatic CONST_REF: &'static mut i32 = &mut C;\n```\n\nStatics are shared everywhere, and if they refer to mutable data one might\nviolate memory safety since holding multiple mutable references to shared data\nis not allowed.\n\nIf you really want global mutable state, try using `static mut` or a global\n`UnsafeCell`.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0388.rs","byte_start":67,"byte_end":73,"line_start":4,"line_end":4,"column_start":30,"column_end":36,"is_primary":true,"text":[{"text":"const CR: &'static mut i32 = &mut C; //~ ERROR E0017","highlight_start":30,"highlight_end":36}],"label":"constants require immutable values","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0017]: references in constants may only refer to immutable values\n  --> /checkout/src/test/ui/error-codes/E0388.rs:4:30\n   |\nLL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017\n   |                              ^^^^^^ constants require immutable values\n\n"}
[01:29:35] {"message":"references in statics may only refer to immutable values","code":{"code":"E0017","explanation":"\nReferences in statics and constants may only refer to immutable values.\nErroneous code example:\n\n```compile_fail,E0017\nstatic X: i32 = 1;\nconst C: i32 = 2;\n\n// these three are not allowed:\nconst CR: &mut i32 = &mut C;\nstatic STATIC_REF: &'static mut i32 = &mut X;\nstatic CONST_REF: &'static mut i32 = &mut C;\n```\n\nStatics are shared everywhere, and if they refer to mutable data one might\nviolate memory safety since holding multiple mutable references to shared data\nis not allowed.\n\nIf you really want global mutable state, try using `static mut` or a global\n`UnsafeCell`.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0388.rs","byte_start":129,"byte_end":135,"line_start":5,"line_end":5,"column_start":39,"column_end":45,"is_primary":true,"text":[{"text":"static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017","highlight_start":39,"highlight_end":45}],"label":"statics require immutable values","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0017]: references in statics may only refer to immutable values\n  --> /checkout/src/test/ui/error-codes/E0388.rs:5:39\n   |\nLL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017\n   |                                       ^^^^^^ statics require immutable values\n\n"}
[01:29:35] {"message":"cannot mutate statics in the initializer of another static","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0388.rs","byte_start":129,"byte_end":135,"line_start":5,"line_end":5,"column_start":39,"column_end":45,"is_primary":true,"text":[{"text":"static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017","highlight_start":39,"highlight_end":45}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: cannot mutate statics in the initializer of another static\n  --> /checkout/src/test/ui/error-codes/E0388.rs:5:39\n   |\nLL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017\n   |                                       ^^^^^^\n\n"}
[01:29:35] {"message":"cannot borrow immutable static item `X` as mutable","code":{"code":"E0596","explanation":"\nThis error occurs because you tried to mutably borrow a non-mutable variable.\n\nExample of erroneous code:\n\n```compile_fail,E0596\nlet x = 1;\nlet y = &mut x; // error: cannot borrow mutably\n```\n\nIn here, `x` isn't mutable, so when we try to mutably borrow it in `y`, it\nfails. To fix this error, you need to make `x` mutable:\n\n```\nlet mut x = 1;\nlet y = &mut x; // ok!\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0388.rs","byte_start":129,"byte_end":135,"line_start":5,"line_end":5,"column_start":39,"column_end":45,"is_primary":true,"text":[{"text":"static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017","highlight_start":39,"highlight_end":45}],"label":"cannot borrow as mutable","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0596]: cannot borrow immutable static item `X` as mutable\n  --> /checkout/src/test/ui/error-codes/E0388.rs:5:39\n   |\nLL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017\n   |                                       ^^^^^^ cannot borrow as mutable\n\n"}
[01:29:35] {"message":"references in statics may only refer to immutable values","code":{"code":"E0017","explanation":"\nReferences in statics and constants may only refer to immutable values.\nErroneous code example:\n\n```compile_fail,E0017\nstatic X: i32 = 1;\nconst C: i32 = 2;\n\n// these three are not allowed:\nconst CR: &mut i32 = &mut C;\nstatic STATIC_REF: &'static mut i32 = &mut X;\nstatic CONST_REF: &'static mut i32 = &mut C;\n```\n\nStatics are shared everywhere, and if they refer to mutable data one might\nviolate memory safety since holding multiple mutable references to shared data\nis not allowed.\n\nIf you really want global mutable state, try using `static mut` or a global\n`UnsafeCell`.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/error-codes/E0388.rs","byte_start":340,"byte_end":346,"line_start":8,"line_end":8,"column_start":38,"column_end":44,"is_primary":true,"text":[{"text":"static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017","highlight_start":38,"highlight_end":44}],"label":"statics require immutable values","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0017]: references in statics may only refer to immutable values\n  --> /checkout/src/test/ui/error-codes/E0388.rs:8:38\n   |\nLL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017\n   |                                      ^^^^^^ statics require immutable values\n\n"}
[01:29:35] {"message":"aborting due to 5 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 5 previous errors\n\n"}
[01:29:35] {"message":"Some errors occurred: E0017, E0596.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0017, E0596.\n"}
[01:29:35] 
[01:29:35] ------------------------------------------
[01:29:35] 
[01:29:35] thread '[ui (nll)] ui/error-codes/E0388.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
---
[01:29:35] 
[01:29:35] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:29:35] 
[01:29:35] 
[01:29:35] 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" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--host-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always" "--compare-mode" "nll"
[01:29:35] 
[01:29:35] 
[01:29:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:29:35] Build completed unsuccessfully in 0:08:22
[01:29:35] Build completed unsuccessfully in 0:08:22
[01:29:35] Makefile:48: recipe for target 'check' failed
[01:29:35] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:06b838f0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed Feb 13 18:51:24 UTC 2019
---
travis_time:end:0a329c00:start=1550083886720277228,finish=1550083886730630758,duration=10353530
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:120e1c38
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --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:0a702fb6
travis_time:start:0a702fb6
$ 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:0bfff090
$ 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)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 13, 2019
@Centril
Copy link
Contributor

Centril commented Feb 13, 2019

Help save the climate by running --bless --compare-mode=nll :)

@eddyb
Copy link
Member Author

eddyb commented Feb 14, 2019

Ugh, it would be tricky to keep the old message order.
Can I have both outputs or do they need to match?

@oli-obk
Copy link
Contributor

oli-obk commented Feb 14, 2019

I think nll has separate files if the output differs. Changing the order is fine.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2019
@bors
Copy link
Contributor

bors commented Feb 15, 2019

⌛ Testing commit f04424a with merge 8db20450bdff0e7852dd73ad2d92be6aa6f8f9a4...

@bors
Copy link
Contributor

bors commented Feb 15, 2019

💔 Test failed - checks-travis

@rust-highfive
Copy link
Collaborator

The job dist-x86_64-apple 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.
php72 -> php@7.2
rebar@3 -> rebar3
resin-cli -> balena-cli
saltstack -> salt
todolist -> ultralist
==> Deleted Formulae
amber
apple-gcc42
aptly-completion
---
[00:03:52]       Memory: 8 GB
[00:03:52]       Boot ROM Version: VMW71.00V.7581552.B64.1801142334
[00:03:52]       Apple ROM Info: [MS_VM_CERT/SHA1/27d66596a61c48dd3dc7216fd715126e33f59ae7]Welcome to the Virtual Machine
[00:03:52]       SMC Version (system): 2.8f0
[00:03:52]       Serial Number (system): VMH2L6mRF2Ev
[00:03:52] 
[00:03:53] hw.ncpu: 4
[00:03:53] hw.byteorder: 1234
[00:03:53] hw.memsize: 8589934592

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)

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

kennytm commented Feb 15, 2019

@bors retry 3 hour timeout

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2019
@bors
Copy link
Contributor

bors commented Feb 15, 2019

⌛ Testing commit f04424a with merge f058741...

bors added a commit that referenced this pull request Feb 15, 2019
rustc_mir: split qualify_consts' "value qualification" bitflags into separate computations.

Prerequisite for computing those bits through a dataflow algorithm ~~(which I might do in this PR later)~~.

This PR should not change behavior overall, other than treating `simd_shuffle*` identically to `#[rustc_args_required_const]` (maybe we should just have `#[rustc_args_required_const]` on the intrinsic imports of `simd_shuffle*`? cc @gnzlbg)

cc @oli-obk @alexreg
@bors
Copy link
Contributor

bors commented Feb 15, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: oli-obk
Pushing f058741 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 15, 2019
@bors bors merged commit f04424a into rust-lang:master Feb 15, 2019
@rust-lang rust-lang deleted a comment from rust-highfive Feb 15, 2019
@eddyb eddyb deleted the requalify branch February 15, 2019 16:17
let allowed = cx.mode == Mode::Static || cx.mode == Mode::StaticMut;

!allowed ||
cx.tcx.get_attrs(static_.def_id).iter().any(|attr| attr.check_name("thread_local"))
Copy link
Member

Choose a reason for hiding this comment

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

My head hurts when reading this, everything is negated.^^

}

// Refers to temporaries which cannot be promoted as
// promote_consts decided they weren't simple enough.
Copy link
Member

Choose a reason for hiding this comment

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

That's weird, how is this meaningfully different from the "promotion-only" checks that are done in the NotConst thing above?

_args: &[Operand<'tcx>],
_return_ty: Ty<'tcx>,
) -> bool {
if cx.mode == Mode::Fn {
Copy link
Member

Choose a reason for hiding this comment

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

This conditional is confusing, wouldn't it make more sense to simply only run this analysis when we care about promotion / only use the result of this analysis when we care about promotion?

At the least, things would be slightly more clear if all methods in this impl early-aborted for the "out of scope" case (cx.mode != Mode::Fn).

Copy link
Member Author

@eddyb eddyb Mar 15, 2019

Choose a reason for hiding this comment

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

I was discussing IsNotPromotable with @oli-obk... it's not exactly clear what to make of it, but the names are definitely wrong.

Promotability is tricky because it differs between compile-time and run-time.

Ideally we would just get rid of IsNotPromotable, but at least one run-time thing (#[rustc_const_arg]) is stable and differs in desired behavior from "promotion involving const fn calls".

Copy link
Member

Choose a reason for hiding this comment

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

it differs between compile-time and run-time.

I am not sure what you mean by this. Do you mean the analysis is different in const context?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean we allow promoting &const_fn() in a const, given that interior mutability and drop conditions are met, while at runtime const_fn also needs #[rustc_promotable].

Copy link
Member

Choose a reason for hiding this comment

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

Okay so by "at runtime" you mean "in run-time code".

However, currently there are also a bunch of checks in NotConst that have to do with promotability, from what I can see.

Copy link
Member Author

Choose a reason for hiding this comment

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

Like I said, some of the naming is wrong/misleading and should be changed.

IIRC, IsNotConst should have the IsNotPromotable name, and our current IsNotPromotable should be ...checks IRC log... IsNotImplicitlyPromotable / MayCallNotImplicitlyPromotableConstFn / MayCallUnpredictableConstFn.

(I'm not sure what @oli-obk actually prefers)

Copy link
Member Author

Choose a reason for hiding this comment

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

To expand a bit: the main point was that we should distinguish between:

  • "implicit promotion"
    • only "rvalue-to-'static" AFAIK
    • requires #[rustc_promotable] on called const fns
  • "explicit promotion" / "forced promotion"
    • e.g. "const args" (whether #[rustc_const_arg] or a different system)
    • it can't compile without being promoted, so we can allow pretty much everything we do in a const item, modulo the "SSA tree" shape required to actually perform the promotion on MIR (we'd need something like VSDG to allow more)

We should figure out how to avoid this discussion getting lost though, heh.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe HasNoConstFnCalls? (I know it's wrong in the presence of rustc_promotable)

interior mutability, create a static instead");
}
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

This is an else clause after a negated conditional: if x != y { ... } else { ... }. Would be clearer to swap the branches.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope! this is the else from if qualifs[HasMutInterior] {.

Some early returns might help, though.

Centril added a commit to Centril/rust that referenced this pull request Apr 12, 2019
Retire `IsNotConst` naming

This naming scheme caused a lot of confusion lately (including ICEs) due to misrefactored code. Also clean up the initialization code for said flag.

r? @eddyb

previous discussions: rust-lang#58784 (comment) rust-lang#58403 (comment)
Centril added a commit to Centril/rust that referenced this pull request Apr 13, 2019
Retire `IsNotConst` naming

This naming scheme caused a lot of confusion lately (including ICEs) due to misrefactored code. Also clean up the initialization code for said flag.

r? @eddyb

previous discussions: rust-lang#58784 (comment) rust-lang#58403 (comment)
Centril added a commit to Centril/rust that referenced this pull request Apr 13, 2019
Retire `IsNotConst` naming

This naming scheme caused a lot of confusion lately (including ICEs) due to misrefactored code. Also clean up the initialization code for said flag.

r? @eddyb

previous discussions: rust-lang#58784 (comment) rust-lang#58403 (comment)
Centril added a commit to Centril/rust that referenced this pull request Apr 13, 2019
Retire `IsNotConst` naming

This naming scheme caused a lot of confusion lately (including ICEs) due to misrefactored code. Also clean up the initialization code for said flag.

r? @eddyb

previous discussions: rust-lang#58784 (comment) rust-lang#58403 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants