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

Get rid of the Scalar and ScalarPair variants of ConstValue... #55260

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
edf94c5
Update function names in comments
oli-obk Oct 19, 2018
856eaed
Simplify `ConstValue`
oli-obk Oct 21, 2018
fe4e950
Make the HashStable impl of Allocation safer for future changes of th…
oli-obk Oct 21, 2018
04fc561
The `Hash` and `Eq` impls of `ConstValue` were inherently broken
oli-obk Oct 21, 2018
b11b3cb
Fixup a bunch of things for "simplify const value"
oli-obk Oct 21, 2018
3aecb0d
Fix some simd intrinsics
oli-obk Oct 21, 2018
8d42376
Fix an ICE that can occur while errors are already being emitted
oli-obk Oct 21, 2018
847f5b9
Const prop is only interested in immediate constants right now
oli-obk Oct 21, 2018
e52644c
Update a few tests with their improved diagnostic messages
oli-obk Oct 21, 2018
8246dd4
Alignment check facepalm
oli-obk Oct 21, 2018
5620d68
Enums can produce scalar pairs with undefs in one of the elements
oli-obk Oct 21, 2018
fc6472c
Hide a constructor function that is unused outside this module
oli-obk Oct 22, 2018
336094f
Use a more appropriate parameter environment
oli-obk Oct 22, 2018
b4ba332
Don't resolve `impl Trait` in function def constants to the concrete …
oli-obk Oct 22, 2018
dfc5d26
Constants carry their type with them
oli-obk Oct 22, 2018
c50d77d
Alignment of `const_field` results must be of the field's type
oli-obk Oct 22, 2018
1d14a84
Add a debugging aid
oli-obk Oct 22, 2018
9fbce39
Change some useless `ParamEnv::empty` to `reveal_all`
oli-obk Oct 22, 2018
1f2fcee
Improve debugging output of layout computation failure
oli-obk Oct 22, 2018
e3bbe6d
Shrink allocations to fit the type at hand
oli-obk Oct 22, 2018
6ff70da
Resize `Allocation`s when doing field accesses into them
oli-obk Oct 22, 2018
7b526d8
Read the slice length from the correct place in the fat pointer
oli-obk Oct 22, 2018
9df63e9
Global Allocations don't have an `extra` value
oli-obk Oct 22, 2018
a7a92e2
Rebase fallout
oli-obk Oct 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-err4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ union Foo {

enum Bar {
Boo = [unsafe { Foo { b: () }.a }; 4][3],
//~^ ERROR could not evaluate enum discriminant
//~^ ERROR constant evaluation of enum discriminant resulted in non-integer
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-err4.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0080]: could not evaluate enum discriminant
error[E0080]: constant evaluation of enum discriminant resulted in non-integer
--> $DIR/const-err4.rs:18:11
|
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
//~^ ERROR this constant likely exhibits undefined behavior

const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
//~^ ERROR this constant cannot be used
//~^ ERROR this constant likely exhibits undefined behavior

const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
//~^ ERROR this constant cannot be used
Expand All @@ -52,7 +52,7 @@ fn main() {
//~^ ERROR this constant likely exhibits undefined behavior

const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
//~^ ERROR this constant cannot be used
//~^ ERROR this constant likely exhibits undefined behavior

const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
//~^ ERROR this constant cannot be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error: this constant cannot be used
error[E0080]: this constant likely exhibits undefined behavior
--> $DIR/const-pointer-values-in-various-types.rs:39:5
|
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error: this constant cannot be used
--> $DIR/const-pointer-values-in-various-types.rs:42:5
Expand Down Expand Up @@ -78,11 +80,13 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error: this constant cannot be used
error[E0080]: this constant likely exhibits undefined behavior
--> $DIR/const-pointer-values-in-various-types.rs:54:5
|
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error: this constant cannot be used
--> $DIR/const-pointer-values-in-various-types.rs:57:5
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/union-const-eval-field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const fn read_field2() -> Field2 {
}

const fn read_field3() -> Field3 {
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR cannot be used
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
FIELD3
}

Expand Down
9 changes: 5 additions & 4 deletions src/test/ui/consts/const-eval/union-const-eval-field.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
error: this constant cannot be used
error[E0080]: this constant likely exhibits undefined behavior
--> $DIR/union-const-eval-field.rs:37:5
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR cannot be used
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
|
= note: #[deny(const_err)] on by default
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/union-ice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ union DummyUnion {

const UNION: DummyUnion = DummyUnion { field1: 1065353216 };

const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior

const FIELD_PATH: Struct = Struct { //~ ERROR this constant likely exhibits undefined behavior
a: 42,
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/consts/const-eval/union-ice.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: this constant cannot be used
error[E0080]: this constant likely exhibits undefined behavior
--> $DIR/union-ice.rs:23:1
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
|
= note: #[deny(const_err)] on by default
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error[E0080]: this constant likely exhibits undefined behavior
--> $DIR/union-ice.rs:25:1
Expand Down