about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2019-04-24Evaluate hair::ExprKind::Use in intoMatthew Jasper-18/+17
This avoids some unnecessary moves
2019-04-24Rollup merge of #56278 - eddyb:mir-debuginfo-proof, r=nikomatsakisMazdak Farrokhzad-27/+27
Future-proof MIR for dedicated debuginfo. This is #56231 without the last commit (the one that actually moves to `VarDebuginfo`). Nothing should be broken, but it should no longer depend on debuginfo for anything else. r? @nikomatsakis
2019-04-23rustc_mir: create the `let` and "remainder" scopes in source order.Eduard-Mihai Burtescu-8/+8
2019-04-23rustc_mir: pretty-print all locals into their respective scopes.Eduard-Mihai Burtescu-22/+22
2019-04-23Rollup merge of #60169 - varkor:tidy-unnecessary-ignore-newline, r=kennytmMazdak Farrokhzad-5/+0
Warn when ignore-tidy-linelength is present, but no lines are too long It's easy for a `// ignore-tidy-linelength` to be added when there is a genuine need to ignore a file's line length, but then after refactoring the need is gone, but the tidy directive is not removed. This means that in the future, further editing may accidentally add unnecessarily long lines. This change forces `// ignore-tidy-linelength` to be used exactly when necessary, to make sure such changes are intentional.
2019-04-23Rollup merge of #59823 - davidtwco:issue-54716, r=cramertjMazdak Farrokhzad-2/+2
[wg-async-await] Drop `async fn` arguments in async block Fixes #54716. This PR modifies the HIR lowering (and some other places to make this work) so that unused arguments to a async function are always dropped inside the async move block and not at the end of the function body. ``` async fn foo(<pattern>: <type>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>) { async move { let <pattern>: <ty> = __arg0; } // <-- dropped as you "exit" the async block } ``` However, the exact ordering of drops is not the same as a regular function, [as visible in this playground example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=be39af1a58e5d430be1eb3c722cb1ec3) - I believe this to be an unrelated issue. There is a [Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/187312-t-compiler.2Fwg-async-await/topic/.2354716.20drop.20order) for this. r? @cramertj cc @nikomatsakis
2019-04-23Remove unnecessary ignore-tidy-linelengthvarkor-5/+0
2019-04-22update tests for migrate mode by defaultMatthew Jasper-4/+6
2019-04-21Move `async fn` arguments into closure.David Wood-2/+2
This commit takes advantage of `AsyncArgument` type that was added in a previous commit to replace the arguments of the `async fn` in the HIR and add statements to move the bindings from the new arguments to the pattern from the old argument. For example, the async function `foo` below: async fn foo((x, _y): (T, V)) { async move { } } becomes: async fn foo(__arg0: (T, V)) { async move { let (x, _y) = __arg0; } }
2019-04-20Auto merge of #59987 - saleemjaffer:refactor_adjust_castkinds, r=oli-obkbors-1/+1
Refactor Adjust and CastKind fixes rust-lang#59588
2019-04-16fixing testsSaleem Jaffer-1/+1
2019-04-14Update testsJohn Kåre Alsaker-3/+3
2019-03-31Fixes for shallow borrowsMatthew Jasper-2/+2
* Don't promote these borrows if we're going to remove them before codegen * Correctly mark unreachable code
2019-03-24Auto merge of #59382 - davidtwco:rfc-2008-refactoring, r=petrochenkovbors-2/+2
Separate `DefId`s for variants and their constructors Part of #44109. Split off from #59376. See [Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/rfc-2008/near/132663140) for previous discussion. r? @petrochenkov
2019-03-24Merge `DefPathData::VariantCtor` and `DefPathData::StructCtor`Vadim Petrochenkov-2/+2
2019-03-24Rollup merge of #59251 - matthewjasper:fix-graphviz, r=petrochenkovkennytm-0/+23
Use a valid name for graphviz graphs Hiridification has broken graphviz output because `HirId` has a more complex display implemetation than `NodeId`. Since the id was just used to generate a distinct identifier, we just pull out the various constituent indexed.
2019-03-24Separate variant id and variant constructor id.David Wood-2/+2
This commit makes two changes - separating the `NodeId` that identifies an enum variant from the `NodeId` that identifies the variant's constructor; and no longer creating a `NodeId` for `Struct`-style enum variants and structs. Separation of the variant id and variant constructor id will allow the rest of RFC 2008 to be implemented by lowering the visibility of the variant's constructor without lowering the visbility of the variant itself. No longer creating a `NodeId` for `Struct`-style enum variants and structs mostly simplifies logic as previously this `NodeId` wasn't used. There were various cases where the `NodeId` wouldn't be used unless there was an unit or tuple struct or enum variant but not all uses of this `NodeId` had that condition, by removing this `NodeId`, this must be explicitly dealt with. This change mostly applied cleanly, but there were one or two cases in name resolution and one case in type check where the existing logic required a id for `Struct`-style enum variants and structs.
2019-03-21Auto merge of #58902 - matthewjasper:generator-cleanup-blocks, r=davidtwcobors-20/+63
Fixes for the generator transform * Moves cleanup annotations in pretty printed MIR so that they can be tested * Correctly determines which drops are in cleanup blocks when elaborating generator drops * Use the correct state for poisoning a generator Closes #58892
2019-03-19Run branch cleanup after copy propOliver Scherer-0/+22
2019-03-17Use a valid name for graphviz graphsMatthew Jasper-0/+23
2019-03-16Rollup merge of #59036 - dlrobertson:fix_59021, r=estebankkennytm-0/+18
Fix ICE in MIR pretty printing A `Def::Variant` should be considered as a function in mir pretty printing. Each variant has a constructor that we must print. Given the following enum definition: ```rust pub enum TestMe { X(usize), } ``` We will need to generate a constructor for the variant `X` with a signature that looks something like the following: ``` fn TestMe::X(_1: usize) -> TestMe; ``` Fixes: #59021
2019-03-15rustc: provide DisambiguatedDefPathData in ty::print.Eduard-Mihai Burtescu-1/+1
2019-03-15rustc: rename item_path to def_path (except the module in ty).Eduard-Mihai Burtescu-1/+1
2019-03-15rustc: explicitly pass the namespace to PrintCx::parameterized.Eduard-Mihai Burtescu-5/+5
2019-03-10Fix ICE in MIR pretty printingDan Robertson-0/+18
A `Def::Variant` should be considered as a function in mir pretty printing. Each variant has a constructor that we must print. Given the following enum definition: ``` pub enum TestMe { X(usize), } ``` We will need to generate a constructor for the variant `X` with a signature that looks something like the following: ``` fn TestMe::X(_1: usize) -> TestMe; ```
2019-03-07HirIdification: replace NodeId method callsljedrz-3/+3
2019-03-03Don't incorrectly mark blocks in generator drop shims as cleanupMatthew Jasper-0/+43
This also ensure that dropping a generator won't leak upvars if dropping one of them panics
2019-03-03Check which blocks are cleanup in mir-opt testsMatthew Jasper-20/+20
2019-02-21Move the exit block of the match to the endMatthew Jasper-121/+121
2019-02-21Simplify the cleanup_post_borrowck passesMatthew Jasper-5/+5
2019-02-21Use normal mutable borrows in MIR match loweringMatthew Jasper-64/+60
2019-02-21Clean up MIR match loweringMatthew Jasper-270/+259
* Adjust fake borrows to only be live over guards. * Remove unused `slice_len_checked` field. * Split the methods on builder into those for matches and those for all kinds of pattern bindings.
2019-02-15Always emit an error for a query cycleJohn Kåre Alsaker-14/+14
2019-02-10Add test for MIR printing changesMatthew Jasper-0/+66
2019-01-19Don't ignore `_` in type casts and ascriptionsMatthew Jasper-7/+7
2019-01-19Rename UserTypeAnnotation -> UserTypeMatthew Jasper-1/+1
2018-12-30Refactor `UserTypeAnnotation`.David Wood-1/+1
This commit refactors the `UserTypeAnnotation` type to be referred to by an index within `UserTypeProjection`. `UserTypeAnnotation` is instead kept in an `IndexVec` within the `Mir` struct. Further, instead of `UserTypeAnnotation` containing canonicalized types, it now contains normal types and the entire `UserTypeAnnotation` is canonicalized. To support this, the type was moved from the `rustc::mir` module to `rustc::ty` module.
2018-12-25Remove licensesMark Rousskov-319/+0
2018-12-20Auto merge of #54125 - varkor:less-conservative-uninhabitedness-check, ↵bors-0/+37
r=nikomatsakis Less conservative uninhabitedness check Extends the uninhabitedness check to structs, non-empty enums, tuples and arrays. Pulled out of #47291 and #50262. Fixes https://github.com/rust-lang/rust/issues/54586. r? @nikomatsakis
2018-12-18treat ref-to-raw cast like a reborrow: do a special kind of retagRalf Jung-1/+1
2018-12-17Auto merge of #56810 - sinkuu:build_match, r=oli-obkbors-0/+85
Improve MIR match generation for ranges Improves MIR match generation to rule out ranges/values distinct from the range that has been tested. e.g., for this code: ```rust match x { 0..=5 if b => 0, 6..=10 => 1, _ => 2, } ``` MIR (before): ```rust bb0: { ...; _4 = Le(const 0i32, _1); switchInt(move _4) -> [false: bb6, otherwise: bb5]; } bb1: { _3 = const 0i32; goto -> bb8; } bb2: { _6 = _2; switchInt(move _6) -> [false: bb6, otherwise: bb1]; } // If `!b`, jumps to test if `6 <= x <= 10`. bb3: { _3 = const 1i32; goto -> bb8; } bb4: { _3 = const 2i32; goto -> bb8; } bb5: { _5 = Le(_1, const 5i32); switchInt(move _5) -> [false: bb6, otherwise: bb2]; } bb6: { _7 = Le(const 6i32, _1); switchInt(move _7) -> [false: bb4, otherwise: bb7]; } bb7: { _8 = Le(_1, const 10i32); switchInt(move _8) -> [false: bb4, otherwise: bb3]; } ``` MIR (after): ```rust bb0: { ...; _4 = Le(const 0i32, _1); switchInt(move _4) -> [false: bb5, otherwise: bb6]; } bb1: { _3 = const 0i32; goto -> bb8; } bb2: { _6 = _2; switchInt(move _6) -> [false: bb4, otherwise: bb1]; } // If `!b`, jumps to `_ =>` arm. bb3: { _3 = const 1i32; goto -> bb8; } bb4: { _3 = const 2i32; goto -> bb8; } bb5: { _7 = Le(const 6i32, _1); switchInt(move _7) -> [false: bb4, otherwise: bb7]; } bb6: { _5 = Le(_1, const 5i32); switchInt(move _5) -> [false: bb5, otherwise: bb2]; } bb7: { _8 = Le(_1, const 10i32); switchInt(move _8) -> [false: bb4, otherwise: bb3]; } ``` cc #29623
2018-12-17tidyShotaro Yamada-1/+1
2018-12-17Add MIR testShotaro Yamada-0/+85
2018-12-13Make SimplifyCfg collapse goto chains from bb0Shotaro Yamada-0/+54
2018-12-11Add a mir-opt testvarkor-0/+37
2018-11-18Simplify MIR drop generationMatthew Jasper-34/+7
Now that EndRegion is gone, we don't need to create as many gotos.
2018-11-18Remove mir::StatementKind::EndRegionMatthew Jasper-1069/+1
Since lexical MIR borrow check is gone, and validation no longer uses these, they can be removed.
2018-11-15Auto merge of #55716 - RalfJung:escape-to-raw, r=oli-obkbors-4/+68
Add escape-to-raw MIR statement Add a new MIR "ghost state statement": Escaping a ptr to permit raw accesses. ~~This includes #55549, [click here](https://github.com/RalfJung/rust/compare/miri-visitor...RalfJung:escape-to-raw) for just the new commits.~~
2018-11-09Don't inline virtual calls (take 2)Wesley Wiser-0/+36
When I fixed the previous mis-optimizations, I didn't realize there were actually two different places where we mutate `callsites` and both of them should have the same behavior. As a result, if a function was inlined and that function contained virtual function calls, they were incorrectly being inlined. I also added a test case which covers this.
2018-11-07array index accesses are stable placesRalf Jung-0/+43