about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/const_eval
AgeCommit message (Collapse)AuthorLines
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
2020-10-26move UnsafeCell-in-const check from interning to validationRalf Jung-8/+9
2020-10-26ensure we intern all promoteds as InternKind::PromotedRalf Jung-10/+7
2020-10-22Fix const core::panic!(non_literal_str).Mara Bos-1/+2
2020-10-14Remove needless alloc_sliceest31-1/+1
Don't invoke alloc_slice. Arenas are temporary, empty slices are eternal!
2020-10-05query_name_of_opt_const_arg -> query_name_opt_const_argBastian Kauschke-1/+1
2020-09-30References to ZSTs may be at arbitrary aligned addressesOliver Scherer-5/+5
2020-09-28Rollup merge of #77170 - ecstatic-morse:const-fn-ptr, r=oli-obkRalf Jung-6/+0
Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]` `rustc_allow_const_fn_ptr` was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need a bespoke attribute. Now this functionality is gated under `const_fn_fn_ptr_basics` (how concise!), and `#[allow_internal_unstable(const_fn_fn_ptr_basics)]` replaces `#[rustc_allow_const_fn_ptr]`. `const_fn_fn_ptr_basics` allows function pointer types to appear in the arguments and locals of a `const fn` as well as function pointer casts to be performed inside a `const fn`. Both of these were allowed in constants and statics already. Notably, this does **not** allow users to invoke function pointers in a const context. Presumably, we will use a nicer name for that (`const_fn_ptr`?). r? @oli-obk
2020-09-27Remove `rustc_allow_const_fn_ptr`Dylan MacKenzie-6/+0
This was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need the bespoke attribute.
2020-09-27Rollup merge of #77203 - ecstatic-morse:const-stability-attr-checks, r=oli-obkJonas Schievink-1/+1
Check for missing const-stability attributes in `rustc_passes` Currently, this happens as a side effect of `is_min_const_fn`, which is non-obvious. Also adds a test for this case, since we didn't seem to have one before.
2020-09-26Auto merge of #70743 - oli-obk:eager_const_to_pat_conversion, r=eddybbors-1/+40
Fully destructure constants into patterns r? `@varkor` as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/constants.20in.20patterns/near/192789924 we should probably crater it once reviewed
2020-09-25Change error in `fn_queries` to `delay_span_bug`Dylan MacKenzie-1/+1
This should be caught by the new check in `rustc_passes`. At some point, this function will be removed entirely.
2020-09-20Implement destructuring for all aggregates and for referencesOliver Scherer-2/+1
2020-09-20Add a query for dereferencing constants of reference typeOliver Scherer-1/+41
2020-09-19Reflect the "do not call this query directly" mentality in its nameOliver Scherer-3/+3
2020-09-19RustfmtOliver Scherer-2/+2
2020-09-19Address review commentsOliver Scherer-5/+5
2020-09-19Unify the names of const eval queries and their return typesOliver Scherer-10/+10