about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret/eval_context.rs
AgeCommit message (Collapse)AuthorLines
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-1049/+0
2021-09-07Move the dataflow framework to its own crate.Camille GILLOT-1/+1
2021-09-05Auto merge of #88499 - eddyb:layout-off, r=nagisabors-12/+19
Provide `layout_of` automatically (given tcx + param_env + error handling). After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit. This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context. After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type: * `TyCtxt`, via `HasTyCtxt` * `ParamEnv`, via `HasParamEnv` * a way to transform `LayoutError`s into the desired error type * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`) When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform. (**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it) Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts. r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-03Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebankbors-2/+3
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in https://github.com/rust-lang/rust/pull/83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting). The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output. In the future we might want to give more fine-grained control over this behavior via compiler flags (see https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix. This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642. Fixes https://github.com/rust-lang/rust/issues/87745. cc `@cbeuw` r? `@ghost`
2021-09-02ty::layout: split `LayoutOf` into required and (blanket) provided halves.Eduard-Mihai Burtescu-2/+2
2021-09-02ty::layout: implement `layout_of` automatically as a default method.Eduard-Mihai Burtescu-8/+16
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-5/+4
2021-08-30rustc_target: `TyAndLayout::field` should never error.Eduard-Mihai Burtescu-2/+2
2021-08-27rustc_target: add lifetime parameter to `LayoutOf`.Eduard-Mihai Burtescu-1/+1
2021-08-27Path remapping: Make behavior of diagnostics output dependent on presence of ↵Michael Woerister-2/+3
--remap-path-prefix.
2021-07-16avoid manual Debug impls by adding extra Provenance bounds to typesRalf Jung-20/+8
I wish the derive macro would support adding extra where clauses...
2021-07-16get rid of incorrect erase_for_fmtRalf Jung-7/+7
2021-07-14consistently treat None-tagged pointers as ints; get rid of some deprecated ↵Ralf Jung-3/+3
Scalar methods
2021-07-14CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion ↵Ralf Jung-46/+48
infallible This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
2021-07-12remove unnecessary deallocate_local hackRalf Jung-3/+3
2021-07-09Use #[track_caller] in const panic diagnostics.Mara Bos-2/+11
It was already used for the message. This also uses it for the spans used for the error and backtrace.
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-06-27Change miri to use tcx allocated allocations.Charles Lew-6/+0
2021-05-28Rewrite to a `match`hyd-dev-5/+4
2021-05-28"a frame" -> "a stack frame"hyd-dev-1/+1
2021-05-25Move the check to `unwind_to_block`hyd-dev-30/+34
2021-05-25Check whether unwinding is allowed before popping the stack framehyd-dev-16/+15
2021-05-23"unwind" -> "unwinding"hyd-dev-1/+1
2021-05-23`Cleanup(Option<_>)` -> `Cleanup(BasicBlock), Skip`hyd-dev-2/+5
2021-05-23Refactor `match` + `if`hyd-dev-12/+9
2021-05-23Move the callee "can unwind" check to the right placehyd-dev-12/+2
2021-05-23const-eval: disallow unwinding across functions that `!fn_can_unwind()`hyd-dev-4/+33
2021-05-05Use local and remapped paths where appropriateAndy Wang-1/+7
2021-04-02Auto merge of #83207 - oli-obk:valtree2, r=lcnrbors-0/+1
normalize mir::Constant differently from ty::Const in preparation for valtrees Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation. In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system. cc `@rust-lang/wg-const-eval` r? `@lcnr`
2021-04-01Some more fine-grained forced inliningOli Scherer-0/+1
2021-03-27Address review commentsJoshua Nelson-0/+12
- Add back `HirIdVec`, with a comment that it will soon be used. - Add back `*_region` functions, with a comment they may soon be used. - Remove `-Z borrowck_stats` completely. It didn't do anything. - Remove `make_nop` completely. - Add back `current_loc`, which is used by an out-of-tree tool. - Fix style nits - Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
2021-03-27Remove (lots of) dead codeJoshua Nelson-15/+0
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-1/+1
2021-02-27Add a getter for Frame.locbjorn3-0/+10
This is necessary for Priroda.
2021-02-16./x.py fmtTomasz Miąsko-17/+18
2021-02-16Pass MPlaceTy by reference not valueTomasz Miąsko-5/+5
2021-02-16Pass PlaceTy by reference not valueTomasz Miąsko-4/+4
2021-02-16Pass OpTy by reference not valueTomasz Miąsko-1/+1
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-1/+1
2021-01-04Move MIR body loading to a machine functionoli-10/+1
2021-01-04Differentiate between the availability of ctfe MIR and runtime MIRoli-1/+1
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-1/+1
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2020-12-11make redundant StorageLive UBRalf Jung-19/+14
2020-12-09Also generate `StorageDead` in constantsoli-16/+6
2020-11-16compiler: fold by valueBastian Kauschke-1/+1
2020-11-06inliner: Use substs_for_mir_bodyTomasz Miąsko-5/+1
Changes from 68965 extended the kind of instances that are being inlined. For some of those, the `instance_mir` returns a MIR body that is already expressed in terms of the types found in substitution array, and doesn't need further substitution. Use `substs_for_mir_body` to take that into account.
2020-11-05Rollup merge of #78742 - vn-ki:fix-issue-78655, r=oli-obkMara Bos-3/+3
make intern_const_alloc_recursive return error fix #78655 r? ``@oli-obk``
2020-11-04make intern_const_alloc_recursive return error fix #78655Vishnunarayan K I-3/+3
2020-11-04`u128` truncation and sign extension are not just interpreter relatedoli-5/+3