about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
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-04Don't try to promote already promoted out temporariesOliver Schneider-4/+16
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
2018-09-06Fixing tests from anon -> opaquems2300-1/+1
2018-09-03Auto merge of #53697 - Cyres:const-fn-int-ops, r=oli-obkbors-1/+10
Add more const int ops r? @oli-obk Tracking Issue: #53718 list of `const fn`s in this PR: - `feature = const_int_rotate` - `rotate_left` - `rotate_right` - `feature = const_int_wrapping` - `wrapping_add` - `wrapping_sub` - `wrapping_mul` - `wrapping_shl` - `wrapping_shr` - `feature = const_int_overflowing` - `overflowing_add` - `overflowing_sub` - `overflowing_mul` - `overflowing_shl` - `overflowing_shr` - `feature = const_int_sign` - `is_positive` - `is_negative` - `feature = const_int_conversion` - `reverse_bits` - `to_le_bytes` - `to_ne_bytes` - `from_be_bytes` - `from_le_bytes` - `from_ne_bytes` - `reverse_bits`
2018-09-01rebaseTim-1/+10
2018-09-01Auto merge of #53604 - oli-obk:min_const_fn, r=Centril,varkorbors-10/+402
Implement the `min_const_fn` feature gate cc @RalfJung @eddyb r? @Centril implements the feature gate for #53555 I added a hack so the `const_fn` feature gate also enables the `min_const_fn` feature gate. This ensures that nightly users of `const_fn` don't have to touch their code at all. The `min_const_fn` checks are run first, and if they succeeded, the `const_fn` checks are run additionally to ensure we didn't miss anything.
2018-08-31Auto merge of #53699 - oli-obk:promotion_stability_hole, r=nikomatsakisbors-3/+1
Fix promotion stability hole in old borrowck r? @nikomatsakis I screwed up the promotion stability checks. Big time. They were basically nonexistant. We had tests for it. I also screwed up said tests. This is in stable already :( Basically stability checks of promotion only worked if you tried to use a const fn defined in the same crate. cc @eddyb
2018-08-31Get rid of token passingOliver Schneider-55/+35
2018-08-31Implement the `min_const_fn` feature gateOliver Schneider-10/+422
2018-08-31Auto merge of #53832 - pietroalbini:rollup, r=pietroalbinibors-12/+17
Rollup of 20 pull requests Successful merges: - #51760 (Add another PartialEq example) - #53113 (Add example for Cow) - #53129 (remove `let x = baz` which was obscuring the real error) - #53389 (document effect of join on memory ordering) - #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.) - #53476 (Add partialeq implementation for TryFromIntError type) - #53513 (Force-inline `shallow_resolve` at its hottest call site.) - #53655 (set applicability) - #53702 (Fix stabilisation version for macro_vis_matcher.) - #53727 (Do not suggest dereferencing in macro) - #53732 (save-analysis: Differentiate foreign functions and statics.) - #53740 (add llvm-readobj to llvm-tools-preview) - #53743 (fix a typo: taget_env -> target_env) - #53747 (Rustdoc fixes) - #53753 (expand keep-stage --help text) - #53756 (Fix typo in comment) - #53768 (move file-extension based .gitignore down to src/) - #53785 (Fix a comment in src/libcore/slice/mod.rs) - #53786 (Replace usages of 'bad_style' with 'nonstandard_style'.) - #53806 (Fix UI issues on Implementations on Foreign types) Failed merges: r? @ghost
2018-08-31Auto merge of #53779 - RalfJung:miri-refactor, r=oli-obkbors-12/+20
Miri refactor: Final round Tying up some loose ends that I noticed in the previous PRs -- and finally getting argument passing into a shape where @eddyb says it is "okay", which is a big improvement over the previous verdict that I cannot quote in public. ;) Also move a bunch of useful helpers to construct `Scalar` from miri to here. Cc @eddyb r? @oli-obk
2018-08-30Rollup merge of #53472 - eddyb:fx-pls, r=pnkfelixPietro Albini-12/+17
Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc. Most of the compiler uses the `Fx` hasher but some places ended up with the default one.