summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2018-02-12Auto merge of #47843 - estebank:teach, r=nikomatsakisbors-30/+138
Add `-Zteach` documentation Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027. Follow up to #47652.
2018-02-09Auto merge of #47802 - bobtwinkles:loop_false_edge, r=nikomatsakisbors-3/+12
[NLL] Add false edges out of infinite loops Resolves #46036 by adding a `cleanup` member to the `FalseEdges` terminator kind. There's also a small doc fix to one of the other comments in `into.rs` which I can pull out in to another PR if desired =) This PR should pass CI but the test suite has been relatively unstable on my system so I'm not 100% sure. r? @nikomatsakis
2018-02-09Auto merge of #47489 - pnkfelix:limit-2pb-issue-46747, r=nikomatsakisbors-3/+3
NLL: Limit two-phase borrows to autoref-introduced borrows This imposes a restriction on two-phase borrows so that it only applies to autoref-introduced borrows. The goal is to ensure that our initial deployment of two-phase borrows is very conservative. We want it to still cover the `v.push(v.len());` example, but we do not want it to cover cases like `let imm = &v; let mu = &mut v; mu.push(imm.len());` (Why do we want it to be conservative? Because when you are not conservative, then the results you get, at least with the current analysis, are tightly coupled to details of the MIR construction that we would rather remain invisible to the end user.) Fix #46747 I decided, for this PR, to add a debug-flag `-Z two-phase-beyond-autoref`, to re-enable the more general approach. But my intention here is *not* that we would eventually turn on that debugflag by default; the main reason I added it was that I thought it was useful for writing tests to be able to write source that looks like desugared MIR.
2018-02-08Encode (in MIR) whether borrows are explicit in source or arise due to autoref.Felix S. Klock II-3/+3
This is foundation for issue 46747 (limit two-phase borrows to method-call autorefs).
2018-02-07Add `-Zteach` documentationEsteban Küber-30/+138
Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027.
2018-02-05mir: Add TerminatorKind::FalseUnwindbobtwinkles-3/+12
Sometimes a simple goto misses the cleanup/unwind edges. Specifically, in the case of infinite loops such as those introduced by a loop statement without any other out edges. Analogous to TerminatorKind::FalseEdges; this new terminator kind is used when we want borrowck to consider an unwind path, but real control flow should never actually take it.
2018-02-05rustc: Add `#[rustc_args_required_const]`Alex Crichton-11/+53
This commit adds a new unstable attribute to the compiler which requires that arguments to a function are always provided as constants. The primary use case for this is SIMD intrinsics where arguments are defined by vendors to be constant and in LLVM they indeed must be constant as well. For now this is mostly just a semantic guarantee in rustc that an argument is a constant when invoked, phases like trans don't actually take advantage of it yet. This means that we'll be able to use this in stdsimd but we won't be able to remove the `constify_*` macros just yet. Hopefully soon though!
2018-02-05Rollup merge of #47892 - Badel2:const_type_id_of, r=oli-obkkennytm-1/+1
Turn `type_id` into a constant intrinsic https://github.com/rust-lang/rust/issues/27745 The method `get_type_id` in `Any` is intended to support reflection. It's currently unstable in favor of using an associated constant instead. This PR makes the `type_id` intrinsic a constant intrinsic, the same as `size_of` and `align_of`, allowing `TypeId::of` to be a `const fn`, which will allow using an associated constant in `Any`.
2018-02-04Auto merge of #47915 - eddyb:layout-of, r=nikomatsakisbors-2/+1
rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. This PR provides `tcx.layout_of(param_env.and(ty))` as the idiomatic replacement for the existing `(tcx, param_env).layout_of(ty)` and removes fragile (coherence-wise) layout-related tuple impls. r? @nikomatsakis
2018-02-03Auto merge of #47845 - Zoxc:gen-fixes, r=nikomatsakisbors-17/+51
Generator bugfixes r? @nikomatsakis
2018-02-01Turn `type_id` into a constant intrinsicBadel2-1/+1
Add rustc_const_unstable attribute for `any::TypeId::of` Add test for `const fn TypeId::of`
2018-02-01rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf.Eduard-Mihai Burtescu-2/+1
2018-01-30Force locals to be live after they are borrowed for immovable generators. ↵John Kåre Alsaker-17/+51
Fixes #47736
2018-01-29rustc: replace "lvalue" terminology with "place" in the code.Eduard-Mihai Burtescu-10/+10
2018-01-23Make immovable generators unsafeJohn Kåre Alsaker-2/+10
2018-01-23Adds support for immovable generators. Move checking of invalid borrows ↵John Kåre Alsaker-16/+61
across suspension points to borrowck. Fixes #44197, #45259 and #45093.
2018-01-16remove noop landing pads in cleanup shimsAriel Ben-Yehuda-6/+13
These are already removed in the normal optimization pipeline - so this should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM. This un-regresses and is therefore a fix for #47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics.
2018-01-11Don't track local_needs_drop separately in qualify_consts (fixes #47351).Alexander Regueiro-23/+31
2018-01-03Auto merge of #46984 - arielb1:pre-statement-effect, r=nikomatsakisbors-2/+9
NLL fixes First, introduce pre-statement effects to dataflow to fix #46875. Edge dataflow effects might make that redundant, but I'm not sure of the best way to integrate them with liveness etc., and if this is a hack, this is one of the cleanest hacks I've seen. And I want a small fix to avoid the torrent of bug reports. Second, fix linking of projections to fix #46974 r? @pnkfelix
2017-12-24Auto merge of #46896 - arielb1:shadow-scope, r=eddybbors-3/+3
fix debuginfo scoping of let-statements r? @eddyb
2017-12-24add pre-statement-effect to dataflowAriel Ben-Yehuda-2/+9
2017-12-21fix debuginfo scoping of let-statementsAriel Ben-Yehuda-3/+3
2017-12-21Mir: Add Terminatorkind::AbortDavid Henningsson-0/+4
The Abort Terminatorkind will cause an llvm.trap function call to be emitted. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2017-12-20Rollup merge of #46852 - scottmcm:asm-placecontext, r=arielb1kennytm-0/+2
Split PlaceContext::Store into Store & AsmOutput Outputs in InlineAsm can be read-write, so splitting it out is useful for things like Store-Store folding, as that's unsound for a Store-AsmOutput. This PR is intended to make no changes, just be the mechanical split of the enum. Future changes can use the split, like a MIR pass I'm working on and perhaps two-phase borrows (see this FIXME: https://github.com/rust-lang/rust/pull/46852/files#diff-74dcd7740ab2104cd2b9a3b68dd4f208R543)
2017-12-20Auto merge of #46733 - nikomatsakis:nll-master-to-rust-master-5, r=arielb1bors-1518/+1
nll part 5 Next round of changes from the nll-master branch. Extensions: - we now propagate ty-region-outlives constraints out of closures and into their creator when necessary - we fix a few ICEs that can occur by doing liveness analysis (and the resulting normalization) during type-checking - we handle the implicit region bound that assumes that each type `T` outlives the fn body - we handle normalization of inputs/outputs in fn signatures Not included in this PR (will come next): - handling `impl Trait` - tracking causal information - extended errors r? @arielb1
2017-12-19Split PlaceContext::Store into Store & AsmOutputScott McMurray-0/+2
Outputs in InlineAsm can be read-write, so splitting it out is useful for things like Store-Store folding, as it cannot be done for a Store-AsmOutput. This PR is intended to make no changes, just be the mechanical split of the enum. Future changes can use the split, like a MIR pass I'm working on and perhaps two-phase borrows.
2017-12-18Tweak "unecessary unsafe block" error spansEsteban Küber-5/+6
2017-12-15move `type_check` out of `transform` and into the `nll` moduleNiko Matsakis-1518/+1
2017-12-15Auto merge of #46537 - pnkfelix:two-phase-borrows, r=arielb1bors-17/+17
[MIR-borrowck] Two phase borrows This adds limited support for two-phase borrows as described in http://smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ The support is off by default; you opt into it via the flag `-Z two-phase-borrows` I have written "*limited* support" above because there are simple variants of the simple `v.push(v.len())` example that one would think should work but currently do not, such as the one documented in the test compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs (To be clear, that test is not describing something that is unsound. It is just providing an explicit example of a limitation in the implementation given in this PR. I have ideas on how to fix, but I want to land the work that is in this PR first, so that I can stop repeatedly rebasing this branch.)
2017-12-13add FIXME related to constant well-formednessNiko Matsakis-0/+8
2017-12-13normalize fn sig as part of reificationNiko Matsakis-58/+86
2017-12-13Mir typeck Cast for Unsize valueSantiago Pastorino-1/+10
2017-12-13Mir typeck Cast for ClosureFnPtr valueSantiago Pastorino-3/+15
2017-12-13Mir typeck Cast for UnsafeFnPtr valueSantiago Pastorino-2/+8
2017-12-13Mir typeck Cast for ReifyFnPtr valueSantiago Pastorino-1/+18
2017-12-13Restructure a bit check_aggregate_rvalue codeSantiago Pastorino-35/+35
2017-12-13Add more debug logsSantiago Pastorino-0/+12
2017-12-13Check functions predicatesSantiago Pastorino-2/+42
2017-12-13Check Aggregate predicatesSantiago Pastorino-0/+27
2017-12-13Check NullaryOp RvalueSantiago Pastorino-2/+10
2017-12-13Check Repeat RvalueSantiago Pastorino-3/+50
2017-12-13Revised graphviz rendering API to avoid requiring borrowed state.Felix S. Klock II-17/+17
Made `do_dataflow` and related API `pub(crate)`.
2017-12-07mir-borrowck returns closure requirements, mir-typeck enforcesNiko Matsakis-2/+34
2017-12-07renumber types in `ty::Const` and relate them to `mir::Constant`Niko Matsakis-0/+47
2017-12-07rustc_mir: promote references of statics from other statics.Eduard-Mihai Burtescu-7/+16
2017-12-04Auto merge of #46319 - nikomatsakis:nll-master-to-rust-master-2, r=pnkfelixbors-1342/+78
NLL: improve inference with flow results, represent regions with bitsets, and more This PR begins with a number of edits to the NLL code and then includes a large number of smaller refactorings (these refactorings ought not to change behavior). There are a lot of commits here, but each is individually simple. The goal is to land everything up to but not including the changes to how we handle closures, which are conceptually more complex. The NLL specific changes are as follows (in order of appearance): **Modify the region inferencer's approach to free regions.** Previously, for each free region (lifetime parameter) `'a`, it would compute the set of other free regions that `'a` outlives (e.g., if we have `where 'a: 'b`, then this set would be `{'a, 'b}`). Then it would mark those free regions as "constants" and report an error if inference tried to extend `'a` to include any other region (e.g., `'c`) that is not in that outlives set. In this way, the value of `'a` would never grow beyond the maximum that could type check. The new approach is to allow `'a` to grow larger. Then, after the fact, we check over the value of `'a` and see what other free regions it is required to outlive, and we check that those outlives relationships are justified by the where clauses in scope etc. **Modify constraint generation to consider maybe-init.** When we have a "drop-live" variable `x` (i.e., a variable that will be dropped but will not be otherwise used), we now consider whether `x` is "maybe initialized" at that point. If not, then we know the drop is a no-op, and we can allow its regions to be dead. Due to limitations in the fragment code, this currently only works at the level of entire variables. **Change representation of regions to use a `BitMatrix`.** We used to use a `BTreeSet`, which was rather silly. We now use a MxN matrix of bits, where `M` is the number of variables and `N` is the number of possible elements in each set (size of the CFG + number of free regions). The remaining commits (starting from extract the `implied_bounds` code into a helper function ") are all "no-op" refactorings, I believe. ~~One concern I have is with the commit "with -Zverbose, print all details of closure substs"; this commit seems to include some "internal" stuff in the mir-dump files, such as internal interner numbers, that I fear may vary by platform. Annoying. I guess we will see.~~ (I removed this commit.) As for reviewer, @arielb1 has been reviewing the PRs, and they are certainly welcome to review this one too. But I figured it'd maybe be good to have more people taking a look and being familiar with this code, so I'll "nominate" @pnkfelix . r? @pnkfelix
2017-12-04type_check.rs: rustfmtNiko Matsakis-29/+23
2017-12-04remove unused span from `eq_types` (and rustfmt slightly)Niko Matsakis-12/+3
2017-12-04break type-checking of aggregate-kind out into helper functionNiko Matsakis-45/+52
2017-12-04make `no_late_bound_regions` a method on `Binder<T>`Niko Matsakis-1/+1