summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2018-11-22Replace the ICEing on const fn loops with an errorOliver Scherer-5/+3
2018-11-19Refactor and add `PlaceContext::AscribeUserTy`.David Wood-35/+48
This commit refactors `PlaceContext` to split it into four different smaller enums based on if the context represents a mutating use, non-mutating use, maybe-mutating use or a non-use (this is based on the recommendation from @oli-obk on Zulip[1]). This commit then introduces a `PlaceContext::AscribeUserTy` variant. `StatementKind::AscribeUserTy` is now correctly mapped to `PlaceContext::AscribeUserTy` instead of `PlaceContext::Validate`. `PlaceContext::AscribeUserTy` can also now be correctly categorized as a non-use which fixes an issue with constant promotion in statics after a cast introduces a `AscribeUserTy` statement. [1]: https://rust-lang.zulipchat.com/#narrow/stream/122657-wg-nll/subject/.2355288.20cast.20fails.20to.20promote.20to.20'static/near/136536949
2018-11-19Add helpful logging statements.David Wood-1/+29
This commit adds logging statements to `promote_consts` and `qualify_consts` to make it easier to understand what it is doing.
2018-10-31Fix an ICE in the min_const_fn analysisOliver Scherer-2/+3
2018-10-29Checkpoint: Added abstraction over collection of projections into user type.Felix S. Klock II-3/+3
I did not think I would need this in the MIR, but in general local decls are going to need to support this. (That, or we need to be able define a least-upper-bound for a collection of types encountered via the pattern compilation.)
2018-10-20Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasperbors-1/+1
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`. An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).
2018-10-19Prefer `Default::default` over `FxHash*::default` in struct constructorsOliver Scherer-8/+6
2018-10-19Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hackOliver Scherer-5/+5
2018-10-19Rollup merge of #55071 - oli-obk:const_cast_🍨, r=RalfJungkennytm-3/+16
Fix ICE and report a human readable error fixes #55063 r? @RalfJung
2018-10-19Prefer unwrap_or_else to unwrap_or in case of function calls/allocationsljedrz-1/+1
2018-10-17Squash closure cast error into fn ptr cast errorOliver SΜΆcΜΆhΜΆnΜΆeΜΆiΜΆdΜΆeΜΆr Scherer-4/+1
2018-10-15Explain all casts in detailOliver Scherer-2/+11
2018-10-14[mir-inlining] Don't inline virtual callsWesley Wiser-7/+16
Prior to this change, the test case would output `1` instead of `2` like it should.
2018-10-14Fix ICE and report a human readable errorOliver Scherer-3/+10
2018-10-12Auto merge of #54715 - oli-obk:nll_deref_promotion, r=RalfJungbors-14/+22
Fix #54224 (const promotion regression) r? @eddyb
2018-10-12Add comments explaining why some operations are not constant inside normal ↡Oliver Scherer-0/+6
functions
2018-10-09miri engine: also check return type before calling functionRalf Jung-0/+1
2018-10-05Add flag to `mir::LocalDecl` to track whether its a temp from some subexpr a ↡Felix S. Klock II-0/+3
block tail expression. Slightly refactored the `LocalDecl` construction API in the process.
2018-10-04Auto merge of #54666 - matthewjasper:mir-function-spans, r=pnkfelixbors-2/+5
[NLL] Improve "borrow later used here" messages * In the case of two conflicting borrows, the later used message says which borrow it's referring to * If the later use is a function call (from the users point of view) say that the later use is for the call. Point just to the function. r? @pnkfelix Closes #48643
2018-10-03Record whether a Call in MIR corresponds to a call in HIRMatthew Jasper-2/+5
2018-10-03Only promote calls to `#[rustc_promotable]` const fnsOliver Schneider-76/+91
2018-10-02Rollup merge of #54702 - RalfJung:fn-ptr-promotion, r=oli-obkPietro Albini-1/+1
do not promote comparing function pointers This *could* break existing code that relied on fn ptr comparison getting promoted to `'static` lifetime. Fixes https://github.com/rust-lang/rust/issues/54696
2018-10-01Auto merge of #54693 - RalfJung:ctfe-scalar-pair-undef, r=oli-obkbors-2/+2
do not normalize all non-scalar constants to a ConstValue::ScalarPair We still need `ConstValue::ScalarPair` for match handling (matching slices and strings), but that will never see anything `Undef`. For non-fat-ptr `ScalarPair`, just point to the allocation like larger data structures do. Fixes https://github.com/rust-lang/rust/issues/54387 r? @eddyb
2018-10-01Fix #54224 (const promotion regression)Oliver Schneider-14/+16
2018-09-30do not promote comparing function pointersRalf Jung-1/+1
2018-09-30move ScalarMaybeUndef into the miri engineRalf Jung-2/+2
2018-09-29Merge branch 'master' into dropMichael Bradshaw-35/+43
2018-09-28rustc: keep a Span for each predicate in ty::GenericPredicates.Eduard-Mihai Burtescu-1/+1
2018-09-26Auto merge of #54526 - nnethercote:shrink-StatementKind, r=nagisabors-34/+42
Shrink `StatementKind` `StatementKind` occurs in significant amounts in Massif profiles.
2018-09-26Make core::mem::needs_drop a const fnMichael Bradshaw-0/+1
2018-09-25Auto merge of #53438 - matthewjasper:permissive-match-access, r=pnkfelixbors-2/+65
[NLL] Be more permissive when checking access due to Match Partially addresses #53114. notably, we should now have parity with AST borrowck. Matching on uninitialized values is still forbidden. * ~~Give fake borrows for match their own `BorrowKind`~~ * ~~Allow borrows with this kind to happen on values that are already mutably borrowed.~~ * ~~Track borrows with this type even behind shared reference dereferences and consider all accesses to be deep when checking for conflicts with this borrow type. See [src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs](https://github.com/rust-lang/rust/commit/cb5c989598178af505fb215dd97afca8cc2b659f#diff-a2126cd3263a1f5342e2ecd5e699fbc6) for an example soundness issue this fixes (a case of #27282 that wasn't handled correctly).~~ * Create a new `BorrowKind`: `Shallow` (name can be bike-shed) * `Shallow` borrows differ from shared borrows in that * When we check for access we treat them as a `Shallow(Some(_))` read * When we check for conflicts with them, if the borrow place is a strict prefix of the access place then we don't consider that a conflict. * For example, a `Shallow` borrow of `x` does not conflict with any access or borrow of `x.0` or `*x` * Remove the current fake borrow in matches. * When building matches, we take a `Shallow` borrow of any `Place` that we switch on or bind in a match, and any prefix of those places. (There are some optimizations where we do fewer borrows, but this shouldn't change semantics) * `match x { &Some(1) => (), _ => (), }` would `Shallow` borrow `x`, `*x` and `(*x as Some).0` (the `*x` borrow is unnecessary, but I'm not sure how easy it would be to remove.) * Replace the fake discriminant read with a `ReadForMatch`. * Change ReadForMatch to only check for initializedness (to prevent `let x: !; match x {}`), but not conflicting borrows. It is still considered a use for liveness and `unsafe` checking. * Give special cased error messages for this kind of borrow. Table from the above issue after this PR | Thing | AST | MIR | Want | Example | | --- | --- | --- | --- |---| | `let _ = <unsafe-field>` | πŸ’š | πŸ’š | ❌ | [playground](https://play.rust-lang.org/?gist=bb7843e42fa5318c1043d04bd72abfe4&version=nightly&mode=debug&edition=2015) | | `match <unsafe_field> { _ => () }` | ❌ | ❌ | ❌ | [playground](https://play.rust-lang.org/?gist=3e3af05fbf1fae28fab2aaf9412fb2ea&version=nightly&mode=debug&edition=2015) | | `let _ = <moved>` | πŸ’š | πŸ’š | πŸ’š | [playground](https://play.rust-lang.org/?gist=91a6efde8288558e584aaeee0a50558b&version=nightly&mode=debug&edition=2015) | | `match <moved> { _ => () }` | ❌ | ❌ | πŸ’š | [playground](https://play.rust-lang.org/?gist=804f8185040b2fe131f2c4a64b3048ca&version=nightly&mode=debug&edition=2015) | | `let _ = <borrowed>` | πŸ’š | πŸ’š | πŸ’š | [playground](https://play.rust-lang.org/?gist=0e487c2893b89cb772ec2f2b7c5da876&version=nightly&mode=debug&edition=2015) | | `match <borrowed> { _ => () }` | πŸ’š | πŸ’š | πŸ’š | [playground](https://play.rust-lang.org/?gist=0e487c2893b89cb772ec2f2b7c5da876&version=nightly&mode=debug&edition=2015) | r? @nikomatsakis
2018-09-24Add a MIR transform to remove fake readsMatthew Jasper-2/+65
As we are now creating borrows of places that may not be valid for borrow checking matches, these have to be removed to avoid generating broken code.
2018-09-24Auto merge of #54416 - christianpoveda:master, r=wesleywiserbors-2/+2
Extend MIR inlining to all operand variants This fixes https://github.com/rust-lang/rust/issues/54193 r? @eddyb
2018-09-24Shrink StatementKind::Assign.Nicholas Nethercote-34/+42
This shrinks StatementKind from 80 bytes to 64 bytes on 64-bit.
2018-09-23Auto merge of #54380 - RalfJung:miri-snapshot, r=eddybbors-9/+9
move CTFE engine snapshot state out of miri engine into CTFE machine instance It still lives in the `interpret` module as it needs access to all sorts of private stuff. Also rename a thing to make @eddyb happy :D The goal was not to change any behavior.
2018-09-20Extend MIR inlining to all operand variantsChristian Poveda-2/+2
2018-09-20move loop detector constants to the module that uses them; make lifetime ↡Ralf Jung-6/+6
order in ConstPropagator consistent with Memory
2018-09-20rename evaluator -> interpreter to make eddyb happyRalf Jung-3/+3
2018-09-20move CTFE engine snapshot state out of miri engine into CTFE machine instanceRalf Jung-2/+2
2018-09-18Refactor 'ReadForMatch' into 'FakeRead' and add the cause of the fake readRemy Rakic-5/+5
2018-09-18Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs.Nicholas Nethercote-49/+47
Currently we have two files implementing bitsets (and 2D bit matrices). This commit combines them into one, taking the best features from each. This involves renaming a lot of things. The high level changes are as follows. - bitvec.rs --> bit_set.rs - indexed_set.rs --> (removed) - BitArray + IdxSet --> BitSet (merged, see below) - BitVector --> GrowableBitSet - {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet - BitMatrix --> BitMatrix - SparseBitMatrix --> SparseBitMatrix The changes within the bitset types themselves are as follows. ``` OLD OLD NEW BitArray<C> IdxSet<T> BitSet<T> -------- ------ ------ grow - grow new - (remove) new_empty new_empty new_empty new_filled new_filled new_filled - to_hybrid to_hybrid clear clear clear set_up_to set_up_to set_up_to clear_above - clear_above count - count contains(T) contains(&T) contains(T) contains_all - superset is_empty - is_empty insert(T) add(&T) insert(T) insert_all - insert_all() remove(T) remove(&T) remove(T) words words words words_mut words_mut words_mut - overwrite overwrite merge union union - subtract subtract - intersect intersect iter iter iter ``` In general, when choosing names I went with: - names that are more obvious (e.g. `BitSet` over `IdxSet`). - names that are more like the Rust libraries (e.g. `T` over `C`, `insert` over `add`); - names that are more set-like (e.g. `union` over `merge`, `superset` over `contains_all`, `domain_size` over `num_bits`). Also, using `T` for index arguments seems more sensible than `&T` -- even though the latter is standard in Rust collection types -- because indices are always copyable. It also results in fewer `&` and `*` sigils in practice.
2018-09-12Merge branch 'master' into kenta7777#53719kenta7777-17/+20
2018-09-10propagate user-ascribes types down onto resulting bindingsNiko Matsakis-0/+3
But only in very simple cases.
2018-09-10fixup: rename `UserAssertTy` to `AscribeUserType`Niko Matsakis-1/+1
This is some rebase pain.
2018-09-10add the `AscribeUserType` statement kindNiko Matsakis-16/+16
Make it have the semantics of subtype.
2018-09-10renamed mk_nil to mk_unitkenta7777-2/+2
2018-09-08Auto merge of #53903 - GabrielMajeri:opt-miri-array-slice, r=oli-obkbors-1/+1
Optimize miri checking of integer array/slices This pull request implements the optimization described in #53845 (the `E-easy` part of that issue, not the refactoring). Instead of checking every element of an integral array, we can check the whole memory range at once. r? @RalfJung
2018-09-08Auto merge of #53705 - ms2300:tmp, r=oli-obkbors-1/+1
#53576 Renaming TyAnon -> TyOpaque Fixes #53576
2018-09-08Optimize miri checking of integer array/slicesGabriel Majeri-1/+1
Instead of checking every element, we can check the whole memory range at once.
2018-09-07make field always private, add `From` implsNiko Matsakis-5/+2