about summary refs log tree commit diff
path: root/src/librustc_mir/interpret
AgeCommit message (Collapse)AuthorLines
2020-04-30Rollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obkTyler Mandry-3/+5
MIR dump: print pointers consistently with Miri output This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a `0x` prefix. To save some space, MIR dump replaces the `alloc` prefix by `a` when necessary. I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).
2020-04-29expand comment in memory.rs with extra soundness concernsRalf Jung-1/+3
2020-04-28better document const-pattern dynamic soundness checks, and fix a soundness holeRalf Jung-7/+15
2020-04-28Rollup merge of #71615 - RalfJung:share-machine-code, r=oli-obkDylan DPC-1/+65
share some common code for compile-time miri instances Fixes https://github.com/rust-lang/rust/issues/71129 r? @oli-obk
2020-04-27Use `LocalDefId` in `typeck_tables_of` and `used_trait_imports` queriesmarmeladema-5/+7
2020-04-27share some common code for compile-time miri instancesRalf Jung-1/+65
2020-04-26organize Debug/Display impls a bit more; avoid sign-ignorant decimal displayRalf Jung-2/+4
2020-04-26sync alloc dump and pointer printingRalf Jung-1/+1
2020-04-26Rollup merge of #71140 - oli-obk:static_cycle, r=RalfJungDylan DPC-8/+17
[breaking change] Disallow statics initializing themselves fixes #71078 Self-initialization is unsound because it breaks privacy assumptions that unsafe code can make. In ```rust pub mod foo { #[derive(Debug, Copy, Clone)] pub struct Foo { x: (), } } pub static FOO: foo::Foo = FOO; ``` unsafe could could expect that ony functions inside the `foo` module were able to create a value of type `Foo`.
2020-04-24Remove `Option` from the return type of `def_kind`.Eduard-Mihai Burtescu-1/+1
2020-04-24Rollup merge of #71475 - RalfJung:miri-frame-loc, r=ecstatic-morseDylan DPC-41/+29
Miri Frame: use mir::Location to represent position in function I only recently learned that `Location` exists, and it seems to perfectly fit what Miri needs to represent which statement we are currently executing. :) r? @ecstatic-morse
2020-04-23Miri Frame: use mir::Location to represent position in functionRalf Jung-41/+29
2020-04-23Rollup merge of #71005 - jonas-schievink:no-place-like-return, r=oli-obkDylan DPC-98/+40
Reading from the return place is fine Const eval thinks that reading from local `_0` is UB, but it isn't. `_0` is just a normal local like any other, and codegen handles it that way too. The only special thing is that the `Return` terminator will read from it. I've hit these errors while working on an NRVO pass that can merge other locals with `_0` in https://github.com/rust-lang/rust/pull/71003. r? @oli-obk
2020-04-23Update src/librustc_mir/interpret/memory.rsOliver Scherer-1/+3
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-04-23Disallow statics initializing themselvesOliver Scherer-1/+10
2020-04-22Auto merge of #71044 - ecstatic-morse:body-predecessor-cache, r=oli-obkbors-3/+3
Remove `BodyAndCache` ...returning to the original approach using interior mutability within `Body`. This simplifies the API at the cost of some uncontended mutex locks when the parallel compiler is enabled. The current API requires you to either have a mutable reference to `Body` (`&mut BodyAndCache`), or to compute the predecessor graph ahead of time by creating a `ReadOnlyBodyAndCache`. This is not a good fit for, e.g., the dataflow framework, which 1. does not mutate the MIR 2. only sometimes needs the predecessor graph (for backward dataflow problems)
2020-04-22Use `Body` everywhereDylan MacKenzie-3/+3
2020-04-22Rollup merge of #71280 - RalfJung:mplace-check-align, r=oli-obkDylan DPC-2/+7
Miri: mplace_access_checked: offer option to force different alignment on place Required to solve https://github.com/rust-lang/miri/issues/1339 in https://github.com/rust-lang/miri/pull/1348. r? @oli-obk
2020-04-22comment explaining force_align usageRalf Jung-0/+3
2020-04-22Rollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obkDylan DPC-2/+7
Detect mistyped associated consts in `Instance::resolve`. *Based on #71049 to prevent redundant/misleading downstream errors.* Fixes #70942 by refusing to resolve an associated `const` if it doesn't have the same type in the `impl` that it does in the `trait` (which we assume had errored, and `delay_span_bug` guards against bugs).
2020-04-20Use copy_op_transmuteJonas Schievink-1/+1
2020-04-20Remove unnecessary blockJonas Schievink-6/+4
2020-04-20Fix codegen and mir-opt testsJonas Schievink-1/+0
Mostly renamed allocations, but I'm not sure about the const prop tests
2020-04-20Dump return_place upon returningJonas Schievink-0/+1
2020-04-20Fix pop_stack_frame logicJonas Schievink-22/+7
2020-04-20Remove null placesJonas Schievink-16/+0
2020-04-20Treat RETURN_PLACE as a normal LocalJonas Schievink-65/+40
Copy its value to the `return_place` upon leaving a call frame
2020-04-19Auto merge of #70598 - vakaras:add-threads-cr3, r=oli-obk,RalfJungbors-59/+120
Make the necessary changes to support concurrency in Miri. This pull request makes the necessary changes to the Rust compiler to allow Miri to support concurrency: 1. Move stack from the interpretation context (`InterpCx`) to machine, so that the machine can switch the stacks when it changes the thread being executed. 2. Add the callbacks that allow the machine to generate fresh allocation ids for each thread local allocation and to translate them back to original allocations when needed. This allows the machine to ensure the property that allocation ids are unique, which allows using a simpler representation of the memory. r? @oli-obk cc @RalfJung
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-17/+17
2020-04-18Detect mistyped associated consts in `Instance::resolve`.Eduard-Mihai Burtescu-2/+7
2020-04-18Miri: mplace_access_checked: offer option to force different alignment on placeRalf Jung-2/+4
2020-04-17Rollup merge of #71238 - RalfJung:miri-typo, r=oli-obkDylan DPC-1/+1
Miri: fix typo r? @oli-obk at least I think this should be "without", right?
2020-04-17Auto merge of #71049 - eddyb:const-err, r=oli-obkbors-12/+13
Add `ConstKind::Error` and convert `ErrorHandled::Reported` to it. By replicating the `ty::Error` approach to encoding "an error has occurred", all of the mechanisms that skip redundant/downstream errors are engaged and help out (see the reduction in test output). This PR also adds `ErrorHandled::Linted` for the lint case because using `ErrorHandled::Reported` *without* having emitted an error that is *guaranteed* to stop compilation, is incorrect now. r? @oli-obk cc @rust-lang/wg-const-eval @varkor @yodaldevoid
2020-04-17Miri: fix typoRalf Jung-1/+1
2020-04-17Auto merge of #70629 - anyska:fields-variant, r=oli-obkbors-5/+10
rustc_target::abi: add Primitive variant to FieldsShape. Originally suggested by @eddyb.
2020-04-17Rollup merge of #71164 - RalfJung:uninit-not-undef, r=oli-obkDylan DPC-6/+11
reword Miri validity errors: undefined -> uninitialized I don't think we say "undefined value" or anything like that anywhere in the docs or so, but we do use the term "uninitialized memory", so I think we should do the same here. Longer-term, I think we should also internally rename "undef" to "uninit". r? @oli-obk
2020-04-16mir/interpret: only use `ErrorHandled::Reported` for `ErrorReported`.Eduard-Mihai Burtescu-13/+13
2020-04-16ty: add `ty::ConstKind::Error` to replace `tcx.consts.err`.Eduard-Mihai Burtescu-0/+1
2020-04-16rustc_target::abi: add Primitive variant to FieldsShape.Ana-Maria Mihalache-5/+10
2020-04-16Move the explanation why adjust_global_const is called for all constants.Vytautas Astrauskas-3/+5
2020-04-16Rename Machine::eval_maybe_thread_local_static_const to adjust_global_const ↵Vytautas Astrauskas-2/+7
and add an additional comment.
2020-04-16switch back to 'bytes'Ralf Jung-1/+1
2020-04-15Fix clippy warningsMatthias Krüger-1/+1
clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
2020-04-15Remove now unnecessary resolve_maybe_global_alloc.Vytautas Astrauskas-43/+17
2020-04-15Add function eval_maybe_thread_local_static_const that allows handling ↵Vytautas Astrauskas-52/+70
thread locals without touching debug info; address other PR comments.
2020-04-15Clarify the comments explaining the purpose of resolve_maybe_global_alloc.Vytautas Astrauskas-4/+23
2020-04-15Address reviewers' comments: replace resolve_thread_local_allocation_id with ↵Vytautas Astrauskas-22/+28
resolve_maybe_global_alloc, clarify comments.
2020-04-15Make the necessary changes to support concurrency in Miri.Vytautas Astrauskas-46/+83
2020-04-15reword Miri validity errors: undefined -> uninitializedRalf Jung-6/+11
2020-04-15Rollup merge of #71100 - RalfJung:miri-frame-hook, r=oli-obkMazdak Farrokhzad-21/+54
Miri: expand frame hooks This is needed to make https://github.com/rust-lang/miri/pull/1330 work. r? @oli-obk @eddyb