about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2020-01-02Normalize `syntax::symbol` imports.Mazdak Farrokhzad-6/+6
2020-01-01Ensure that we process projections during MIR inliningAaron Hill-8/+4
Fixes #67710 Previously, we were not calling `super_place`, which resulted in us failing to update any local references that occur in ProjectionElem::Index. This caused the post-inlining MIR to contain a reference to a local ID from the inlined callee, leading to an ICE due to a type mismatch.
2020-01-01Auto merge of #67676 - wesleywiser:lint_overflowing_int_casts, r=oli-obkbors-63/+135
Lint overflowing integer casts in const prop This extends the invalid cases we catch in const prop to include overflowing integer casts using the same machinery as the overflowing binary and unary operation logic. r? @oli-obk
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-9/+9
2019-12-30[const-prop] Expand comment about casting ZST enumsWesley Wiser-1/+3
2019-12-30[const-prop] Clean up `check_cast()` a bitWesley Wiser-31/+35
2019-12-30[const-prop] Extract some functions out of `_const_prop`Wesley Wiser-91/+118
2019-12-30Lint overflowing integer casts in const propWesley Wiser-7/+46
This extends the invalid cases we catch in const prop to include overflowing integer casts using the same machinery as the overflowing binary and unary operation logic.
2019-12-30Auto merge of #67631 - oli-obk:polymorphic_promotion, r=wesleywiserbors-22/+62
Work around a resolve bug in const prop r? @wesleywiser @anp This isn't exposed right now, but further changes to rustc may start causing bugs without this.
2019-12-29Auto merge of #66942 - cjgillot:hirene-ty, r=Zoxcbors-1/+1
Allocate HIR on an arena 3/4 -- Ty This is the third PR in the series started by #66931 and #66936 Once again, commits don't really make sense on their own. They are mostly split by type of compile error. The additional diff is here: https://github.com/cjgillot/rust/compare/hirene-expr...hirene-ty
2019-12-29Ensure that we don't cause *new* hard errors if we suddenly can evaluate ↵Oliver Scherer-29/+41
more constants during const prop
2019-12-28Rollup merge of #67621 - matthewjasper:correct-static-type, r=oli-obkOliver Scherer-9/+8
Use the correct type for static qualifs Closes #67609
2019-12-28Prevent polymorphic const prop on assignmentsOliver Scherer-0/+7
2019-12-28Work around a resolve bug in const propOliver Scherer-1/+7
2019-12-27Fallout in other crates.Camille GILLOT-1/+1
2019-12-27Fix `Instance::resolve()` incorrectly returning specialized instancesWesley Wiser-6/+21
We only want to return specializations when `Reveal::All` is passed, not when `Reveal::UserFacing` is. Resolving this fixes several issues with the `ConstProp`, `SimplifyBranches`, and `Inline` MIR optimization passes. Fixes #66901
2019-12-26Fallout in other crates.Camille GILLOT-1/+1
2019-12-25Use the correct type for static qualifsMatthew Jasper-9/+8
2019-12-23Dynamically prevent constants from accessing staticsOliver Scherer-0/+1
2019-12-22Format the worldMark Rousskov-2171/+1835
2019-12-22Auto merge of #66931 - cjgillot:hirene-preamble, r=eddybbors-1/+1
Allocate HIR on an arena 1/4 This PR is the first in a series of 4, aiming at allocating the HIR on an arena, as a memory optimisation. 1. This first PR lays the groundwork and migrates some low-hanging fruits. 2. The second PR will migrate `hir::Expr`, `hir::Pat` and related. 3. The third PR will migrate `hir::Ty` and related. 4. The final PR will be dedicated to eventual cleanups. In order to make the transition as gradual as possible, some lowering routines receive `Box`-allocated data and move it into the arena. This is a bit wasteful, but hopefully temporary. Nonetheless, special care should be taken to avoid double arena allocations. Work mentored by @Zoxc.
2019-12-21Use Arena inside hir::EnumDef.Camille GILLOT-1/+1
2019-12-21Rollup merge of #67333 - wesleywiser:fix_inline_into_box_place, r=oli-obkMazdak Farrokhzad-10/+20
[mir-opt] Fix `Inline` pass to handle inlining into `box` expressions r? @oli-obk Before, the test case just ICE'd here: https://github.com/rust-lang/rust/blob/a605441e049f0b6d5f7715b94b8ac4662fd7fcf6/src/librustc_mir/transform/inline.rs#L668
2019-12-21Rollup merge of #67355 - Centril:merge-mut, r=oli-obkMazdak Farrokhzad-6/+6
Merge `ast::Mutability` and `mir::Mutability` r? @oli-obk
2019-12-20[mir-opt] Fix `Inline` pass to handle inlining into `box` expressionsWesley Wiser-10/+20
2019-12-201. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.Mazdak Farrokhzad-6/+6
2. mir::Mutability -> ast::Mutability.
2019-12-20Rollup merge of #67130 - wesleywiser:const_prop_into_locals, r=oli-obkMazdak Farrokhzad-18/+34
Const prop should finish propagation into user defined variables Fixes #66638 ~~Temporarily rebased on top of #67015 to get those fixes.~~ r? @oli-obk
2019-12-18Add Rvalue::AddressOf to MIRMatthew Jasper-72/+125
This operator creates a raw pointer to a Place directly, without first creating a reference. See RFC #2582 for motivation. The Rvalue is currently unused.
2019-12-16Rollup merge of #66570 - lzutao:stabilize-result-map_or, r=Dylan-DPCMazdak Farrokhzad-1/+1
stabilize Result::map_or r? @SimonSapin Closes #66293
2019-12-13Correctly mark things as `min_const_fn`Dylan MacKenzie-4/+6
2019-12-13Put MIR checks for loops behind the feature flagDylan MacKenzie-1/+7
2019-12-13Const prop should finish propagation into user defined variablesWesley Wiser-18/+34
Fixes #66638
2019-12-12Require `allow_internal_unstable` for stable min_const_fn using unstable ↵Oliver Scherer-5/+5
features
2019-12-11Auto merge of #66650 - matthewjasper:nonuniform-array-move, r=pnkfelixbors-390/+5
Remove uniform array move MIR passes This PR fixes a number of bugs caused by limitations of this pass * Projections from constant indexes weren't being canonicalized * Constant indexes from the start weren't being canonicalized (they could have different min_lengths) * It didn't apply to non-moves This PR makes the following changes to support removing this pass: * ConstantIndex of arrays are now generated in a canonical form (from the start, min_length is the actual length). * Subslices are now split when generating move paths and when checking subslices have been moved. Additionally * The parent move path of a projection from an array element is now calculated correctly closes #66502
2019-12-11Rollup merge of #67015 - osa1:issue66971, r=wesleywiserMazdak Farrokhzad-11/+37
Fix constant propagation for scalar pairs We now only propagate a scalar pair if the Rvalue is a tuple with two scalars. This for example avoids propagating a (u8, u8) value when Rvalue has type `((), u8, u8)` (see the regression test). While this is a correct thing to do, implementation is tricky and will be done later. Fixes #66971 Fixes #66339 Fixes #67019
2019-12-11Rollup merge of #67134 - oli-obk:const_prop_zst, r=wesleywiserYuki Okushi-4/+9
Ensure that we get a hard error on generic ZST constants if their bod… …y causes an error during evaluation cc #67083 (does not fix because we still need the beta backport) r? @wesleywiser cc @RalfJung
2019-12-09Remove `uniform_array_move_out` passesMatthew Jasper-386/+2
These passes were buggy, MIR building is now responsible for canonicalizing `ConstantIndex` projections and `MoveData` is responsible for splitting `Subslice` projections.
2019-12-09Make const index and subslice array projections more usefulMatthew Jasper-4/+3
* `min_length` is now exact for const index elements. * const index elements are always from the start. * make array `Subslice` `PlaceElems` count both `from` and `to` from the start.
2019-12-08Rollup merge of #66991 - Nashenas88:body_cache_cleanup, r=eddybMazdak Farrokhzad-87/+87
Cleanup BodyCache After this PR: - `BodyCache` is renamed to `BodyAndCache` - `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache` - `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in #65947) cc @eddyb @oli-obk
2019-12-08Ensure that we get a hard error on generic ZST constants if their body ↵Oliver Scherer-4/+9
causes an error during evaluation
2019-12-07Auto merge of #65881 - anp:implicit-caller-location, r=eddyb,oli-obkbors-0/+5
Implement #[track_caller] attribute. (RFC 2091 4/N) Implements the `#[track_caller]` attribute in both const and codegen contexts. The const implementation walks up the stack to find the nearest untracked callsite. The codegen implementation adds an implicit argument to tracked function calls, and populates it with either a call to the previously-landed intrinsic or if the caller has `#[track_caller]` with a copy of the location passed to the current function. Also includes a little cleanup and a few comments in the other caller location areas. [Depends on: 65664](https://github.com/rust-lang/rust/pull/65664) [RFC 2091 text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [Tracking doc](https://paper.dropbox.com/doc/track_rfc_2091_impl-notes--Anf1NwnIb0xcRv31YLIadyj0Ag-rwCdRc2fi2yvRZ7syGZ9q#:uid=863513134494965680023183&h2=TODO-actually-pass-location-to)
2019-12-06Rollup merge of #66606 - christianpoveda:mut-refs-in-const-fn, r=oli-obkMazdak Farrokhzad-32/+57
Add feature gate for mut refs in const fn r? @oli-obk
2019-12-06const-prop: Restrict scalar pair propagationÖmer Sinan Ağacan-11/+37
We now only propagate a scalar pair if the Rvalue is a tuple with two scalars. This for example avoids propagating a (u8, u8) value when Rvalue has type `((), u8, u8)` (see the regression test). While this is a correct thing to do, implementation is tricky and will be done later. Fixes #66971 Fixes #66339 Fixes #67019
2019-12-06Fix rebase issuesvarkor-2/+2
2019-12-06Rename to `then_some` and `then`varkor-1/+1
2019-12-06Use `to_option` in various placesvarkor-1/+1
2019-12-05`#[track_caller]` suppresses MIR inlining.Adam Perry-0/+5
2019-12-05rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove unneeded ↵Paul Daniel Faria-87/+87
Index impl, remove body fn rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
2019-12-05update comment to explain the importance of this check more clearlyRemy Rakic-2/+3
2019-12-05make const-qualif look at more `const fn`sRemy Rakic-1/+5
the unstables ones in libcore, with the unstable feature disabled, were not checked