summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-2/+4
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-14Auto merge of #95826 - carbotaniuman:miri-permissive-provenance, r=RalfJungbors-5/+8
Initial work on Miri permissive-exposed-provenance Rustc portion of the changes for portions of a permissive ptr-to-int model for Miri. The main changes here are changing `ptr_get_alloc` and `get_alloc_id` to return an Option, and also making ptr-to-int casts have an expose side effect.
2022-05-13Add bound_type_ofJack Huey-4/+4
2022-05-13Rustc changes for permissive provenancecarbotaniuman-5/+8
2022-05-12Auto merge of #96889 - Aaron1011:place-ref-remove, r=compiler-errorsbors-1/+7
Remove `PartialOrd`/`Ord` impl for `PlaceRef` This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-0/+3
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-11Remove `PartialOrd`/`Ord` impl for `PlaceRef`Aaron Hill-1/+7
This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
2022-05-10Introduce EarlyBinderJack Huey-4/+6
2022-05-08Use sparse representation of switch sourcesTomasz Miąsko-9/+7
to avoid quadratic space overhead
2022-05-08Avoid constructing switch sources unless necessaryTomasz Miąsko-0/+2
Switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed. Delay the computation until we know that switch sources are indeed required and avoid the computation otherwise.
2022-05-07Rollup merge of #96581 - RalfJung:debug-size-align, r=oli-obkGuillaume Gomez-2/+8
make Size and Align debug-printing a bit more compact In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable). We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that? Cc `````@oli-obk`````
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-47/+50
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-06don't debug-print ConstValue in MIR pretty-printerRalf Jung-2/+8
2022-05-05Allow unused rules in some places in the compiler, library and toolsest31-0/+3
2022-05-03Update `ProjectionElem::Downcast` documentationTomasz Miąsko-4/+2
`ProjectionElem:::Downcast` is used when downcasting to a variant of an enum or a generator, regardless of the number of variants.
2022-05-03Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebankYuki Okushi-5/+1
Update `RValue::Discriminant` documentation `RValue::Discriminant` returns zero for types without discriminant. This guarantee is already documented for `discriminant_value` intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-05-02fix most compiler/ doctestsElliot Roberts-47/+50
2022-05-01Auto merge of #96549 - ouz-a:mir-opt, r=oli-obkbors-2/+15
Move Derefer before Retag _Follow up work to #96116 #95857 #95649_ This moves `Derefer` before `Retag` and creates a new `LocalInfo` called `Temp` to avoid retagging created temp values. Zulip discussion [link](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/deref.20as.20first.20and.20only.20projection) r? `@oli-obk`
2022-05-01re-name stuffouz-a-7/+9
2022-05-01Update `RValue::Discriminant` documentationTomasz Miąsko-5/+1
`RValue::Discriminant` returns zero for types without discriminant. This guarantee is already documented for `discriminant_value` intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-04-30Auto merge of #96500 - SparrowLii:rpo, r=tmiaskobors-4/+94
Reduce duplication of RPO calculation of mir Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow. This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
2022-04-30Eliminate duplication of RPO calculation for mirSparrowLii-4/+94
add `postorder_cache` to mir Body add `ReversePostorderCache` struct correct struct name and comments
2022-04-29remove and blessouz-a-4/+0
2022-04-29exp-stuff-dirtyouz-a-0/+15
2022-04-28Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obkbors-0/+1
Implement Valtree to ConstValue conversion Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction. r? `@oli-obk` cc `@RalfJung`
2022-04-26Auto merge of #96425 - oli-obk:fix_incremental_regression_unsafety_checking, ↵bors-49/+19
r=compiler-errors Fix incremental perf regression unsafety checking Perf regression introduced in #96294 We will simply avoid emitting the name of the unsafe function in MIR unsafeck, since we're moving to THIR unsafeck anyway.
2022-04-26Revert "add `DefId` to unsafety violations and display function path in E0133"Oli Scherer-49/+19
This reverts commit 8b8f6653cfd54525714f02efe7af0a0f830e185c.
2022-04-26Rollup merge of #96400 - JakobDegen:shallow-init-docs, r=Dylan-DPCGuillaume Gomez-2/+0
Correct documentation for `Rvalue::ShallowInitBox` As a part of the big MIR docs PR, I had added a comment indicating that `Rvalue::ShallowInitBox` is disallowed after drop elaboration, but this is not true (no idea why I thought it was). Codegen has support for it, and trying to enforce this rule in the validator causes compiling core to ICE on the very first `box` statement. That being said, this `Rvalue` probably *should* be banned after drop elaboration - it doesn't seem like it's still useful for much. However, I do not have time right now to actually go investigate how difficult a change that is to make, so in the meantime fixing the docs to reflect the current situation seems like the right step. r? rust-lang/mir-opt
2022-04-25Auto merge of #96294 - Emilgardis:def_id-in-unsafetyviolationdetails, r=oli-obkbors-19/+49
Display function path in unsafety violations - E0133 adds `DefId` to `UnsafetyViolationDetails` this enables consumers to access the function definition that was reported to be unsafe and also changes the output for some E0133 diagnostics
2022-04-25Auto merge of #96116 - ouz-a:mir-opt, r=oli-obkbors-0/+20
Make derefer work everwhere Follow up work on previous PR's #95649 and #95857. r? rust-lang/mir-opt _Co-Authored-By: `@oli-obk_`
2022-04-25Correct documentation for `ShallowInitBox`Jakob Degen-2/+0
2022-04-24only show a simple description in E0133 span labelEmil Gardström-11/+32
2022-04-24add `DefId` to unsafety violations and display function path in E0133Emil Gardström-19/+28
this enables consumers to access the function definition that was reported to be unsafe
2022-04-22Relax restrictions for copy operandsJakob Degen-2/+6
2022-04-21deduplicate a lot of codeb-naber-5/+1
2022-04-21implement valtree -> constvalue conversionb-naber-1/+6
2022-04-20Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obkDylan DPC-0/+8
Miri/interpreter debugging tweaks Some changes I made to make debugging Miri with trace logging less terrible. r? ``@oli-obk``
2022-04-19Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obkDylan DPC-0/+17
Miri provenance cleanup Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here. ``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type. r? ``@oli-obk``
2022-04-19Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obkDylan DPC-8/+28
interpret: Fix writing uninit to an allocation When calling `mark_init`, we need to also be mindful of what happens with the relocations! Specifically, when we de-init memory, we need to clear relocations in that range as well or else strange things will happen (and printing will not show the de-init, since relocations take precedence there). Fixes https://github.com/rust-lang/miri/issues/2068. Here's the Miri testcase that this fixes (requires `-Zmiri-disable-validation`): ```rust use std::mem::MaybeUninit; fn main() { unsafe { let mut x = MaybeUninit::<i64>::uninit(); // Put in a ptr. x.as_mut_ptr().cast::<&i32>().write_unaligned(&0); // Overwrite parts of that pointer with 'uninit' through a Scalar. let ptr = x.as_mut_ptr().cast::<i32>(); *ptr = MaybeUninit::uninit().assume_init(); // Reading this back should hence work fine. let _c = *ptr; } } ``` Previously this failed with ``` error: unsupported operation: unable to turn pointer into raw bytes --> ../miri/uninit.rs:11:14 | 11 | let _c = *ptr; | ^^^^ unable to turn pointer into raw bytes | = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support = note: inside `main` at ../miri/uninit.rs:11:14 ```
2022-04-18replace iter with into_iter()ouz-a-2/+2
2022-04-18avoid an unnecessary call to Pointer::into_parts, and caution against ↵Ralf Jung-0/+4
into_pointer_or_addr
2022-04-18add method to get absolute address of a pointer (useful only for Miri)Ralf Jung-0/+10
2022-04-18avoid pairing up AllocId and PointerTag, which is redundantRalf Jung-0/+3
2022-04-17check Allocation invariant during printingRalf Jung-0/+1
2022-04-17explain why prepare_relocation_copy works the way it doesRalf Jung-4/+11
2022-04-17add caution to some commentsRalf Jung-1/+7
2022-04-17when writing uninit to an allocation, also clear relocations like other ↵Ralf Jung-3/+9
writes do
2022-04-17add log warnings for when we overwrite parts of a pointer, and de-init the restRalf Jung-0/+8
2022-04-17fat vecouz-a-7/+5
2022-04-17format errouz-a-5/+3