summary refs log tree commit diff
path: root/compiler/rustc_mir/src/const_eval
AgeCommit message (Collapse)AuthorLines
2021-03-16Update compiler/rustc_mir/src/const_eval/mod.rsOli Scherer-5/+4
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-15Explain pointer and dyn Trait handling in const_to_valtreeOli Scherer-9/+7
2021-03-15Explain how we encode enums at the encoding siteOli Scherer-3/+4
2021-03-15Explain why we do not allow const_to_valtree to read from staticsOli Scherer-1/+6
2021-03-12We won't support trait object constants in type level constants for the ↵Oli Scherer-3/+5
forseeable future
2021-03-12Intern valtree field vectorOli Scherer-3/+7
2021-03-12Implement valtreeOli Scherer-2/+90
valtree is a version of constants that is inherently safe to be used within types. This is in contrast to ty::Const which can have different representations of the same value. These representation differences can show up in hashing or equality comparisons, breaking type equality of otherwise equal types. valtrees do not have this problem.
2021-02-25fix reviewklensy-1/+1
2021-02-24replaced some map_or with map_or_elseklensy-1/+1
2021-02-20Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obkbors-27/+27
Pass large interpreter types by reference, not value r? `@ghost`
2021-02-17Reduce size of InterpErrorInfo to 8 bytesTomasz Miąsko-4/+8
2021-02-16Pass MPlaceTy by reference not valueTomasz Miąsko-6/+6
2021-02-16Pass PlaceTy by reference not valueTomasz Miąsko-4/+4
2021-02-16Pass OpTy by reference not valueTomasz Miąsko-17/+17
2021-02-13Heat up the ICE-y error reportingEllen-1/+1
rest in peace match bool <3
2021-02-05improve error message for disallowed ptr-to-int casts in const evalJeffrey Griffin-1/+8
2021-01-24clean up some const error reporting around promotedsRalf Jung-74/+28
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-1/+1
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-1/+1
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-0/+16
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-10Add ABI argument to `find_mir_or_eval_fn`Nym Seddon-0/+2
Add ABI argument for called function in `find_mir_or_eval_fn` and `call_extra_fn`. Useful for comparing with expected ABI in interpreters. Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)
2021-01-04Move MIR body loading to a machine functionoli-0/+16
2020-12-20promoteds in statics may refer to staticsRalf Jung-2/+6
2020-12-20validate promotedsRalf Jung-19/+9
2020-12-17Auto merge of #79840 - dvtkrlbs:issue-79667, r=oli-obkbors-68/+17
Remove memoization leftovers from constant evaluation machine Closes #79667
2020-12-11add missing constraintsTunahan Karlibas-6/+10
2020-12-11Remove unnecessary check and fix local_def_id parameterTunahan Karlibas-11/+4
2020-12-10Auto merge of #79621 - usbalbin:constier_maybe_uninit, r=RalfJungbors-0/+6
Constier maybe uninit I was playing around trying to make `[T; N]::zip()` in #79451 be `const fn`. One of the things I bumped into was `MaybeUninit::assume_init`. Is there any reason for the intrinsic `assert_inhabited<T>()` and therefore `MaybeUninit::assume_init` not being `const`? --- I have as best as I could tried to follow the instruction in [library/core/src/intrinsics.rs](https://github.com/rust-lang/rust/blob/master/library/core/src/intrinsics.rs#L11). I have no idea what I am doing but it seems to compile after some slight changes after the copy paste. Is this anywhere near how this should be done? Also any ideas for name of the feature gate? I guess `const_maybe_assume_init` is quite misleading since I have added some more methods. Should I add test? If so what should be tested?
2020-12-09Extra assertions in eval_body_using_ecx to disallow queries forTunahan Karlibas-0/+7
functions that does allocations
2020-12-09Remove memoization leftoversTunahan Karlibas-59/+4
closes #79667
2020-12-06Fix comments related to abort()Albin Hedman-0/+4
2020-12-05Fix tests (hopefully)Albin Hedman-1/+1
2020-12-05abort() now takes a msg parameterAlbin Hedman-0/+2
2020-12-03move interpret::MemoryKind::Heap to const evalVishnunarayan K I-1/+26
2020-12-03move intrinsic to CTFE, add FIXMEVishnunarayan K I-0/+17
2020-12-02add comment and bless some testsVishnunarayan K I-1/+5
2020-12-01review comment and one more testVishnunarayan K I-7/+6
2020-12-01review commentsVishnunarayan K I-2/+8
2020-11-12review commentsVishnunarayan K I-3/+2
2020-11-12check mir exists before validation; fix testsVishnunarayan K I-0/+7
2020-11-12fix tests and formattingVishnunarayan K I-1/+1
2020-11-12add error_occured field to ConstQualifs, fix #76064Vishnunarayan K I-0/+5
2020-11-05Rollup merge of #78742 - vn-ki:fix-issue-78655, r=oli-obkMara Bos-3/+5
make intern_const_alloc_recursive return error fix #78655 r? ``@oli-obk``
2020-11-04make intern_const_alloc_recursive return error fix #78655Vishnunarayan K I-3/+5
2020-11-04Add `is_null` helperoli-2/+2
This is cheaper than creating a null-`ScalarInt` and comparing and then just throwing it away.
2020-11-04Replace `Scalar::zst` with a `Scalar::ZST` constantoli-1/+1
2020-11-04s/Scalar::Raw/Scalar::Intoli-6/+6
2020-11-0432 bit platforms don't have 64 bit pointersOliver Scherer-2/+3
2020-11-04Split the "raw integer bytes" part out of `Scalar`Oliver Scherer-7/+7
2020-10-26interning cleanup: we no longer need to distinguish Const and ConstInner; we ↵Ralf Jung-8/+9
no longer need the ignore_interior_mut_in_const hack