about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2019-12-01Rollup merge of #66832 - RalfJung:const-prop-no-alloc, r=oli-obkMazdak Farrokhzad-7/+25
const_prop: detect and avoid catching Miri errors that require allocation r? @wesleywiser @oli-obk
2019-12-01Rollup merge of #66790 - christianpoveda:check-set-discriminant, r=oli-obkMazdak Farrokhzad-3/+2
Do `min_const_fn` checks for `SetDiscriminant`s target Fixes https://github.com/rust-lang/rust/issues/66556 r? @oli-obk @ecstatic-morse
2019-11-30Merge match branchesChristian Poveda-4/+1
2019-11-30`find_fn` -> `find_mir_or_eval_fn` renameOliver Scherer-1/+1
2019-11-30Rollup merge of #66895 - Centril:rustc_feature, r=oli-obkMazdak Farrokhzad-24/+24
Feature gating *declarations* => new crate `rustc_feature` This PR moves the data-oriented parts of feature gating into its own crate, `rustc_feature`. The parts consist of some data types as well as `accepted`, `active`, `removed`, and `builtin_attrs`. Feature gate checking itself remains in `syntax::feature_gate::check`. The parts which define how to emit feature gate errors could probably be moved to `rustc_errors` or to the new `rustc_session` crate introduced in #66878. The visitor itself could probably be moved as a pass in `rustc_passes` depending on how the dependency edges work out. The PR also contains some drive-by cleanup of feature gate checking. As such, the PR probably best read commit-by-commit. r? @oli-obk cc @petrochenkov cc @Mark-Simulacrum
2019-11-30Rollup merge of #66870 - tmiasko:simplify-ty, r=oli-obkMazdak Farrokhzad-1/+7
SimplifyArmIdentity only for locals with the same type Fixes #66856 Fixes #66851
2019-11-30move GateIssue to rustc_feature & simplify emit_feature_errMazdak Farrokhzad-24/+24
2019-11-30rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.Eduard-Mihai Burtescu-17/+13
2019-11-30rustc_mir: fix inliner to also copy over source_scope_local_data.Eduard-Mihai Burtescu-1/+10
2019-11-30rustc: move MIR source_scope_local_data's ClearCrossCrate to be around elements.Eduard-Mihai Burtescu-56/+24
2019-11-29SimplifyArmIdentity only for locals with the same typeTomasz Miąsko-1/+7
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-29Auto merge of #66321 - ninjasource:async-fn-resume-after-completion, r=oli-obkbors-6/+15
Async fn resume after completion #65419 -- Attempting to run an async fn after completion mentions generators Not yet ready for review - work in progress Just need to run the tests on a proper build server
2019-11-28Auto merge of #66642 - ecstatic-morse:promotion-in-const, r=eddybbors-100/+4
Create promoted MIR fragments for `const` and `static`s Resolves #65732. The previous strategy of removing `Drop` and `StorageDead` for promoted locals only worked for rvalue lifetime extension and only if no `loop`s were present. This PR applies the approach currently used for `fn` and `const fn`s to `const` and `statics`. This may have some performance impacts. r? @eddyb
2019-11-28const_prop: detect and avoid catching Miri errors that require allocationRalf Jung-7/+25
2019-11-28Fail fast if generator_kind is NoneDavid Haig-8/+9
2019-11-28Fixed tidy errorsDavid Haig-2/+6
2019-11-28Remove duplication using single variant for errorDavid Haig-17/+6
2019-11-28SquashDavid Haig-5/+20
2019-11-27Don't treat a reference to a `static` as a reborrowDylan MacKenzie-0/+13
They now look the same in the MIR after #66587.
2019-11-27Remove `CheckOpResult`Dylan MacKenzie-14/+6
2019-11-27Rollup merge of #66798 - bwignall:typo, r=varkorTyler Mandry-1/+1
Fix spelling typos Should be non-semantic. Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos.
2019-11-27Remove `derived_from_illegal_borrow`Dylan MacKenzie-41/+1
2019-11-27Remove `Rvalue::Ref` handling from `HasMutInterior`Dylan MacKenzie-29/+1
2019-11-27Handle `Rvalue::Ref` in one placeDylan MacKenzie-71/+106
2019-11-27Use type-based qualification for staticsDylan MacKenzie-3/+4
2019-11-27rustc: move debug info from LocalDecl and UpvarDecl into a dedicated ↵Eduard-Mihai Burtescu-34/+7
VarDebugInfo.
2019-11-27Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obkbors-4/+12
[const prop] Fix "alloc id without corresponding allocation" ICE r? @oli-obk
2019-11-26Fix spelling typosBrian Wignall-1/+1
2019-11-27Auto merge of #66794 - tmandry:rollup-99qrpr0, r=tmandrybors-0/+3
Rollup of 14 pull requests Successful merges: - #66128 (alloc: Add new_zeroed() versions like new_uninit().) - #66661 (Add riscv64gc-unknown-linux-gnu target) - #66663 (Miri: print leak report even without tracing) - #66711 (Add hardware floating point features to aarch64-pc-windows-msvc) - #66713 (introduce a target to build the kernel of the unikernel HermitCore) - #66717 (tidy: Accommodate rustfmt's preferred layout of stability attributes) - #66719 (Store pointer width as u32 on Config) - #66720 (Move ErrorReported to rustc_errors) - #66737 (Error codes cleanup) - #66754 (Various tweaks to diagnostic output) - #66763 (Minor edit for documentation-tests.md that increases clarity) - #66779 (follow the same function order in the trait) - #66786 (Add wildcard test for const_if_match) - #66788 (Allow `Unreachable` terminators through `min_const_fn` checks) Failed merges: r? @ghost
2019-11-26Change way of checking SetDiscriminantChristian Poveda-3/+2
2019-11-26Check SetDiscriminant placeChristian Poveda-2/+5
2019-11-26Allow `Unreachable` terminators behind `const_if_match`Dylan MacKenzie-0/+3
2019-11-25miri: couple ret place and ret block together (they both exist or both don't)Ralf Jung-6/+4
2019-11-24Respond to CR feedbackWesley Wiser-11/+8
2019-11-23[const prop] Fix "alloc id without corresponding allocation" ICEWesley Wiser-3/+1
Fixes #66345
2019-11-23Intern allocations during constant propagationWesley Wiser-2/+15
2019-11-23Auto merge of #66507 - ecstatic-morse:const-if-match, r=oli-obkbors-6/+26
Enable `if` and `match` in constants behind a feature flag This PR is an initial implementation of #49146. It introduces a `const_if_match` feature flag and does the following if it is enabled: - Allows `Downcast` projections, `SwitchInt` terminators and `FakeRead`s for matched places through the MIR const-checker. - Allows `if` and `match` expressions through the HIR const-checker. - Stops converting `&&` to `&` and `||` to `|` in `const` and `static` items. As a result, the following operations are now allowed in a const context behind the feature flag: - `if` and `match` - short circuiting logic operators (`&&` and `||`) - the `assert` and `debug_assert` macros (if the `const_panic` feature flag is also enabled) However, the following operations remain forbidden: - `while`, `loop` and `for` (see #52000) - the `?` operator (calls `From::from` on its error variant) - the `assert_eq` and `assert_ne` macros, along with their `debug` variants (calls `fmt::Debug`) This PR is possible now that we use dataflow for const qualification (see #64470 and #66385). r? @oli-obk cc @rust-lang/wg-const-eval @eddyb
2019-11-22Create promoted MIR fragments in `const` and `static`sDylan MacKenzie-100/+4
The previous strategy of removing `Drop` and `StorageDead` for promoted locals only worked for rvalue lifetime extension. We now use the same implementation for promotion across all kinds of items.
2019-11-22Rollup merge of #66587 - matthewjasper:handle-static-as-const, r=oli-obkMazdak Farrokhzad-82/+92
Handle statics in MIR as const pointers This is the first PR towards the goal of removing `PlaceBase::Static`. In this PR: * Statics are lowered to dereferencing a const pointer. * The temporaries holding such pointers are tracked in MIR, for the most part this is only used for diagnostics. There are two exceptions: * The borrow checker has some checks for thread-locals that directly use this data. * Const checking will suppress "cannot dereference raw pointer" diagnostics for pointers to `static mut`/`extern static`. This is to maintain the current behaviour (12 tests fail otherwise). The following are left to future PRs (I think that @spastorino will be working on the first 3): * Applying the same treatments to promoted statics. * Removing `PlaceBase::Static`. * Replacing `PlaceBase` with `Local`. * Moving the ever growing collection of metadata that we have for diagnostics in MIR passes somewhere more appropriate. r? @oli-obk
2019-11-21Allow `Downcast` projections in `qualify_min_const_fn`Dylan MacKenzie-3/+4
2019-11-21Const-check the discriminant of a `SwitchInt`Dylan MacKenzie-3/+5
2019-11-21Allow `Downcast` projections if `const_if_match` enabledDylan MacKenzie-1/+5
These are generated when matching on enum variants to extract the value within. We should have no problem evaluating these, but care should be taken that we aren't accidentally allowing some other operation.
2019-11-21Add feature gate for const `if` and `match`Dylan MacKenzie-2/+15
2019-11-21Track pointers to statics in MIRMatthew Jasper-60/+70
2019-11-21Fix rebaseMatthew Jasper-1/+1
2019-11-21Readjust const qualification to detect statics againSantiago Pastorino-23/+23
2019-11-21Introduce MIR optimizations for simplifying `x?` on `Result`s.Mazdak Farrokhzad-0/+205
This optimization depends on inlining for the identity conversions introduced by the lowering of the `?`. To take advantage of `SimplifyArmIdentity`, `-Z mir-opt-level=2` is required because that triggers the inlining MIR optimization.
2019-11-19Auto merge of #66074 - wesleywiser:test_run_const_prop, r=oli-obkbors-14/+27
[mir-opt] Turn on the `ConstProp` pass by default perf.rlo shows that running the `ConstProp` pass results in across-the-board wins regardless of debug or opt complilation mode. As a result, we're turning it on to get the compile time benefits.
2019-11-17Auto merge of #66385 - ecstatic-morse:check-only-pass2, r=eddybbors-1566/+243
Make dataflow-based const qualification the canonical one For over a month, dataflow-based const qualification has been running in parallel with `qualify_consts` to check the bodies of `const` and `static`s. This PR removes the old qualification pass completely in favor of the dataflow-based one. **edit:** This PR also stops checking `QUALIF_ERROR_BIT` during promotion. This check appears to no longer serve a purpose now that the CTFE engine is more robust. As a side-effect, this resolves #66167. r? @eddyb
2019-11-15[ConstProp] Avoid OOM crashes by not evaluating large PlacesWesley Wiser-0/+5
Fixes #66397