about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret
AgeCommit message (Collapse)AuthorLines
2021-07-08PR feedbackScott McMurray-1/+2
- Add `:Sized` assertion in interpreter impl - Use `Scalar::from_bool` instead of `ScalarInt: From<bool>` - Remove unneeded comparison in intrinsic typeck - Make this UB to call with undef, not just return undef in that case
2021-07-08Stop generating `alloca`s+`memcmp` for simple array equalityScott McMurray-0/+18
2021-07-08Move [debug_]assert_matches to mod {core, std}::assert.Mara Bos-0/+1
2021-07-04Combine individual limit queries into single `limits` queryAaron Hill-1/+1
2021-07-04Query-ify global limit attribute handlingAaron Hill-0/+5
2021-07-03Make vtable_allocation always succeedSmitty-1/+1
2021-07-02Allocation failure in constprop panics right awaySmitty-1/+4
2021-06-29Unwrap allocated Location at creationSmitty-9/+8
2021-06-29Support allocation failures when interperting MIRSmitty-16/+19
Note that this breaks Miri. Closes #79601
2021-06-28Update other codegens to use tcx managed vtable allocations.Charles Lew-91/+6
2021-06-27Change miri to use tcx allocated allocations.Charles Lew-29/+36
2021-06-16Auto merge of #86291 - crlf0710:trait_vtbl_refactor, r=bjorn3bors-35/+57
Refactor vtable codegen This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends. This is preparation for the implementation of trait upcasting feature. cc #65991 Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3. cc `@RalfJung` `@bjorn3`
2021-06-15Refactor to make interpreter and codegen backend neutral to vtable internal ↵Charles Lew-35/+57
representation.
2021-06-14Adjust `throw_validation_failure` macro to shorten the use of ↵Rémy Rakic-13/+10
`with_no_trimmed_paths`
2021-06-13Improve CTFE validation error messageRémy Rakic-8/+12
2021-06-13Turn incorrect vtable size/alignment errors into hard const-UB errorsRémy Rakic-9/+10
They were "freeform const UB" error message, but could reach validation and trigger ICEs there. We now catch them during validation to avoid that.
2021-06-12Rollup merge of #86174 - lqd:const-ub-align, r=RalfJungYuki Okushi-1/+3
Detect incorrect vtable alignment during const eval This PR fixes #86132 by detecting invalid alignment values for trait objects in the interpreter, and emitting an error about this conversion failure, to avoid the ICE. I've noticed that the error emitted at https://github.com/rust-lang/rust/blob/a50d72158e08e02cfc051b863017bdbd2c45b637/compiler/rustc_mir/src/interpret/traits.rs#L163-L166 doesn't seem to be present in the const-ub tests, so I've tried adding a test that triggers both of these cases: one for the invalid size, and another for the invalid alignment that #86132 tracks (I have found different magic values triggering different `Align::from_bytes` errors than the "power of 2" one, if need be). However, when doing that, I *cannot* for the life of me figure out the correct incantation to make these 2 errors trigger with the "it is undefined behavior to use this value" message rather than the "any use of this value will cause an error" lint. I've tried Oli's suggestions of different values, tuples and arrays, using the transparent wrapper trick from the other tests and I was only able to trigger the regular const-ub errors about the size of the vtable, or that the drop pointer was invalid. Maybe these "type validation failed" errors happen before this part of the interpreter is reached and there just needs some magic incorrect values to bypass them, I don't know. Since this fixes an ICE, and if the constants are indeed used, these 2 tests will turn into a hard error, I thought I'd open the PR anyways. And if ```@RalfJung``` you know of a way I could manage that (if you think that these tests are worth checking that the `throw_ub_format!` does indeed create const-ub errors as we expect) I'd be grateful. For that reason, r? ```@RalfJung``` and cc ```@oli-obk.```
2021-06-09detect incorrect vtable alignment during const eval instead of ICE-ingRémy Rakic-1/+3
also add tests for these 2 kinds of errors for size and alignment, as the existing size check wasn't apparently tested
2021-06-05Explain that `ensure_monomorphic_enough` omission is intentionalTomasz Miąsko-0/+2
2021-06-05Disallow non-monomorphic calls to `needs_drop` in interpreterTomasz Miąsko-1/+4
otherwise evaluation could change after further substitutions.
2021-06-04Rollup merge of #85963 - m-ou-se:constructor-type-name, r=yaahcYuki Okushi-6/+1
Show `::{{constructor}}` in std::any::type_name(). Fix #84666 Before: ``` [src/main.rs:6] type_name::<T>() = "playground::Velocity" [src/main.rs:6] type_name::<T>() = "playground::Velocity" ``` After: ``` [src/main.rs:6] type_name::<T>() = "scratchpad::Velocity::{{constructor}}" [src/main.rs:6] type_name::<T>() = "scratchpad::Velocity" ``` cc ``@scottmcm``
2021-06-03Show `::{{constructor}}` in std::any::type_name().Mara Bos-6/+1
2021-06-02Restrict access to crate_name.Camille GILLOT-1/+1
Also remove original_crate_name, which had the exact same implementation
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-1/+1
2021-05-30Restrict access to crate_name.Camille GILLOT-1/+1
Also remove original_crate_name, which had the exact same implementation
2021-05-28Auto merge of #85546 - hyd-dev:unwind, r=RalfJungbors-55/+121
const-eval: disallow unwinding across functions that `!fn_can_unwind()` Following https://github.com/rust-lang/miri/pull/1776#discussion_r633074343, so r? `@RalfJung` This PR turns `unwind` in `StackPopCleanup::Goto` into a new enum `StackPopUnwind`, with a `NotAllowed` variant to indicate that unwinding is not allowed. This variant is chosen based on `rustc_middle::ty::layout::fn_can_unwind()` in `eval_fn_call()` when pushing the frame. A check is added in `unwind_to_block()` to report UB if unwinding happens across a `StackPopUnwind::NotAllowed` frame. Tested with Miri `HEAD` with [minor changes](https://github.com/rust-lang/miri/compare/HEAD..9cf3c7f0d86325a586fbcbf2acdc9232b861f1d8) and the rust-lang/miri#1776 branch with [these changes](https://github.com/rust-lang/miri/compare/d866c1c52f48bf562720383455b75c257bb1ad92..626638fbfe2fff34648dda29a34d59db498a6e52).
2021-05-28Rewrite to a `match`hyd-dev-5/+4
2021-05-28"a frame" -> "a stack frame"hyd-dev-1/+1
2021-05-26Remove unneeded workaroundSmitty-5/+3
This removes a workaround for #24159, which has been fixed.
2021-05-26Use `match` instead of `.map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup)`hyd-dev-5/+8
2021-05-25Move the check to `unwind_to_block`hyd-dev-30/+34
2021-05-25Add a commenthyd-dev-0/+1
2021-05-25`can_unwind` -> `caller_can_unwind`hyd-dev-2/+2
2021-05-25Check whether unwinding is allowed before popping the stack framehyd-dev-16/+15
2021-05-23:facepalm:hyd-dev-1/+1
2021-05-23Pass `StackPopUnwind` to `eval_fn_call()` and some other functions that are ↵hyd-dev-21/+25
called by `eval_fn_call()`
2021-05-23"unwind" -> "unwinding"hyd-dev-1/+1
2021-05-23`Cleanup(Option<_>)` -> `Cleanup(BasicBlock), Skip`hyd-dev-6/+9
2021-05-23support creating mutable allocations from byte slicesRalf Jung-6/+16
2021-05-23avoid redundant immutability checkRalf Jung-3/+0
2021-05-23reject deallocation of read-only allocationsRalf Jung-0/+3
2021-05-23Don't evaluate `self.fn_can_unwind(...)` if `can_unwind` is already truehyd-dev-3/+4
2021-05-23Refactor `match` + `if`hyd-dev-12/+9
2021-05-23Move the callee "can unwind" check to the right placehyd-dev-38/+37
2021-05-23const-eval: disallow unwinding across functions that `!fn_can_unwind()`hyd-dev-11/+67
2021-05-22Auto merge of #85578 - RalfJung:alloc-mem-extra, r=oli-obkbors-2/+3
CTFE get_alloc_extra_mut: also provide ref to MemoryExtra This would let me use mutable references in more places in Stacked Borrows, avoiding some `RefCell` overhead. :) r? `@oli-obk`
2021-05-22CTFE get_alloc_extra_mut: also provide ref to MemoryExtraRalf Jung-2/+3
2021-05-22Add default implementation for `enforce_abi()`hyd-dev-6/+3
2021-05-21Add `rustc_mir::interpret::Machine::enforce_abi()`hyd-dev-19/+29
2021-05-19CTFE Machine: do not expose AllocationRalf Jung-9/+11