about summary refs log tree commit diff
path: root/src/librustc_mir/interpret
AgeCommit message (Collapse)AuthorLines
2019-12-26Comments should start capitalized and end in a periodOliver Scherer-4/+4
2019-12-26Explain ParamEnv::reveal_all usageOliver Scherer-0/+5
2019-12-26Immediately evaluate and validate constants when we want them as operandsOliver Scherer-3/+10
2019-12-26Interning even happens when validation of a constant failsOliver Scherer-6/+12
2019-12-26Prevent an ICE on invalid transmutesOliver Scherer-6/+4
2019-12-26Comment on a few odd things that we should look atOliver Scherer-5/+4
2019-12-26Simplify `force_allocation_maybe_sized`Oliver Scherer-15/+4
2019-12-26Retire `to_ptr` which should already have no users but still kept getting ↵Oliver Scherer-7/+12
new ones
2019-12-26Move `eval_const_fn_call` to the `const_eval` moduleOliver Scherer-22/+1
2019-12-24x.py fmt after previous deignoreMark Rousskov-145/+126
2019-12-24Rollup merge of #67337 - oli-obk:no_mut_static_ref_from_const, r=RalfJungMazdak Farrokhzad-11/+24
Ensure that evaluating or validating a constant never reads from a static r? @RalfJung as per https://github.com/rust-lang/rust/pull/66302#issuecomment-554663387 This does not yet address the fact that evaluation of a constant can read from a static (under unleash-miri)
2019-12-23TidyOliver Scherer-1/+2
2019-12-23Rollup merge of #67546 - oli-obk:slice_pattern_ice, r=varkorMazdak Farrokhzad-1/+2
Fix ICE in mir interpretation Indices from the end start at 1 so you can immediately subtract them from the length to get the index instead of having to do an additional `-1`. Kinda documented in https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/enum.ProjectionElem.html#variant.ConstantIndex
2019-12-23Update src/librustc_mir/interpret/intern.rsOliver Scherer-1/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-12-23Dynamically prevent constants from accessing staticsOliver Scherer-5/+8
2019-12-23Panic on mutable allocs in constantsOliver Scherer-6/+15
2019-12-23Update src/librustc_mir/interpret/place.rsOliver Scherer-1/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-12-23Fix ICE in mir interpretationOliver Scherer-1/+2
2019-12-22Format the worldMark Rousskov-1179/+1016
2019-12-22Rollup merge of #67299 - christianpoveda:try_immty_from_int, r=RalfJungMazdak Farrokhzad-0/+9
Add `ImmTy::try_from_(u)int` methods r? @RalfJung
2019-12-22Rollup merge of #66877 - skinny121:const-eval-entry-points, r=oli-obkMazdak Farrokhzad-12/+5
Add simpler entry points to const eval for common usages. I found the `tcx.const_eval` API to be complex/awkward to work with, because of the inherent complexity from all of the different situations it is called from. Though it mainly used in one of the following ways: - Evaluates the value of a constant without any substitutions, e.g. evaluating a static, discriminant, etc. - Evaluates the value of a resolved instance of a constant. this happens when evaluating unevaluated constants or normalising trait constants. - Evaluates a promoted constant. This PR adds three new functions `const_eval_mono`, `const_eval_resolve`, and `const_eval_promoted` to `TyCtxt`, which each cater to one of the three ways `tcx.const_eval` is normally used.
2019-12-22Add error message if `Scalar::from_(u)int` failsChristian Poveda-2/+2
2019-12-22Add simpler entry points to const eval for common usages.Ben Lewis-12/+5
2019-12-21Change results to optionsChristian Poveda-4/+4
2019-12-21Rollup merge of #67467 - matthewjasper:test-slice-patterns, r=oli-obkMazdak Farrokhzad-4/+25
Test slice patterns more Adds tests for const evaluation and some more borrow checking tests. Fixes some bugs in const eval for subslice patterns. closes #66934 r? @oli-obk cc @Centril
2019-12-20Don't ICE in subslice pattern const-evalMatthew Jasper-4/+25
2019-12-201. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.Mazdak Farrokhzad-28/+25
2. mir::Mutability -> ast::Mutability.
2019-12-18Add Rvalue::AddressOf to MIRMatthew Jasper-1/+1
This operator creates a raw pointer to a Place directly, without first creating a reference. See RFC #2582 for motivation. The Rvalue is currently unused.
2019-12-14add ImmTy::try_from_(u)int methodsChristian Poveda-2/+11
2019-12-13Rollup merge of #67256 - RalfJung:reduce-allocs, r=oli-obkMazdak Farrokhzad-29/+22
Reduce allocs for validation errors This probably doesn't really matter, but I just felt like I had to do this... r? @oli-obk
2019-12-12avoid more intermediate allocations in validation errorsRalf Jung-23/+16
2019-12-12validation: avoid some intermediate allocationsRalf Jung-6/+6
2019-12-12dont ICE in case of invalid drop fnRalf Jung-1/+12
2019-12-11Auto merge of #66650 - matthewjasper:nonuniform-array-move, r=pnkfelixbors-4/+10
Remove uniform array move MIR passes This PR fixes a number of bugs caused by limitations of this pass * Projections from constant indexes weren't being canonicalized * Constant indexes from the start weren't being canonicalized (they could have different min_lengths) * It didn't apply to non-moves This PR makes the following changes to support removing this pass: * ConstantIndex of arrays are now generated in a canonical form (from the start, min_length is the actual length). * Subslices are now split when generating move paths and when checking subslices have been moved. Additionally * The parent move path of a projection from an array element is now calculated correctly closes #66502
2019-12-09Make const index and subslice array projections more usefulMatthew Jasper-4/+10
* `min_length` is now exact for const index elements. * const index elements are always from the start. * make array `Subslice` `PlaceElems` count both `from` and `to` from the start.
2019-12-08fix miri step debug printingRalf Jung-1/+3
2019-12-08Rollup merge of #66991 - Nashenas88:body_cache_cleanup, r=eddybMazdak Farrokhzad-1/+1
Cleanup BodyCache After this PR: - `BodyCache` is renamed to `BodyAndCache` - `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache` - `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in #65947) cc @eddyb @oli-obk
2019-12-07Auto merge of #65881 - anp:implicit-caller-location, r=eddyb,oli-obkbors-0/+16
Implement #[track_caller] attribute. (RFC 2091 4/N) Implements the `#[track_caller]` attribute in both const and codegen contexts. The const implementation walks up the stack to find the nearest untracked callsite. The codegen implementation adds an implicit argument to tracked function calls, and populates it with either a call to the previously-landed intrinsic or if the caller has `#[track_caller]` with a copy of the location passed to the current function. Also includes a little cleanup and a few comments in the other caller location areas. [Depends on: 65664](https://github.com/rust-lang/rust/pull/65664) [RFC 2091 text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [Tracking doc](https://paper.dropbox.com/doc/track_rfc_2091_impl-notes--Anf1NwnIb0xcRv31YLIadyj0Ag-rwCdRc2fi2yvRZ7syGZ9q#:uid=863513134494965680023183&h2=TODO-actually-pass-location-to)
2019-12-07Auto merge of #66927 - RalfJung:engines-dont-panic, r=oli-obkbors-8/+6
Miri core engine: use throw_ub instead of throw_panic See https://github.com/rust-lang/rust/issues/66902 for context: panicking is not really an "interpreter error", but just part of a normal Rust execution. This is a first step towards removing the `InterpError::Panic` variant: the core Miri engine does not use it any more. ConstProp and ConstEval still use it, though. This will be addressed in future PRs. From what I can tell, all the error messages this removes are actually duplicates. r? @oli-obk @wesleywiser
2019-12-06Address review feedback.Adam Perry-13/+6
2019-12-06Rename to `then_some` and `then`varkor-4/+4
2019-12-06Use `to_option` in various placesvarkor-4/+4
2019-12-05Implement #[track_caller] in const.Adam Perry-0/+23
2019-12-05rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove unneeded ↵Paul Daniel Faria-1/+1
Index impl, remove body fn rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
2019-12-04Auto merge of #66866 - oli-obk:const_fn_memoization, r=RalfJungbors-15/+4
Only memoize const fn calls during const eval Miri and other engines may want to execute the function in order to detect UB inside of them. r? @RalfJung
2019-12-04Update src/librustc_mir/interpret/terminator.rsOliver Scherer-0/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-12-04Auto merge of #66275 - oli-obk:organize-intrinsics-promotion-checks, r=RalfJungbors-63/+66
Organize intrinsics promotion checks cc @vertexclique supersedes #61835 r? @RalfJung
2019-12-03Rollup merge of #66960 - wesleywiser:fix_66787_take2, r=oli-obk,RalfJungMazdak Farrokhzad-10/+13
[const-prop] Fix ICE calculating enum discriminant Fixes #66787 Different approach than #66857 r? @oli-obk cc @RalfJung @eddyb
2019-12-03[const-prop] Fix ICE calculating enum discriminantWesley Wiser-10/+13
Fixes #66787
2019-12-03Rollup merge of #66148 - oli-obk:it_must_be_a_sign, r=RalfJungMazdak Farrokhzad-3/+40
Show the sign for signed ops on `exact_div` r? @RalfJung Cc https://github.com/rust-lang/miri/pull/961/files#r341842128 I'm fairly unhappy with the duplication and the general effort required for this. Maybe it would be better to add a `display` impl for `ImmTy`?