about summary refs log tree commit diff
path: root/src/librustc_mir/interpret
AgeCommit message (Collapse)AuthorLines
2020-03-14adjust Miri to needs of changed unwinding strategyRalf Jung-26/+19
2020-03-12miri engine: fix treatment of abort intrinsicRalf Jung-8/+5
2020-03-12Rollup merge of #69830 - RalfJung:miri-invalid-terminator, r=oli-obkMazdak Farrokhzad-7/+18
miri: ICE on invalid terminators We've run a lot of MIR in Miri (including some generators) and never seen these. @tmandry is it correct that `Yield` and `GeneratorDrop` get lowered away? @eddyb @oli-obk what's with this `Abort` that does not seem to ever actually exist? Codegen *does* seem to handle it, so I wonder why Miri can get away without that. In fact, codegen handles it twice: https://github.com/rust-lang/rust/blob/1d5241c96208ca7d925442b1a5fa45ad18717a6f/src/librustc_codegen_ssa/mir/block.rs#L796 https://github.com/rust-lang/rust/blob/1d5241c96208ca7d925442b1a5fa45ad18717a6f/src/librustc_codegen_ssa/mir/mod.rs#L296
2020-03-12codegen/mir: support polymorphic `InstanceDef`sDavid Wood-15/+25
This commit modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. Signed-off-by: David Wood <david@davidtw.co>
2020-03-11we are on 2018 edition, use try blockRalf Jung-6/+4
2020-03-11avoid boolean inversionRalf Jung-3/+3
2020-03-11explain why we catch PointerUseAfterFreeRalf Jung-0/+2
2020-03-11start Miri messages lower-caseRalf Jung-2/+2
2020-03-11fmt, and fix rustfmt-induced rebase hickupRalf Jung-5/+2
2020-03-11generalize InvalidNullPointerUsage to InvalidIntPointerUsageRalf Jung-13/+23
2020-03-11fmt, tweak messages and blessRalf Jung-18/+31
2020-03-11miri: categorize errors into "unsupported" and "UB"Ralf Jung-150/+162
Also slightly refactor pointer bounds checks to avoid creating unnecessary temporary Errors
2020-03-11Rollup merge of #69850 - RalfJung:panic-bounds-check, r=eddybMazdak Farrokhzad-2/+1
panic_bounds_check: use caller_location, like PanicFnLangItem The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well. This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
2020-03-11Comment nitsOliver Scherer-1/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-03-11Compute the correct layout for variants of uninhabited enums and readd a ↵Oliver Scherer-9/+1
long lost assertion This reverts part of commit 9712fa405944cb8d5416556ac4b1f26365a10658.
2020-03-11Rollup merge of #69825 - lcnr:discriminant, r=oli-obkMazdak Farrokhzad-0/+5
make `mem::discriminant` const implements #69821, which could be used as a tracking issue for `const_discriminant`. Should this be added to the meta tracking issue #57563? @Lokathor
2020-03-11Generalize typed value printing and use for undef printingOliver Scherer-7/+9
2020-03-11Deduplicate and clean up pretty printing logicOliver Scherer-42/+40
2020-03-09also handle abort intrinsic with new machine hookRalf Jung-1/+5
2020-03-09remove no-longer needed span from Miri Machine hookRalf Jung-2/+1
2020-03-09Rollup merge of #69762 - RalfJung:validity-errors, r=oli-obkMazdak Farrokhzad-33/+78
Ensure that validity only raises validity errors For now, only as a debug-assertion (similar to const-prop detecting errors that allocate). Now includes https://github.com/rust-lang/rust/pull/69646. [Relative diff](https://github.com/RalfJung/rust/compare/layout-visitor...RalfJung:validity-errors). r? @oli-obk
2020-03-09miri: add machine hook for Abort terminatorRalf Jung-2/+12
2020-03-08fix some cases of unexpected exceptions leaving validationRalf Jung-27/+57
2020-03-08miri validation: debug-complain about unexpected errorsRalf Jung-6/+21
2020-03-08Rollup merge of #69326 - JOE1994:os_str_widestring, r=RalfJungMazdak Farrokhzad-0/+27
mir-interpret: add method to read wide strings from Memory Implemented *step2* from [instructions](https://github.com/rust-lang/miri/issues/707#issuecomment-561564057) laid out in rust-lang/miri#707. Added 2 new methods to struct `rustc_mir::interpret::InterpCx`. * `read_os_str_from_wide_str` (src/librustc_mir/interpret/operand.rs) * `write_os_str_to_wide_str` (src/librustc_mir/interpret/place.rs) - used existing logic implemented in [MIRI/src/eval.rs](https://github.com/rust-lang/miri/blob/94732aaf7bf79fd01a4a48d11155c6586b937514/src/eval.rs#L132-L141) These methods are intended to be used for environment variable emulation in Windows.
2020-03-08miri: ICE on invalid terminatorsRalf Jung-9/+6
2020-03-08Rollup merge of #69646 - RalfJung:layout-visitor, r=eddybMazdak Farrokhzad-127/+166
Miri visitor: detect primitive types based on type, not layout (also, more tests) I also converted the union-based transmutes to use `mem::transmute` for increased readability. r? @eddyb @oli-obk
2020-03-08constify `mem::discriminant`Bastian Kauschke-0/+5
2020-03-07Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkovMazdak Farrokhzad-4/+4
fix various typos
2020-03-07Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cramertjMazdak Farrokhzad-1/+1
Don't redundantly repeat field names (clippy::redundant_field_names)
2020-03-06mir-interpret: add method Memory::read wide_stringJOE1994-0/+27
2020-03-06bug on ty::GeneratorWitnessRalf Jung-4/+7
2020-03-06rename visit_primitive -> try_visit_primitive, and commentsRalf Jung-4/+5
2020-03-06better error messages for invalid boxes (and a few more tests)Ralf Jung-7/+12
2020-03-06test that we validate boxesRalf Jung-1/+0
2020-03-06miri value visitor: detect primitives by type, not layoutRalf Jung-126/+158
2020-03-06'fieldless enums' is not what I meant -- it's empty/uninhabited enums, reallyRalf Jung-2/+1
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-03-06Auto merge of #69753 - pnkfelix:issue-69191-ice-on-uninhabited-enum-field, r=olibors-0/+8
Do not ICE when matching an uninhabited enum's field Fix #69191
2020-03-06fix various typosMatthias Krüger-4/+4
2020-03-06Add FIXMEOliver Scherer-0/+2
2020-03-05Fix #69191Felix S. Klock II-0/+6
2020-03-05Rollup merge of #69736 - matthiaskrgr:even_more_clippy, r=Dylan-DPCDylan DPC-3/+2
even more clippy cleanups * Don't pass &mut where immutable reference (&) is sufficient (clippy::unnecessary_mut_passed) * Use more efficient &&str to String conversion (clippy::inefficient_to_string) * Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call) * Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) * Use simple 'for i in x' loops instead of 'while let Some(i) = x.next()' loops on iterators. (clippy::while_let_on_iterator) * Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes) * Remove redundant patterns when matching ( x @ _ to x) (clippy::redundant_pattern)
2020-03-05Rollup merge of #69713 - matthiaskrgr:more_cleanup, r=cramertjDylan DPC-1/+1
more clippy cleanups * Don't use .ok() before unwrapping via .expect() on a Result. * Use .map() to modify data inside Options instead of using .and_then(|x| Some(y)) * Use .as_deref() instead of .as_ref().map(Deref::deref) * Don't use "if let" bindings to only check a value and not actually bind anything. * Use single-char patter on {ends,starts}_with and remove clone on copy type.
2020-03-05Use simple 'for i in x' loops instead of 'while let Some(x) = x.next()' ↵Matthias Krüger-3/+2
loops on iterators. (clippy::while_let_on_iterator)
2020-03-04Don't use "if let" bindings to only check a value and not actually bind ↵Matthias Krüger-1/+1
anything. For example: `if let Some(_) = foo() {}` can be reduced to `if foo().is_some() {}` (clippy::redundant_pattern_matching)
2020-03-04use integer assoc consts instead of methodsRalf Jung-4/+4
2020-03-04Auto merge of #69550 - RalfJung:scalar, r=oli-obkbors-42/+38
interpret engine: Scalar cleanup * Remove `to_ptr` * Make `to_bits` private r? @oli-obk
2020-03-03Rollup merge of #69565 - RalfJung:assert, r=eddybDylan DPC-7/+7
miri engine: turn some debug_assert into assert @eddyb said to avoid debug assertions in rustc. These checks here look like they are probably not too expensive. Cc @oli-obk
2020-03-02Auto merge of #69257 - RalfJung:layout-visitor, r=eddybbors-174/+191
Adjust Miri value visitor, and doc-comment layout components I realized that I still didn't have quite the right intuition for how our `LayoutDetails` work, so I had to adjust the Miri value visitor to the things I understood better now. I also added some doc-comments to `LayoutDetails` as a hopefully canonical place to note such things. The main visitor change is that we *first* look at all the fields (according to `FieldPlacement`), and *then* check the variants and handle `Multiple` appropriately. I did not quite realize how orthogonal "fields" and "variants" are. I also moved the check for the scalar ABI to *after* checking all the fields; this leads to better (more type-driven) error messages. And it looks like we can finally remove that magic hack for `ty::Generator`. :D r? @oli-obk for the Miri/visitor changes and @eddyb for the layout docs The Miri PR is at: https://github.com/rust-lang/miri/pull/1178