summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
AgeCommit message (Collapse)AuthorLines
2021-11-23explain why CTFE/Miri perform truncation on shift offsetRalf Jung-1/+6
2021-11-20Revert "require full validity when determining the discriminant of a value"Ralf Jung-12/+0
This reverts commit 0a2b7d71d96a22126cce57f0dab5890d060f2259, reversing changes made to 47c1bd1bcc50b25d133f8be3d49825491c1df249. This caused several unforeseen problems: - https://github.com/rust-lang/rust/issues/91029 - https://github.com/rust-lang/rust/pull/89764#issuecomment-973588007
2021-11-20Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obkMatthias Krüger-32/+55
fix CTFE/Miri simd_insert/extract on array-style repr(simd) types The changed test would previously fail since `place_index` would just return the only field of `f32x4`, i.e., the array -- rather than *indexing into* the array which is what we have to do. The new helper methods will also be needed for https://github.com/rust-lang/miri/issues/1912. r? ``````@oli-obk``````
2021-11-19Rollup merge of #90895 - RalfJung:read-discriminant-valid, r=oli-obkYuki Okushi-0/+12
require full validity when determining the discriminant of a value This resolves (for now) the semantic question that came up in https://github.com/rust-lang/rust/pull/89764: arguably, reading the discriminant of a value is 'using' that value, so we are in our right to demand full validity. Reading a discriminant is somewhat special in that it works for values of *arbitrary* type; all the other primitive MIR operations work on specific types (e.g. `bool` or an integer) and basically implicitly require validity as part of just "doing their job". The alternative would be to just require that the discriminant itself is valid, if any -- but then what do we do for types that do not have a discriminant, which kind of validity do we check? [This code](https://github.com/rust-lang/rust/blob/81117ff930fbf3792b4f9504e3c6bccc87b10823/compiler/rustc_codegen_ssa/src/mir/place.rs#L206-L215) means we have to at least reject uninhabited types, but I would rather not special case that. I don't think this can be tested in CTFE (since validity is not enforced there), I will add a compile-fail test to Miri: ```rust #[allow(enum_intrinsics_non_enums)] fn main() { let i = 2u8; std::mem::discriminant(unsafe { &*(&i as *const _ as *const bool) }); // UB } ``` (I tried running the check even on the CTFE machines, but then it runs during ConstProp and that causes all sorts of problems. We could run it for ConstEval but not ConstProp, but that simply does not seem worth the effort currently.) r? ``@oli-obk``
2021-11-18fix CTFE/Miri simd_insert/extract on array-style repr(simd) typesRalf Jung-32/+55
2021-11-14require full validity when determining the discriminant of a valueRalf Jung-0/+12
2021-11-13fix ICE on Miri/CTFE copy of half a pointerRalf Jung-7/+6
2021-11-10Auto merge of #88670 - camelid:miri-uninit-num, r=RalfJungbors-5/+12
miri: Detect uninitialized integers and floats Part of rust-lang/miri#1340. Companion Miri PR: rust-lang/miri#1904 r? `@RalfJung`
2021-11-09miri: Detect uninitialized integers and floatsNoah Lev-5/+12
Change the Miri engine to allow configuring whether to check initialization of integers and floats. This allows the Miri tool to optionally check for initialization if requested by the user.
2021-11-06use matches!() macro in more placesMatthias Krüger-8/+4
2021-10-23Rollup merge of #89920 - hudson-ayers:location-detail-control, r=davidtwcoMatthias Krüger-4/+11
Implement -Z location-detail flag This PR implements the `-Z location-detail` flag as described in https://github.com/rust-lang/rfcs/pull/2091 . `-Z location-detail=val` controls what location details are tracked when using `caller_location`. This allows users to control what location details are printed as part of panic messages, by allowing them to exclude any combination of filenames, line numbers, and column numbers. This option is intended to provide users with a way to mitigate the size impact of `#[track_caller]`. Some measurements of the savings of this approach on an embedded binary can be found here: https://github.com/rust-lang/rust/issues/70579#issuecomment-942556822 . Closes #70580 (unless people want to leave that open as a place for discussion of further improvements). This is my first real PR to rust, so any help correcting mistakes / understanding side effects / improving my tests is appreciated :) I have one question: RFC 2091 specified this as a debugging option (I think that is what -Z implies?). Does that mean this can never be stabilized without a separate MCP? If so, do I need to submit an MCP now, or is the initial RFC specifying this option sufficient for this to be merged as is, and then an MCP would be needed for eventual stabilization?
2021-10-21Configure saved panic locations based on location-detail flagHudson Ayers-4/+11
2021-10-17Auto merge of #89514 - davidtwco:polymorphize-shims-and-predicates, r=lcnrbors-1/+2
polymorphization: shims and predicates Supersedes #75737 and #75414. This pull request includes up some changes to polymorphization which hadn't landed previously and gets stage2 bootstrapping and the test suite passing when polymorphization is enabled. There are still issues with `type_id` and polymorphization to investigate but this should get polymorphization in a reasonable state to work on. - #75737 and #75414 both worked but were blocked on having the rest of the test suite pass (with polymorphization enabled) with and without the PRs. It makes more sense to just land these so that the changes are in. - #75737's changes remove the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. This won't have much of an effect until polymorphization's analysis is more advanced, but it doesn't hurt. - #75414's changes remove all logic which marks parameters as used based on their presence in predicates - given #75675, this will enable more polymorphization and avoid the symbol clashes that predicate logic previously sidestepped. - Polymorphization now explicitly checks (and skips) foreign items, this is necessary for stage2 bootstrapping to work when polymorphization is enabled. - The conditional determining the emission of a note adding context to a post-monomorphization error has been modified. Polymorphization results in `optimized_mir` running for shims during collection where that wouldn't happen previously, some errors are emitted during `optimized_mir` and these were considered post-monomorphization errors with the existing logic (more errors and shims have a `DefId` coming from the std crate, not the local crate), adding a note that resulted in tests failing. It isn't particularly feasible to change where polymorphization runs or prevent it from using `optimized_mir`, so it seemed more reasonable to not change the conditional. - `characteristic_def_id_of_type` was being invoked during partitioning for self types of impl blocks which had projections that depended on the value of unused generic parameters of a function - this caused a ICE in a debuginfo test. If partitioning is enabled and the instance needs substitution then this is skipped. That test still fails for me locally, but not with an ICE, but it fails in a fresh checkout too, so 🤷‍♂️. r? `@lcnr`
2021-10-15Rollup merge of #89859 - RalfJung:write-discriminant, r=oli-obkMatthias Krüger-1/+15
add dedicated error variant for writing the discriminant of an uninhabited enum variant This is conceptually different from hitting an `Unreachable` terminator. Also add some sanity check making sure we don't write discriminants of things that do not have discriminants. r? ``@oli-obk``
2021-10-14add dedicated error variant for writing the discriminant of an uninhabited ↵Ralf Jung-1/+15
enum variant
2021-10-12Add const_eval_select intrinsicDeadbeef-1/+1
2021-10-08Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisabors-1/+1
Turn vtable_allocation() into a query This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query. The change is pretty straightforward and should be backportable without too much effort. Fixes https://github.com/rust-lang/rust/issues/89598.
2021-10-07Turn tcx.vtable_allocation() into a query.Michael Woerister-1/+1
2021-10-03Remove re-export.Camille GILLOT-1/+1
2021-10-01polymorphize: polymorphize shimsDavid Wood-1/+2
This commit removes the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. Signed-off-by: David Wood <david.wood@huawei.com>
2021-09-29CTFE: extra assertions for Aggregate rvalues; remove unnecessarily eager ↵Ralf Jung-7/+9
special case
2021-09-29remove outdated commentRalf Jung-1/+0
2021-09-25Introduce `Rvalue::ShallowInitBox`Gary Guo-0/+6
2021-09-20Enable 2021 compatibility lints for all in-tree codeMark Rousskov-1/+1
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
2021-09-14Remove implementation of `min_align_of` intrinsicTomasz Miąsko-7/+2
Since 88839 `min_align_of` is lowered to AlignOf operator.
2021-09-12Auto merge of #88839 - nbdd0121:alignof, r=nagisabors-8/+10
Introduce NullOp::AlignOf This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`. The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
2021-09-13Introduce NullOp::AlignOfGary Guo-8/+10
2021-09-09Rename `(un)signed` to `(un)signed_int`Andreas Liljeqvist-2/+2
2021-09-09Move `unsigned_max` etc into `Size` againAndreas Liljeqvist-6/+4
2021-09-09Remove cloneAndreas Liljeqvist-1/+1
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-16/+13
fix fix Remove more refs and clones fix more fix
2021-09-09Add methods for checking for full ranges to `Scalar` and `WrappingRange`Andreas Liljeqvist-15/+13
Move *_max methods back to util change to inline instead of inline(always) Remove valid_range_exclusive from scalar Use WrappingRange instead implement always_valid_for in a safer way Fix accidental edit
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-0/+9026