Commit Graph

69815 Commits

Author SHA1 Message Date
bors
b32267f2c1 Auto merge of #45595 - scottmcm:iter-try-fold, r=dtolnay
Short-circuiting internal iteration with Iterator::try_fold & try_rfold

These are the core methods in terms of which the other methods (`fold`, `all`, `any`, `find`, `position`, `nth`, ...) can be implemented, allowing Iterator implementors to get the full goodness of internal iteration by only overriding one method (per direction).

Based off the `Try` trait, so works with both `Result` and `Option` (🎉 https://github.com/rust-lang/rust/pull/42526).  The `try_fold` rustdoc examples use `Option` and the `try_rfold` ones use `Result`.

AKA continuing in the vein of PRs https://github.com/rust-lang/rust/pull/44682 & https://github.com/rust-lang/rust/pull/44856 for more of `Iterator`.

New bench following the pattern from the latter of those:
```
test iter::bench_take_while_chain_ref_sum          ... bench:   1,130,843 ns/iter (+/- 25,110)
test iter::bench_take_while_chain_sum              ... bench:     362,530 ns/iter (+/- 391)
```

I also ran the benches without the `fold` & `rfold` overrides to test their new default impls, with basically no change.  I left them there, though, to take advantage of existing overrides and because `AlwaysOk` has some sub-optimality due to https://github.com/rust-lang/rust/issues/43278 (which 45225 should fix).

If you're wondering why there are three type parameters, see issue https://github.com/rust-lang/rust/issues/45462

Thanks for @bluss for the [original IRLO thread](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434) and the rfold PR and to @cuviper for adding so many folds, [encouraging me](https://github.com/rust-lang/rust/pull/45379#issuecomment-339424670) to make this PR, and finding a catastrophic bug in a pre-review.
2017-11-17 07:43:08 +00:00
bors
3bcb00dbc2 Auto merge of #45991 - gnzlbg:fix_i586, r=alexcrichton
fix linking error on i586

Try to fix this linking error on i586 in cross:

https://travis-ci.org/japaric/cross/builds/302095949#L8670

The problem is that `std` is built in Ubuntu 16.04 and `cross` uses a linker from 12.04.

Currently this fix solves the problem for `i686-musl`  making it "supercompatible", this PR applies the fix to `i586` as well.

The cross PR is here: https://github.com/japaric/cross/pull/157
2017-11-17 05:18:45 +00:00
bors
8fbb46c4a1 Auto merge of #45980 - Keruspe:master, r=alexcrichton
rustbuild: Install rustfmt as part of extended build

Now that we distribute it, this allows `./x.py install` to install it too
2017-11-17 02:34:08 +00:00
bors
d59f66d9b8 Auto merge of #45897 - tromey:trait-object-debug, r=michaelwoerister
Trait object debug

This enables better debugging of trait objects.  See the individual commits for explanations.  This required an LLVM bump.
2017-11-16 23:28:00 +00:00
bors
d0f8e2913a Auto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1
integrate MIR type-checker with NLL inference

This branch refactors NLL type inference so that it uses the MIR type-checker to gather constraints. Along the way, it also refactors how region constraints are gathered in the normal inference context mildly. The new setup is like this:

- What used to be `region_inference` is split into two parts:
    - `region_constraints`, which just collects up sets of constraints
    - `lexical_region_resolve`, which does the iterative, lexical region resolution
- When `resolve_regions_and_report_errors` is invoked, the inference engine converts the constraints into final values.
- In the MIR type checker, however, we do not invoke this method, but instead periodically take the region constraints and package them up for the NLL solver to use later.
    - This allows us to track when and where those constraints were incurred.
    - We also remove the central fulfillment context from the MIR type checker, instead instantiating new fulfillment contexts at each point. This allows us to capture the set of obligations that occurred at a particular point, and also to ensure that if the same obligation arises at two points, we will enforce the region constraints at both locations.
- The MIR type checker is also enhanced to instantiate late-bound-regions with fresh variables and handle a few other corner cases that arose.
- I also extracted some of the 'outlives' logic from the regionck, which will be needed later (see future work) to handle the type-outlives relationships.

One concern I have with this branch: since the MIR type checker is used even without the `-Znll` switch, I'm not sure if it will impact performance. One simple fix here would be to only enable the MIR type-checker if debug-assertions are enabled, since it just serves to validate the MIR. Longer term I hope to address this by improving the interface to the trait solver to be more query-based (ongoing work).

There is plenty of future work left. Here are two things that leap to mind:

- **Type-region outlives.** Currently, the NLL solver will ICE if it is required to handle a constraint like `T: 'a`. Fixing this will require a small amount of refactoring to extract the implied bounds code. I plan to follow a file-up bug on this (hopefully with mentoring instructions).
- **Testing.** It's a good idea to enumerate some of the tricky scenarios that need testing, but I think it'd be nice to try and parallelize some of the actual test writing (and resulting bug fixing):
    - Same obligation occurring at two points.
    - Well-formedness and trait obligations of various kinds (which are not all processed by the current MIR type-checker).
    - More tests for how subtyping and region inferencing interact.
    - More suggestions welcome!

r? @arielb1
2017-11-16 20:56:26 +00:00
bors
58d8761ab3 Auto merge of #46029 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests

- Successful merges: #45951, #45973, #45984, #45993, #46005, #46010
- Failed merges:
2017-11-16 18:24:17 +00:00
bors
481b42b507 Auto merge of #45528 - alexcrichton:avx512, r=arielb1
rustc: Add some more compatibility with AVX-512

* Increase the maximum vector size in the ABI calculations to ensure that
  AVX-512 operands are immediates.
* Add a few more `target_feature` matchings for AVX-512 features
2017-11-16 15:32:13 +00:00
bors
c81f201d48 Auto merge of #46028 - oli-obk:clippy, r=kennytm
Reenable Clippy

r? @kennytm
2017-11-16 10:59:39 +00:00
Niko Matsakis
8c109f5681 infer/outlives/obligations.rs: wrap some long lines 2017-11-16 05:58:16 -05:00
Niko Matsakis
9e29662a98 obligations.rs: rustfmt 2017-11-16 05:58:16 -05:00
Niko Matsakis
a94d2a6b88 Nit: fix typo 2017-11-16 05:58:13 -05:00
Niko Matsakis
a73d620323 Nit: reset more state after take_and_reset_data 2017-11-16 05:58:11 -05:00
Niko Matsakis
11c84c6625 Nit: improve comment to explain why we wait until regionck 2017-11-16 05:58:00 -05:00
Niko Matsakis
15739b820f Nit: rework region obligations to a snapshotted vector 2017-11-16 05:57:56 -05:00
Niko Matsakis
f72259101f Nit: fix wording in README 2017-11-16 05:57:51 -05:00
Niko Matsakis
5a8c1eb61a leak the affects of closures on the free-region-map, like we used to
This restores the behavior of regionck with respect to the
free-region-map: that is, it collects all the relations from the fn
and its closures. This feels a bit fishy but it's the behavior we've
had for some time, and it will go away with NLL, so seems best to just
keep it.
2017-11-16 05:57:51 -05:00
Niko Matsakis
c7c2603e2c factor out free_region_binding_scope helper 2017-11-16 05:57:51 -05:00
Niko Matsakis
8cea0539d1 fix mir-opt NLL tests -- variable '_#0r is now 'static 2017-11-16 05:57:50 -05:00
Niko Matsakis
9da54c1ac8 add FIXME for converting RegionVid to use newtype_index! 2017-11-16 05:57:50 -05:00
Niko Matsakis
267574c8df convert TODO in traits into a FIXME 2017-11-16 05:57:50 -05:00
Niko Matsakis
013f88b9fb infer/outlives: add license 2017-11-16 05:57:47 -05:00
Niko Matsakis
b383ab79c9 update READMEs to describe the new situation
The inference README, in particular, was VERY out of date!
2017-11-16 05:57:47 -05:00
Niko Matsakis
4b743da596 integrate NLL with MIR type-checker 2017-11-16 05:57:47 -05:00
Niko Matsakis
d9e841e756 region_infer: improved debug logging 2017-11-16 05:57:47 -05:00
Niko Matsakis
32f964cc98 renumber: debug logs, use visit_region rather than visit_rvalue 2017-11-16 05:57:47 -05:00
Niko Matsakis
12534e9159 renumber: handle ReturnTy better 2017-11-16 05:57:47 -05:00
Niko Matsakis
5592bb7c33 MIR-dump: print return type from local_decls for _0
We've kind of got the same information twice in the MIR, between the
return-type field and the local-decls. Seems un-great.
2017-11-16 05:57:46 -05:00
Niko Matsakis
8d3219ed5e erase regions in MIR borrowck when checking if type moves by default 2017-11-16 05:57:46 -05:00
Niko Matsakis
ef392bc11b simplify lifetime annotations for MirBorrowckCtxt 2017-11-16 05:57:46 -05:00
Niko Matsakis
51ce1f9493 formalize giving ownership of region vars to region inf. context 2017-11-16 05:57:46 -05:00
Niko Matsakis
109c9a79ed infer: extract total number of region variables from infcx
We are heading towards deeper integration with the region inference
system in infcx; in particular, prior to the creation of the
`RegionInferenceContext`, it will be the "owner" of the set of region
variables.
2017-11-16 05:57:46 -05:00
Niko Matsakis
a87d1bbb93 infer: give access to region variable origins 2017-11-16 05:57:45 -05:00
Niko Matsakis
09b44bbe77 IndexVec: add '_ to make clear where borrowing is happening 2017-11-16 05:57:45 -05:00
Niko Matsakis
72675d82d7 replace RegionIndex with RegionVid (which now impls Idx) 2017-11-16 05:57:45 -05:00
Niko Matsakis
89c1b6009b replace usize with RegionIndex in indices map 2017-11-16 05:57:45 -05:00
Niko Matsakis
ad93b695d1 MIR typeck: refactor to track region constraints 2017-11-16 05:57:45 -05:00
Niko Matsakis
37945fe3e8 MIR typeck: rustfmt 2017-11-16 05:57:44 -05:00
Niko Matsakis
034018cd90 rustfmt lexical_region_resolve 2017-11-16 05:57:44 -05:00
Niko Matsakis
1430a600de add method take_and_reset_region_constraints to InferCtxt 2017-11-16 05:57:44 -05:00
Niko Matsakis
1efcf1a115 split the var_origins from the RegionConstraintData 2017-11-16 05:57:44 -05:00
Niko Matsakis
a8daa37df6 region_constraints: only push givens into undo-log if in a snapshot 2017-11-16 05:57:44 -05:00
Niko Matsakis
524e23ae2e make RegionVid implement Idx and use IndexVec 2017-11-16 05:57:44 -05:00
Niko Matsakis
bea6b94273 fix error messages relating to removing lint for E0276 2017-11-16 05:57:44 -05:00
Niko Matsakis
f6037f2816 separate the Collector from the Data it is collecting 2017-11-16 05:57:43 -05:00
Niko Matsakis
adf1519941 make the region_constraints field an Option
This way, we can `take()` ownership of it when we are going to resolve regions.
2017-11-16 05:57:43 -05:00
Niko Matsakis
326ec52eac rename RegionVarBindings to RegionConstraintCollector 2017-11-16 05:57:43 -05:00
Niko Matsakis
48d8f7210b infer: rename region_vars field to region_constraints 2017-11-16 05:57:43 -05:00
Niko Matsakis
23abd85138 rename region_inference module to region_constraints 2017-11-16 05:57:43 -05:00
Niko Matsakis
cff191d444 move refcells out from RegionVarBindings and up into InferCtxt 2017-11-16 05:57:42 -05:00
Niko Matsakis
63d658d87c extract the tcx out from RegionVarBindings 2017-11-16 05:57:42 -05:00