about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2022-04-13couple of clippy::complexity fixesMatthias Krüger-2/+2
2022-04-11Remove inlining cost of `Deinit` statementsJakob Degen-0/+1
2022-04-11Add new `MutatatingUseContext`s for deinit and `SetDiscriminant`Jakob Degen-1/+5
2022-04-11Add new `Deinit` statement kindJakob Degen-5/+14
2022-04-10Auto merge of #95889 - Dylan-DPC:rollup-1cmywu4, r=Dylan-DPCbors-8/+8
Rollup of 7 pull requests Successful merges: - #95566 (Avoid duplication of doc comments in `std::char` constants and functions) - #95784 (Suggest replacing `typeof(...)` with an actual type) - #95807 (Suggest adding a local for vector to fix borrowck errors) - #95849 (Check for git submodules in non-git source tree.) - #95852 (Fix missing space in lossy provenance cast lint) - #95857 (Allow multiple derefs to be splitted in deref_separator) - #95868 (rustdoc: Reduce allocations in a `html::markdown` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-10Rollup merge of #95857 - ouz-a:mir-opt, r=oli-obkDylan DPC-8/+8
Allow multiple derefs to be splitted in deref_separator Previously in #95649 only a single deref within projection was supported and multiple derefs caused a bunch of issues, this PR fixes those issues. ```@oli-obk``` helped a ton again ❤️
2022-04-10Avoid accessing HIR from MIR queries.Camille GILLOT-7/+7
2022-04-09remove the if blockouz-a-22/+9
2022-04-09support multiple derefsouz-a-13/+26
2022-04-06Rollup merge of #95649 - ouz-a:mir-opt, r=oli-obkDylan DPC-0/+74
New mir-opt deref_separator This adds a new mir-opt that split certain derefs into this form: `let x = (*a.b).c;` to => `tmp = a.b; let x = (*tmp).c;` Huge thanks to ``@oli-obk`` for his patient mentoring.
2022-04-06Auto merge of #95723 - SparrowLii:const_goto, r=fee1-deadbors-9/+16
enhance `ConstGoto` mir-opt by moving up `StorageDead` statements From the `FIXME` in the implementation of `ConstGoto` miropt. We can move `StorageDead` statements up to the predecessor. This can expand the scope of application of this opt.
2022-04-06enhance `ConstGoto` mir-opt by moving up `StorageDead` statementsSparrowLii-9/+16
2022-04-05kill temp earlyouz-a-2/+1
2022-04-05interp: pass TyCtxt to Machine methods that do not take InterpCxRalf Jung-0/+2
2022-04-05remove region checkouz-a-9/+11
2022-04-05Rollup merge of #95620 - RalfJung:memory-no-extras, r=oli-obkDylan DPC-8/+2
interpret: remove MemoryExtra in favor of giving access to the Machine The Miri PR for this is upcoming. r? ``@oli-obk``
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-19/+6
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2022-04-04destroy temp at the end and avoid ICEouz-a-7/+10
2022-04-04fixed error, made function leaner and tighterouz-a-30/+35
2022-04-04New mir-opt deref_separatorouz-a-0/+65
2022-04-03interpret: remove MemoryExtra in favor of giving access to the MachineRalf Jung-8/+2
2022-04-02Less manipulation of the callee_def_id.Camille GILLOT-5/+6
2022-04-02Use only local hash.Camille GILLOT-2/+2
2022-04-02Use DefPathHash instead of HirId to break cycles.Camille GILLOT-14/+8
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-13/+13
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30a few mode feedback fixes per @bjorn3Yuri Astrakhan-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-14/+14
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-4/+4
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-26Auto merge of #95149 - cjgillot:once-diag, r=estebankbors-1/+0
Remove `Session::one_time_diagnostic` This is untracked mutable state, which modified the behaviour of queries. It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes). It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter. A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics. As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-25Rollup merge of #94655 - JakobDegen:mir-phase-docs, r=oli-obkDylan DPC-7/+11
Clarify which kinds of MIR are allowed during which phases. This enhances documentation with these details and extends the validator to check these requirements more thoroughly. Most of these conditions were already being checked. There was also some disagreement between the `MirPhase` docs and validator as to what it meant for the `body.phase` field to have a certain value. This PR resolves those disagreements in favor of the `MirPhase` docs (which is what the pass manager implemented), adjusting the validator accordingly. The result is now that the `DropLowering` phase begins with the end of the elaborate drops pass, and lasts until the beginning of the generator lowring pass. This doesn't feel entirely natural to me, but as long as it's documented accurately it should be ok. r? rust-lang/mir-opt
2022-03-23Clarify which kinds of MIR are allowed during which phases.Jakob Degen-7/+11
This enhances documentation with these details and extends the validator to check these requirements more thoroughly. As a part of this, we add a new `Deaggregated` phase, and rename other phases so that their names more naturally correspond to what they represent.
2022-03-23Address rebase falloutOli Scherer-3/+3
2022-03-23remove optimizations from const_prop_lintCarl Scherer-281/+21
2022-03-23separate const prop lint from optimizationsCarl Scherer-177/+1320
2022-03-22Rollup merge of #95196 - RalfJung:unalloc-not-uninit, r=oli-obkDylan DPC-4/+4
rename LocalState::Uninitialized to Unallocated This is to avoid confusion with `Uninit` as in `ScalarMaybeUninit`, which is very different. r? `@oli-obk`
2022-03-21rename LocalState::Uninitialized to UnallocatedRalf Jung-4/+4
2022-03-20Disable early otherwise branch MIR optJakob Degen-1/+32
2022-03-20Filter OnceNote in diagnostic infra.Camille GILLOT-1/+0
2022-03-17Rollup merge of #94960 - codehorseman:master, r=oli-obkDylan DPC-6/+6
Fix many spelling mistakes Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16rustc_error: make ErrorReported impossible to constructmark-5/+5
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-6/+6
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-12Auto merge of #94733 - nnethercote:fix-AdtDef-interning, r=fee1-deadbors-9/+9
Improve `AdtDef` interning. This commit makes `AdtDef` use `Interned`. Much of the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`. r? `@fee1-dead`
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-9/+9
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-10Move `is_trivially_pure_clone_copy` onto `Ty` insteadScott McMurray-12/+2
2022-03-10mir-opt: Replace clone on primitives with copyScott McMurray-2/+83
We can't do it for everything, but it would be nice to at least stop making calls to clone methods in debug from things like derived-clones.
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-17/+19
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-1/+1
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-03-07Introduce `ConstAllocation`.Nicholas Nethercote-4/+4
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
2022-03-03Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obkbors-1/+10
Miri/CTFE: properly treat overflow in (signed) division/rem as UB To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine. r? `@oli-obk`
2022-03-01Miri/CTFE: properly treat overflow in (signed) division/rem as UBRalf Jung-1/+10