]>
git.lizzy.rs Git - rust.git/log
bors [Thu, 8 Mar 2018 08:52:23 +0000 (08:52 +0000)]
Auto merge of #46882 - oli-obk:miri3, r=eddyb
Replace all const evaluation with miri
* error reporting in constants prints a stacktrace through all called const fns
* Trivial constant propagation and folding in MIR (always active, irrelevant of the optimization level)
* can now use floating constants in patterns (previously only floating point literals were allowed)
* the future compat lint is still produced for both cases
* can index into constant arrays during const eval (previously feature gated)
* can create a constant union value with field `a` and read from field `b`
* can dereference references into constants
* can create references inside constants (`const X: &u32 = &22`)
* Tuple struct constructors can be used in constants
* regression in const eval errors spans (some of these need improvements in mir debug info)
* can cast floats to ints and vice versa (in constants, and even nan/inf constants)
* Mir dump prints false/true instead of 0u8/1u8
* `1i8 >> [8][0]` does not lint about exceeding bitshifts anymore.
* Needs const propagation across projections
* `foo[I]` produces a const eval lint if `foo: [T; N]` and `N < I`
* Essentially all builtin panics produce lints if they can be statically proven to trigger at runtime. This is on a best effort basis, so there might be some complex cases that don't trigger. (The runtime panic stays there, irrelevant of whether the lint is produced or not)
* can use `union`s to implement `transmute` for `Copy` types in constants without a feature gate. With all the greatness and nasal demons that come with this.
* can convert integers to `&'static T` in constants (useful for embedded)
fixes #34997 (stack overflow with many constants)
fixes #25574 (deref byte strings in patterns)
fixes #27918 (broken mir ICE)
fixes #46114 (ICE on struct constructors in patterns)
fixes #37448 (`SomeStruct { foo } as SomeStruct`)
fixes #43754 (`return` in const fn)
fixes #41898 (tuple struct constructors)
fixes #31364 (infinite recursion with const fn, fixed by miri's recursion limit)
closes #29947 (const indexing stabilization)
fixes #45044 (pattern matching repeat expressions)
fixes #47971 (ICE on const fn + references)
fixes #48081 (ICE on cyclic assoc const error)
fixes #48746 (nonhelpful error message with unions)
r? @eddyb
even though 1k loc are added in tests, this PR reduces the loc in this repository by 700
Oliver Schneider [Wed, 7 Mar 2018 11:56:48 +0000 (12:56 +0100)]
Don't derive traits on packed structs
Oliver Schneider [Wed, 7 Mar 2018 07:17:03 +0000 (08:17 +0100)]
Clean up the binary hex lint
Oliver Schneider [Tue, 6 Mar 2018 13:07:52 +0000 (14:07 +0100)]
simplify constant value pair field access
Oliver Schneider [Tue, 6 Mar 2018 11:43:02 +0000 (12:43 +0100)]
Unify the const folding errors
before they differed depending on whether optimizations were on or not
Oliver Schneider [Tue, 6 Mar 2018 09:26:23 +0000 (10:26 +0100)]
Correct the shift overflow check in miri
Oliver Schneider [Mon, 5 Mar 2018 09:21:11 +0000 (10:21 +0100)]
Regenerate tests
Oliver Schneider [Fri, 23 Feb 2018 12:52:33 +0000 (13:52 +0100)]
Use clearer name for integer bit width helper function
Oliver Schneider [Fri, 23 Feb 2018 12:39:41 +0000 (13:39 +0100)]
Reuse `Integer::from_attr`
Oliver Schneider [Fri, 23 Feb 2018 10:20:51 +0000 (11:20 +0100)]
Remove unused error code
Oliver Schneider [Fri, 23 Feb 2018 08:21:31 +0000 (09:21 +0100)]
Generator assertions are unconditionally triggered
Oliver Schneider [Thu, 22 Feb 2018 16:29:39 +0000 (17:29 +0100)]
Address review comments
Oliver Schneider [Thu, 22 Feb 2018 15:56:14 +0000 (16:56 +0100)]
Adjust test which differs between 32 bit and 64 bit
The differences are not part of what the test is testing, so they were simply removed.
Oliver Schneider [Thu, 22 Feb 2018 13:59:18 +0000 (14:59 +0100)]
Decide signdedness on the layout instead of the type
Oliver Schneider [Thu, 22 Feb 2018 08:37:20 +0000 (09:37 +0100)]
Deduplicate some code
Oliver Schneider [Wed, 21 Feb 2018 21:02:52 +0000 (22:02 +0100)]
Don't use the undefined bytes of PrimVal::Bytes
Oliver Schneider [Tue, 20 Feb 2018 10:49:50 +0000 (11:49 +0100)]
Fix mozjs crater failure
Oliver Schneider [Tue, 20 Feb 2018 09:32:33 +0000 (10:32 +0100)]
Const eval will oom together with rustc now
Oliver Schneider [Mon, 19 Feb 2018 11:00:15 +0000 (12:00 +0100)]
Step limit is now terminator limit
Oliver Schneider [Mon, 19 Feb 2018 09:26:53 +0000 (10:26 +0100)]
Add regression test
Oliver Schneider [Fri, 9 Feb 2018 08:38:45 +0000 (09:38 +0100)]
Rebase fallout
Oliver Schneider [Tue, 6 Feb 2018 17:33:59 +0000 (18:33 +0100)]
Report tcx errors with the span of the currently evaluating statement
Oliver Schneider [Tue, 6 Feb 2018 14:35:43 +0000 (15:35 +0100)]
Report a best guess span if no stack is available anymore
Oliver Schneider [Tue, 6 Feb 2018 13:15:36 +0000 (14:15 +0100)]
Update compile-fail tests
Oliver Schneider [Tue, 6 Feb 2018 13:05:06 +0000 (14:05 +0100)]
Add a test for transmuting via unions in constants
Oliver Schneider [Tue, 6 Feb 2018 13:04:42 +0000 (14:04 +0100)]
Typo
Oliver Schneider [Tue, 6 Feb 2018 13:04:35 +0000 (14:04 +0100)]
Unregress error spans in constant errors
Oliver Schneider [Tue, 6 Feb 2018 09:51:54 +0000 (10:51 +0100)]
Stage 2 doesn't see suggestion_approximate
Oliver Schneider [Tue, 6 Feb 2018 09:24:53 +0000 (10:24 +0100)]
Remove dead code
Oliver Schneider [Tue, 6 Feb 2018 08:52:56 +0000 (09:52 +0100)]
Add some documentation to pattern/const conversions
Oliver Schneider [Tue, 6 Feb 2018 08:52:08 +0000 (09:52 +0100)]
Reduce code duplication
Oliver Schneider [Wed, 31 Jan 2018 14:45:59 +0000 (15:45 +0100)]
Tidy fix
Oliver Schneider [Wed, 31 Jan 2018 14:06:45 +0000 (15:06 +0100)]
Const eval error refactoring
Oliver Schneider [Wed, 31 Jan 2018 09:39:30 +0000 (10:39 +0100)]
Add stack traces to miri errors
Oliver Schneider [Wed, 31 Jan 2018 09:20:30 +0000 (10:20 +0100)]
Update tests
Oliver Schneider [Wed, 31 Jan 2018 08:57:25 +0000 (09:57 +0100)]
Report all errors other than those about insufficient type information
Oliver Schneider [Wed, 31 Jan 2018 08:31:24 +0000 (09:31 +0100)]
Compute the ParamEnv only once and use it to call tcx.const_eval
Oliver Schneider [Tue, 30 Jan 2018 15:46:37 +0000 (16:46 +0100)]
Add regression test for const prop
Oliver Schneider [Tue, 30 Jan 2018 15:38:14 +0000 (16:38 +0100)]
Can only const prop temporaries
Variables might error in branches that are not reachable due to the variable value.
Oliver Schneider [Tue, 30 Jan 2018 13:32:47 +0000 (14:32 +0100)]
Update tests
Oliver Schneider [Tue, 30 Jan 2018 13:28:45 +0000 (14:28 +0100)]
Simplify const propagator by removing unused code paths
Oliver Schneider [Tue, 30 Jan 2018 13:12:16 +0000 (14:12 +0100)]
Rename OptimizationFinder and don't propagate any borrows
Oliver Schneider [Tue, 30 Jan 2018 12:57:13 +0000 (13:57 +0100)]
Simplify const prop checks through PlaceContext
Oliver Schneider [Tue, 30 Jan 2018 10:18:37 +0000 (11:18 +0100)]
Move the resource limits to the session in preparation for attributes configuring them
Oliver Schneider [Tue, 30 Jan 2018 08:40:46 +0000 (09:40 +0100)]
Figure out const propgatable locals in a single pass
Oliver Schneider [Tue, 30 Jan 2018 08:40:26 +0000 (09:40 +0100)]
Remove unused error E0020
Oliver Schneider [Mon, 29 Jan 2018 19:47:09 +0000 (20:47 +0100)]
Update tests
Oliver Schneider [Mon, 29 Jan 2018 19:46:42 +0000 (20:46 +0100)]
Stabilize const_indexing feature
Oliver Schneider [Mon, 29 Jan 2018 18:53:46 +0000 (19:53 +0100)]
Report const eval errors at the correct span
Oliver Schneider [Mon, 29 Jan 2018 18:06:44 +0000 (19:06 +0100)]
Only report bitshift lints on bitshift ops
Oliver Schneider [Mon, 29 Jan 2018 17:54:37 +0000 (18:54 +0100)]
rustc_passes::consts -> rvalue_promotion
Oliver Schneider [Mon, 29 Jan 2018 14:12:45 +0000 (15:12 +0100)]
Use IndexVec instead of FxHashMap
Oliver Schneider [Mon, 29 Jan 2018 14:10:26 +0000 (15:10 +0100)]
Merge const linting pass into const prop
Oliver Schneider [Mon, 29 Jan 2018 14:02:01 +0000 (15:02 +0100)]
Remove redundant warnings in rustc_trans
Oliver Schneider [Mon, 29 Jan 2018 10:38:47 +0000 (11:38 +0100)]
Remove single field struct by just using the field
Oliver Schneider [Mon, 29 Jan 2018 10:24:51 +0000 (11:24 +0100)]
Adjust tests to changed const err lints
Oliver Schneider [Mon, 29 Jan 2018 09:38:05 +0000 (10:38 +0100)]
Remove the fragile const propagator and just do linting
Oliver Schneider [Mon, 29 Jan 2018 09:32:11 +0000 (10:32 +0100)]
Deduplicate code in rustdoc
Oliver Schneider [Mon, 29 Jan 2018 09:29:10 +0000 (10:29 +0100)]
Adjust tests to more aggressive const err linting
Oliver Schneider [Mon, 29 Jan 2018 09:18:49 +0000 (10:18 +0100)]
Fix ICE in const prop
Oliver Schneider [Mon, 29 Jan 2018 08:58:28 +0000 (09:58 +0100)]
Simplify const SIMD shuffle in trans
Oliver Schneider [Mon, 29 Jan 2018 07:50:47 +0000 (08:50 +0100)]
Revert all changes to the instcombine pass
Oliver Schneider [Sun, 28 Jan 2018 13:41:17 +0000 (14:41 +0100)]
Split const prop into its own pass
Oliver Schneider [Sun, 28 Jan 2018 13:11:55 +0000 (14:11 +0100)]
Don't use scary block reorderings
Oliver Schneider [Sat, 27 Jan 2018 16:15:40 +0000 (17:15 +0100)]
Report errors in statics during collecting instead of translating
Oliver Schneider [Sat, 27 Jan 2018 15:07:45 +0000 (16:07 +0100)]
Add regression tests
Oliver Schneider [Fri, 26 Jan 2018 15:44:10 +0000 (16:44 +0100)]
Simplify code around reading/writing ConstVals
Oliver Schneider [Fri, 26 Jan 2018 15:29:37 +0000 (16:29 +0100)]
Accidental paste
Oliver Schneider [Fri, 26 Jan 2018 15:24:54 +0000 (16:24 +0100)]
Explain the existance of `is_binop_lang_item`
Oliver Schneider [Fri, 26 Jan 2018 15:22:26 +0000 (16:22 +0100)]
Remove unused error variants and const eval types
Oliver Schneider [Fri, 26 Jan 2018 15:12:07 +0000 (16:12 +0100)]
Move the pattern checking code to hair
Oliver Schneider [Fri, 26 Jan 2018 14:55:12 +0000 (15:55 +0100)]
only export the two check* functions from check_match
Oliver Schneider [Fri, 26 Jan 2018 14:51:33 +0000 (15:51 +0100)]
The `const_eval` module is no more
Oliver Schneider [Fri, 26 Jan 2018 14:31:39 +0000 (15:31 +0100)]
Move lit_to_const to `pattern` and remove the now-empty `eval` module
Oliver Schneider [Fri, 26 Jan 2018 14:28:45 +0000 (15:28 +0100)]
Remove unused function
Oliver Schneider [Fri, 26 Jan 2018 14:27:38 +0000 (15:27 +0100)]
Move compare_const_vals out of `eval`
Oliver Schneider [Fri, 26 Jan 2018 14:19:01 +0000 (15:19 +0100)]
Reduce noise in error reporting
Oliver Schneider [Fri, 26 Jan 2018 13:28:58 +0000 (14:28 +0100)]
Use Mutability enum instead of bool
Oliver Schneider [Fri, 26 Jan 2018 12:54:51 +0000 (13:54 +0100)]
Prefer enum instead of magic numbers
Oliver Schneider [Fri, 26 Jan 2018 12:50:42 +0000 (13:50 +0100)]
Stop emitting `miri failed` in error messages
Oliver Schneider [Fri, 26 Jan 2018 12:45:41 +0000 (13:45 +0100)]
Rename simd shuffle function and adjust comment
Oliver Schneider [Fri, 26 Jan 2018 12:37:46 +0000 (13:37 +0100)]
Use layout::Integer over manual *size resolving
Oliver Schneider [Thu, 25 Jan 2018 15:44:45 +0000 (16:44 +0100)]
Nuke ConstInt and Const*size
Oliver Schneider [Thu, 25 Jan 2018 13:56:34 +0000 (14:56 +0100)]
Rename ConstVal::to_u128 to to_raw_bits
Oliver Schneider [Thu, 25 Jan 2018 13:15:56 +0000 (14:15 +0100)]
Destructure Rc wrapped ErrorKind in miri
Oliver Schneider [Thu, 25 Jan 2018 13:15:28 +0000 (14:15 +0100)]
Add test for #45044
Oliver Schneider [Thu, 25 Jan 2018 13:15:12 +0000 (14:15 +0100)]
Add test for attempting to use array indexing for conditional const eval
Oliver Schneider [Thu, 25 Jan 2018 12:45:57 +0000 (13:45 +0100)]
Wrap the miri ErrorKind in an Rc to reduce work in queries
Oliver Schneider [Thu, 25 Jan 2018 11:12:19 +0000 (12:12 +0100)]
Don't read from zero sized fields
Oliver Schneider [Thu, 25 Jan 2018 11:59:24 +0000 (12:59 +0100)]
Hide the RefCell inside InterpretInterner
It was too easy to get this wrong
Oliver Schneider [Thu, 25 Jan 2018 11:12:07 +0000 (12:12 +0100)]
Don't borrow the interpret_interner for anything but a direct function call
Oliver Schneider [Thu, 25 Jan 2018 08:04:00 +0000 (09:04 +0100)]
Allow tools (e.g. miri) to enable rust logging
Oliver Schneider [Thu, 25 Jan 2018 07:06:53 +0000 (08:06 +0100)]
Allow writing mutable statics in miri by adding them to the Machine
Oliver Schneider [Tue, 23 Jan 2018 15:37:39 +0000 (16:37 +0100)]
More const eval sanity checks (invalid slice fat pointers)
Oliver Schneider [Tue, 23 Jan 2018 15:36:55 +0000 (16:36 +0100)]
Enable const prop to also evaluate constants, not just literals
Oliver Schneider [Mon, 22 Jan 2018 09:21:49 +0000 (10:21 +0100)]
Additional sanity assertion
Oliver Schneider [Mon, 22 Jan 2018 09:21:22 +0000 (10:21 +0100)]
Print whether the stackframe is for a promoted
Oliver Schneider [Tue, 16 Jan 2018 09:16:38 +0000 (10:16 +0100)]
Add InterpretInterner to StableHashingContext for AllocId serialization
Oliver Schneider [Tue, 16 Jan 2018 09:15:41 +0000 (10:15 +0100)]
Add tests for fixed issues
Oliver Schneider [Mon, 15 Jan 2018 09:31:28 +0000 (10:31 +0100)]
Codegen tests