about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2022-06-28Validate all fields of box instead of validating allocator specificallyDrMeepster-2/+2
2022-06-27make AllocKind actually publicRalf Jung-1/+1
2022-06-26interpret: refactor allocation info queryRalf Jung-51/+34
We now have an infallible function that also tells us which kind of allocation we are talking about. Also we do longer have to distinguish between data and function allocations for liveness.
2022-06-26validate box's allocatorDrMeepster-0/+3
2022-06-26fix box with custom allocator in miriDrMeepster-17/+4
2022-06-26interpret: do not prune requires_caller_location stack frames quite so earlyRalf Jung-18/+13
2022-06-22Rollup merge of #98099 - RalfJung:convert_tag_add_extra, r=oli-obkYuki Okushi-11/+15
interpret: convert_tag_add_extra: allow tagger to raise errors Needed for https://github.com/rust-lang/miri/issues/2234 r? `@oli-obk`
2022-06-21Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obkbors-50/+69
Remove dereferencing of Box from codegen Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains. Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-19Mention formatting macros when encountering ArgumentV1::new in constMichael Goulet-1/+11
2022-06-16interpret: convert_tag_add_extra, init_allocation_extra: allow tagger to ↵Ralf Jung-11/+15
raise errors
2022-06-15make sure miri ices when dereferencing a boxDrMeepster-0/+5
2022-06-15remove box derefs from codgenDrMeepster-50/+64
2022-06-15Rename `impl_constness` to `constness`Deadbeef-7/+8
The current code is a basis for `is_const_fn_raw`, and `impl_constness` is no longer a valid name, which is previously used for determining the constness of impls, and not items in general.
2022-06-14rebaseb-naber-3/+3
2022-06-14correctly create Scalar for meta infob-naber-3/+7
2022-06-14address reviewb-naber-17/+54
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-169/+132
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-9/+10
And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant.
2022-06-13Rollup merge of #98043 - TaKO8Ki:remove-unnecessary-to-string, r=davidtwcoMatthias Krüger-1/+1
Remove unnecessary `to_string` and `String::new` https://github.com/rust-lang/rust/pull/96468/commits/73fa217bc11fbac76f730223f6766c8e03513b5e changed the type of the `suggestion` argument to `impl ToString`. This patch removes unnecessary `to_string` and `String::new`. cc: `````@davidtwco`````
2022-06-13Rollup merge of #97960 - RalfJung:offset-from, r=oli-obkMatthias Krüger-67/+70
interpret: unify offset_from check with offset check `offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call. I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance). I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that. r? ``````@oli-obk``````
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-1/+1
2022-06-11Try out `yeet` in the MIR interpreterScott McMurray-0/+1
2022-06-11Rollup merge of #97761 - RalfJung:vtable-validation, r=cjgillotDylan DPC-0/+8
validating the vtable can lead to Stacked Borrows errors Fixes https://github.com/rust-lang/miri/issues/2123
2022-06-09interpret: unify offset_from check with offset checkRalf Jung-67/+70
2022-06-09Auto merge of #97740 - RalfJung:ctfe-cycle-spans, r=lcnrbors-19/+23
use precise spans for recursive const evaluation This fixes https://github.com/rust-lang/rust/issues/73283 by using a `TyCtxtAt` with a more precise span when the interpreter recursively calls itself. Hopefully such calls are sufficiently rare that this does not cost us too much performance. (In theory, cycles can also arise through layout computation, as layout can depend on consts -- but layout computation happens all the time so we'd have to do something to not make this terrible for performance.)
2022-06-08Rollup merge of #97763 - RalfJung:fallible-cast, r=lcnrDylan DPC-6/+7
Allow ptr_from_addr_cast to fail This is needed for https://github.com/rust-lang/miri/issues/2133: I would like to have an option in Miri to error when a int2ptr cast is executed.
2022-06-08Auto merge of #97447 - nnethercote:improve-folding, r=jackh726bors-2/+2
Folding revamp r? `@ghost`
2022-06-08Folding revamp.Nicholas Nethercote-2/+2
This commit makes type folding more like the way chalk does it. Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods. - `fold_with` is the standard entry point, and defaults to calling `super_fold_with`. - `super_fold_with` does the actual work of traversing a type. - For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead calls into a `TypeFolder`, which can then call back into `super_fold_with`. With the new approach, `TypeFoldable` has `fold_with` and `TypeSuperFoldable` has `super_fold_with`. - `fold_with` is still the standard entry point, *and* it does the actual work of traversing a type, for all types except types of interest. - `super_fold_with` is only implemented for the types of interest. Benefits of the new model. - I find it easier to understand. The distinction between types of interest and other types is clearer, and `super_fold_with` doesn't exist for most types. - With the current model is easy to get confused and implement a `super_fold_with` method that should be left defaulted. (Some of the precursor commits fixed such cases.) - With the current model it's easy to call `super_fold_with` within `TypeFolder` impls where `fold_with` should be called. The new approach makes this mistake impossible, and this commit fixes a number of such cases. - It's potentially faster, because it avoids the `fold_with` -> `super_fold_with` call in all cases except types of interest. A lot of the time the compile would inline those away, but not necessarily always.
2022-06-07Remove `AlwaysLiveLocals` wrapper structTomasz Miąsko-4/+4
It is just a wrapper around a `BitSet` and doesn't have any functionality of its own.
2022-06-06Auto merge of #97795 - Dylan-DPC:rollup-dxilagr, r=Dylan-DPCbors-6/+1
Rollup of 5 pull requests Successful merges: - #97312 (Compute lifetimes in scope at diagnostic time) - #97495 (Add E0788 for improper #[no_coverage] usage) - #97579 (Avoid creating `SmallVec`s in `global_llvm_features`) - #97767 (interpret: do not claim UB until we looked more into variadic functions) - #97787 (E0432: rust 2018 -> rust 2018 or later in --explain message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-06Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obkbors-18/+45
interpret: better control over whether we read data with provenance The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen. This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`). The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!
2022-06-05interpret: do not claim UB until we looked more into variadic functionsRalf Jung-6/+1
2022-06-05validating the vtable can lead to Stacked Borrows errorsRalf Jung-0/+8
2022-06-05Allow ptr_from_addr_cast to failRalf Jung-6/+7
2022-06-05reduce code duplicationRalf Jung-13/+12
2022-06-05interpret: better control over whether we read data with provenance, and ↵Ralf Jung-18/+46
implicit provenance stripping where possible
2022-06-04use precise spans for recursive const evaluationRalf Jung-3/+4
2022-06-04const_prop_lint: ensure we have up-to-date cur_span()Ralf Jung-1/+4
2022-06-04Move statement_index increment out of statement() functionRalf Jung-9/+9
That function is called by const_prop, where updating the index like that is totally meaningless.
2022-06-04tweak some bug!sRalf Jung-6/+6
2022-06-03Rollup merge of #97663 - RalfJung:keine-halben-sachen, r=oli-obkDylan DPC-3/+3
take back half-baked noaliasing check in Assignment Doing an aliasing check in `copy_op` does not make a ton of sense. We have to eventually do something in the `Assignment` statement handling instead.
2022-06-02take back half-baked noaliasing check in AssignmentRalf Jung-3/+3
2022-06-02commentRalf Jung-1/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-06-02add cast kind of from_exposed_addr (int-to-ptr casts)Ralf Jung-21/+34
2022-06-02Rollup merge of #97626 - RalfJung:expose, r=tmiaskoYuki Okushi-5/+5
rename PointerAddress → PointerExposeAddress `PointerAddress` sounds a bit too much like `ptr.addr()`, but this corresponds to `ptr.expose_addr()`. r? `@tmiasko`
2022-06-01rename PointerAddress → PointerExposeAddressRalf Jung-5/+5
2022-06-01Rollup merge of #97216 - RalfJung:null-ptr-check, r=oli-obkYuki Okushi-0/+4
Ensure we never consider the null pointer dereferencable This replaces the checks that are being removed in https://github.com/rust-lang/rust/pull/97188. Those checks were too early and hence incorrect.
2022-05-31Add a pointer to address cast kindTomasz Miąsko-36/+30
A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-30Rollup merge of #97395 - RalfJung:call-abi, r=oli-obkMichael Goulet-1/+8
Miri call ABI check: ensure type size+align stay the same We should almost certainly not accept calls where caller and callee disagree on the size or alignment of the type. The checks we do *almost* imply that, except that `ScalarPair` types can have `repr(align)` and thus differ in size/align even when they are pairs of the same primitive type. r? ``@oli-obk``
2022-05-30Auto merge of #97025 - ouz-a:mini-derefer-generator, r=davidtwcobors-1/+10
Add validation layer for Derefer _Follow up work to #96549 #96116 #95857 #95649_ This adds validation for Derefer making sure it is always the first projection. r? rust-lang/mir-opt