about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2022-04-10Avoid accessing HIR from MIR queries.Camille GILLOT-14/+4
2022-04-08use deref on ImmTyb-naber-4/+3
2022-04-08create leafs for slicesb-naber-116/+63
2022-04-07interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internalRalf Jung-50/+60
2022-04-06Auto merge of #95707 - RalfJung:initialized, r=oli-obkbors-4/+22
interp/validity: enforce Scalar::Initialized This is a follow-up to https://github.com/rust-lang/rust/pull/94527, to also account for the new kind of `Scalar` layout inside the validity checker. r? `@oli-obk`
2022-04-06Rollup merge of #95693 - RalfJung:more-context, r=oli-obkDylan DPC-7/+13
interp: pass TyCtxt to Machine methods that do not take InterpCx This just seems like something you might need, so let's consistently have it. One day we might have to add `ParamEnv` as well, though that seems less likely (and in Miri you can always use `reveal_all` anyway). It might make sense to have a type that packages `TyCtxt` and `ParamEnv`, this pairing occurs quite frequently in rustc... r? `@oli-obk`
2022-04-05interp/validity: enforce Scalar::InitializedRalf Jung-4/+22
2022-04-05interp: pass TyCtxt to Machine methods that do not take InterpCxRalf Jung-7/+13
2022-04-05Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardinbors-18/+27
Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized. follow up to #94411 To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union cc `@RalfJung` r? `@ghost`
2022-04-05mir-interpret now treats unions as non-immediate, even if they have scalar ↵Oli Scherer-7/+11
layout, allowing partially initializing them
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-13/+18
initialized scalars can special case them.
2022-04-03tweak some function namesRalf Jung-14/+14
2022-04-03interpret: remove MemoryExtra in favor of giving access to the MachineRalf Jung-238/+192
2022-04-01Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obkbors-31/+35
Encode even more metadata through tables instead of EntryKind This should move us closer to getting rid of `EntryKind`.
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-31/+35
2022-03-31catch overflow in slice size computationRalf Jung-1/+2
2022-03-31audit check_mul uses in interpretRalf Jung-1/+7
2022-03-31interpret: make isize::MAX the limit for dynamic value sizesRalf Jung-8/+10
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-1/+1
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPCbors-8/+8
Rollup of 5 pull requests Successful merges: - #95294 (Document Linux kernel handoff in std::io::copy and std::fs::copy) - #95443 (Clarify how `src/tools/x` searches for python) - #95452 (fix since field version for termination stabilization) - #95460 (Spellchecking compiler code) - #95461 (Spellchecking some comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-30Spellchecking some commentsYuri Astrakhan-8/+8
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-1/+1
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-29include refs in valtree creationb-naber-29/+158
2022-03-28Normalize all projections in mir validation againOli Scherer-1/+6
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-8/+16
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-26interpret: with enforce_number_validity, ensure integers are truly ↵Ralf Jung-3/+6
Scalar::Int (i.e., no pointers)
2022-03-26interpret: mark a dead match arm as deadRalf Jung-1/+2
2022-03-26Auto merge of #95149 - cjgillot:once-diag, r=estebankbors-2/+2
Remove `Session::one_time_diagnostic` This is untracked mutable state, which modified the behaviour of queries. It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes). It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter. A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics. As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-25Rollup merge of #94655 - JakobDegen:mir-phase-docs, r=oli-obkDylan DPC-28/+48
Clarify which kinds of MIR are allowed during which phases. This enhances documentation with these details and extends the validator to check these requirements more thoroughly. Most of these conditions were already being checked. There was also some disagreement between the `MirPhase` docs and validator as to what it meant for the `body.phase` field to have a certain value. This PR resolves those disagreements in favor of the `MirPhase` docs (which is what the pass manager implemented), adjusting the validator accordingly. The result is now that the `DropLowering` phase begins with the end of the elaborate drops pass, and lasts until the beginning of the generator lowring pass. This doesn't feel entirely natural to me, but as long as it's documented accurately it should be ok. r? rust-lang/mir-opt
2022-03-23Clarify which kinds of MIR are allowed during which phases.Jakob Degen-28/+48
This enhances documentation with these details and extends the validator to check these requirements more thoroughly. As a part of this, we add a new `Deaggregated` phase, and rename other phases so that their names more naturally correspond to what they represent.
2022-03-23Rollup merge of #95221 - RalfJung:check_and_deref_ptr, r=oli-obkMatthias Krüger-15/+5
interpret/memory: simplify check_and_deref_ptr *Finally* I saw a way to make this code simpler. The odd preprocessing in `let ptr_or_addr =` has bothered me since forever, but it actually became unnecessary in the last provenance refactoring. :) This also leads to slightly more explicit error messages as a nice side-effect. :tada: r? `@oli-obk`
2022-03-23Auto merge of #94901 - fee1-dead:destructable, r=oli-obkbors-9/+7
Rename `~const Drop` to `~const Destruct` r? `@oli-obk` Completely switching to `~const Destructible` would be rather complicated, so it seems best to add it for now and wait for it to be backported to beta in the next release. The rationale is to prevent complications such as #92149 and #94803 by introducing an entirely new trait. And `~const Destructible` reads a bit better than `~const Drop`. Name Bikesheddable.
2022-03-22interpret/memory: simplify check_and_deref_ptrRalf Jung-15/+5
2022-03-22interpret/validity: improve clarityRalf Jung-3/+2
2022-03-21rename LocalState::Uninitialized to UnallocatedRalf Jung-12/+10
2022-03-21Rename `~const Drop` to `~const Destruct`Deadbeef-9/+7
2022-03-20Take &mut Diagnostic in emit_diagnostic.Camille GILLOT-2/+2
Taking a Diagnostic by move would break the usual pattern `diag.label(..).emit()`.
2022-03-20Auto merge of #95071 - RalfJung:arbitrary-self-dyn, r=oli-obkbors-15/+40
Miri: implement arbitrary-self dyn receivers Roughly follows the [codegen logic](https://github.com/rust-lang/rust/blob/851fcc7a54262748b1aa9e16de91453998d896f3/compiler/rustc_codegen_ssa/src/mir/block.rs#L809). Fixes https://github.com/rust-lang/miri/issues/1038 r? `@oli-obk` Cc `@eddyb`
2022-03-18Miri: implement arbitrary-self dyn receiversRalf Jung-15/+40
2022-03-16rustc_error: make ErrorReported impossible to constructmark-11/+14
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-12Auto merge of #94733 - nnethercote:fix-AdtDef-interning, r=fee1-deadbors-19/+22
Improve `AdtDef` interning. This commit makes `AdtDef` use `Interned`. Much of the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`. r? `@fee1-dead`
2022-03-11Rollup merge of #94827 - RalfJung:offset-from-ub, r=oli-obkDylan DPC-41/+45
CTFE/Miri: detect out-of-bounds pointers in offset_from Also I became uneasy with aggressively doing `try_to_int` here -- this will always succeed on Miri, leading to the wrong codepath being taken. We should rather try to convert them both to pointers, and use the integer path as a fallback, so that's what I implemented now. Hiding whitespaces helps with the diff. Fixes https://github.com/rust-lang/miri/issues/1950 r? ``@oli-obk``
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-19/+22
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-10adjust offset_from logic: check that both pointers are in-boundsRalf Jung-41/+45
2022-03-09normalization change and rebaseb-naber-1/+12
2022-03-07Stabilize const_impl_trait as wellEric Holk-22/+0
2022-03-07Remove dead/useless codeEric Holk-58/+0
2022-03-07Update tests after feature stabilizationEric Holk-59/+0
2022-03-07Stabilize const_fn_fn_ptr_basics and const_fn_trait_boundEric Holk-125/+4
2022-03-07Rollup merge of #94685 - RalfJung:saturating, r=oli-obkMatthias Krüger-39/+45
interpret: move saturating_add/sub into (pub) helper method I plan to use them for `simd_saturating_add/sub`. The first commit just moves code, the 2nd simplifies it a bit with some helper methods that did not exist yet when the code was originally written.