about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2022-07-14interpret/validity: improve some commentsRalf Jung-2/+4
2022-07-14Use constant eval to do strict validity checks5225225-30/+74
2022-07-14rename MPlaceTy::dangling to fake_alloc_zstRalf Jung-2/+4
2022-07-14Remove comment referring to constness.rsDaniel Bevenius-2/+0
This commit removes the comment in emulate_intrinsic, which is currently referring to 'src/librustc_middle/ty/constness.rs'.
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-6/+6
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPCbors-4/+4
Rollup of 5 pull requests Successful merges: - #98574 (Lower let-else in MIR) - #99011 (`UnsafeCell` blocks niches inside its nested type from being available outside) - #99030 (diagnostics: error messages when struct literals fail to parse) - #99155 (Keep unstable target features for asm feature checking) - #99199 (Refactor: remove an unnecessary `span_to_snippet`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-13Auto merge of #98145 - ouz-a:some_branch, r=oli-obkbors-1/+23
Pull Derefer before ElaborateDrops _Follow up work to #97025 #96549 #96116 #95887 #95649_ This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`. r? `@oli-obk`
2022-07-13get rid of MemPlaceMeta::PoisonRalf Jung-21/+10
MPlaceTy::dangling still exists, but now it is only called in places that actually conceptually allocate something new, so that's fine.
2022-07-13Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddybDylan DPC-4/+4
`UnsafeCell` blocks niches inside its nested type from being available outside fixes #87341 This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646 Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-13Auto merge of #99101 - RalfJung:interpret-projections, r=oli-obkbors-432/+540
interpret: refactor projection handling code Moves our projection handling code into a common file, and avoids the use of a general mplace-based fallback function by have more specialized implementations. mplace_index (and the other slice-related functions) could be more efficient by copy-pasting the body of operand_index. Or we could do some trait magic to share the code between them. But for now this is probably fine. This is the common part of https://github.com/rust-lang/rust/pull/99013 and https://github.com/rust-lang/rust/pull/99097. I am seeing some strange perf results so this probably should be its own change so we know which diff caused which perf changes... r? `@oli-obk`
2022-07-12add new rval, pull deref earlyouz-a-1/+23
2022-07-11use a loop rather than try_foldRalf Jung-23/+21
2022-07-11interpret: refactor projection handling codeRalf Jung-421/+531
Moves our projection handling code into a common file, and avoids the use of a general mplace-based fallback function by have more specialized implementations. mplace_index (and the other slice-related functions) could be more efficient by copy-pasting the body of operand_index. Or we could do some trait magic to share the code between them. But for now this is probably fine.
2022-07-11Rollup merge of #99140 - TaKO8Ki:implement-is-accessible-span, r=fee1-deadDylan DPC-1/+1
Implement `SourceMap::is_span_accessible` This patch adds `SourceMap::is_span_accessible` and replaces `span_to_snippet(span).is_ok()` and `span_to_snippet(span).is_err()` with it. This removes a `&str` to `String` conversion.
2022-07-11rename a methodTakayuki Maeda-1/+1
2022-07-11implement `is_accessible_span`Takayuki Maeda-1/+1
2022-07-11Deny floats even when adt_const_params is enabledMichael Goulet-1/+1
2022-07-09Auto merge of #98957 - RalfJung:zst-are-different, r=lcnr,oli-obkbors-14/+11
don't allow ZST in ScalarInt There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So I propose we stop using ScalarInt to represent ZST (which are clearly not integers). Instead, we can add new ZST variants to those types that did not have other variants which could be used for this purpose. Based on https://github.com/rust-lang/rust/pull/98831. Only the commits starting from "don't allow ZST in ScalarInt" are new. r? `@oli-obk`
2022-07-09tweak names and output and blessRalf Jung-3/+3
2022-07-09review feedbackRalf Jung-3/+3
2022-07-09don't allow ZST in ScalarIntRalf Jung-14/+11
There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So instead add new ZST variants to those types that did not have other variants which could be used for this purpose.
2022-07-09Rollup merge of #99050 - JakobDegen:storage-docs, r=tmiaskoMatthias Krüger-1/+7
Clarify MIR semantics of storage statements Seems worthwhile to start closing out some of the less controversial open questions about MIR semantics. Hopefully this is fairly non-controversial - it's what we implement already, and I see no reason to do anything more restrictive. cc ``@tmiasko`` who commented on this when it was discussed in the original PR that added these docs.
2022-07-09Rollup merge of #99022 - pierwill:always-storage-live-locals, r=pierwillMatthias Krüger-4/+4
MIR dataflow: Rename function to `always_storage_live_locals` Related to #99021. r? ```@JakobDegen``` (as discussed on Zulip)
2022-07-09Rollup merge of #98980 - RalfJung:const-prop-ice, r=oli-obkDylan DPC-7/+11
fix ICE in ConstProp Fixes https://github.com/rust-lang/rust/issues/96169
2022-07-08Clarify MIR semantics of storage statementsJakob Degen-1/+7
2022-07-08interpret: only to track_caller in debug builds due to perfRalf Jung-4/+4
2022-07-08Migrate MutDeref, TransientMutBorrow diagnosticsMichael Goulet-18/+40
2022-07-08Migrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnosticsMichael Goulet-23/+30
2022-07-08Migrate StaticAccess diagnosticMichael Goulet-19/+21
2022-07-08Migrate NonConstOp diagnosticMichael Goulet-7/+9
2022-07-08Migrate unstable-in-stable diagnosticMichael Goulet-20/+25
2022-07-07MIR dataflow: Rename function to `always_storage_live_locals`pierwill-4/+4
Related to #99021.
2022-07-07Rollup merge of #98979 - RalfJung:more-alloc-range, r=oli-obkMatthias Krüger-2/+2
interpret: use AllocRange in UninitByteAccess also use nice new format string syntax in `interpret/error.rs`, and use the `#` flag to add `0x` prefixes where applicable. r? ``@oli-obk``
2022-07-07make a name less ambiguousRalf Jung-7/+7
2022-07-07Rollup merge of #98930 - tmiasko:pub-basic-blocks, r=oli-obkDylan DPC-2/+3
Make MIR basic blocks field public This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
2022-07-07Rollup merge of #96856 - DrMeepster:fix_projection_validation, r=IcnrDylan DPC-6/+43
Fix ProjectionElem validation `TypeChecker::visit_projection_elem` was not actually being called.
2022-07-07`UnsafeCell` now has no niches, ever.Oli Scherer-4/+4
2022-07-07Make MIR basic blocks field publicTomasz Miąsko-2/+3
This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
2022-07-06Auto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obkbors-223/+243
interpret: remove support for unsized_locals I added support for unsized_locals in https://github.com/rust-lang/rust/pull/59780 but the current implementation is a crude hack and IMO definitely not the right way to have unsized locals in MIR. It also [causes problems](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Missing.20Layout.20Check.20in.20.60interpret.2Foperand.2Ers.60.3F). and what codegen does is unsound and has been for years since clearly nobody cares (so I hope nobody actually relies on that implementation and I'll be happy if Miri ensures they do not). I think if we want to have unsized locals in Miri/MIR we should add them properly, either by having a `StorageLive` that takes metadata or by having an `alloca` that returns a pointer (making the ptr indirection explicit) or something like that. So, this PR removes the `LocalValue::Unallocated` hack. It adds `Immediate::Uninit`, for several reasons: - This lets us still do fairly little work in `push_stack_frame`, in particular we do not actually have to create any allocations. - If/when I remove `ScalarMaybeUninit`, we will need something like this to have an "optimized" representation of uninitialized locals. Without this we'd have to put uninitialized integers into the heap! - const-prop needs some way to indicate "I don't know the value of this local'; it used to use `LocalValue::Unallocated` for that, now it can use `Immediate::Uninit`. There is still a fundamental difference between `LocalValue::Unallocated` and `Immediate::Uninit`: the latter is considered a regular local that you can read from and write to, it just has a more optimized representation when compared with an actual `Allocation` that is fully uninit. In contrast, `LocalValue::Unallocated` had this really odd behavior where you would write to it but not read from it. (This is in fact what caused the problems mentioned above.) While at it I also did two drive-by cleanups/improvements: - In `pop_stack_frame`, do the return value copying and local deallocation while the frame is still on the stack. This leads to better error locations being reported. The old errors were [sometimes rather confusing](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.202022-06-24/near/287445522). - Deduplicate `copy_op` and `copy_op_transmute`. r? `@oli-obk`
2022-07-06Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, ↵Guillaume Gomez-3/+2
r=cjgillot Replace some `guess_head_span` with `def_span` This patch fixes a part of #97417. r? `@cjgillot`
2022-07-06deduplicate some copy_op codeRalf Jung-87/+74
2022-07-06support passing unsized fn argumentsRalf Jung-12/+54
2022-07-06interpret: remove LocalValue::Unallocated, add Operand::UninitRalf Jung-149/+140
Operand::Uninit is an *allocated* operand that is fully uninitialized. This lets us lazily allocate the actual backing store of *all* locals (no matter their ABI). I also reordered things in pop_stack_frame at the same time. I should probably have made that a separate commit...
2022-07-06fix ICE in ConstPropRalf Jung-5/+5
2022-07-06add track_caller to some interpreter functionsRalf Jung-0/+4
2022-07-06interpret: use AllocRange in UninitByteAccessRalf Jung-2/+2
also use nice new format string syntax in interpret/error.rs
2022-07-06replace `guess_head_span` with `def_span`Takayuki Maeda-3/+2
2022-07-06Rollup merge of #98968 - RalfJung:scalar-sanity, r=oli-obkDylan DPC-4/+3
assert Scalar sanity With https://github.com/rust-lang/rust/pull/96814 having landed, finally our `Scalar` layouts have the invariants they deserve. :)
2022-07-06Rollup merge of #98964 - RalfJung:typo, r=Dylan-DPCDylan DPC-3/+3
fix typo in function name I don't know what I was doing when I named that function... follow-up to #98888 r? `@oli-obk`
2022-07-06fix projectionelem validationDrMeepster-6/+43