Commit graph

70549 commits

Author SHA1 Message Date
bors
a4fa23a5bb Auto merge of #46305 - irinagpopa:backstory, r=alexcrichton,eddyb
Move rustc_back modules where they belong.
2017-12-05 00:21:59 +00:00
bors
cd8a352995 Auto merge of #46427 - michaelwoerister:transitive-svh, r=nikomatsakis
incr.comp.: Incorporate the stable commandline arg hash and SVHs of upstream crates into the SVH.

So far the SVH detected changes in the HIR, which is already very sensitive, but in order for `eval_always` queries to also be sensitive to changes in upstream crates, the SVH also needs to capture changes there.

This PR fixes [rust-icci/crossbeam](https://travis-ci.org/rust-icci/crossbeam/builds/308936448), but I have not yet been able to come up with a minimal regression test.

r? @nikomatsakis
2017-12-04 21:46:15 +00:00
bors
8503b3ff82 Auto merge of #46319 - nikomatsakis:nll-master-to-rust-master-2, r=pnkfelix
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-04 19:07:52 +00:00
Niko Matsakis
a6adc74e87 adopt longer and shorter rather than fr and outlived_fr 2017-12-04 11:30:39 -05:00
Niko Matsakis
ab2bc9f073 outlives/env: fix comment, say must and not should 2017-12-04 11:30:38 -05:00
bors
226656ff72 Auto merge of #46463 - nak3:fix-invalid-docs-path, r=kennytm
Fix invalid docs path for compiler plugins

The path to the docs `src/doc/guide-plugin.md` moved to
`src/doc/unstable-book/src/language-features/plugin.md`.

This patch updates it in the comment of WARNING message of the test
code.
2017-12-04 16:29:28 +00:00
Irina-Gabriela Popa
2c175df013 rustc_back: replace tempdir with crates.io version. 2017-12-04 18:25:31 +02:00
Irina-Gabriela Popa
dda924ab6a rustc_back: move dynamic_lib to rustc_metadata. 2017-12-04 18:25:29 +02:00
Irina-Gabriela Popa
d6f70359dc rustc_back: remove slice module in favor of std::slice::from_ref. 2017-12-04 18:25:06 +02:00
Niko Matsakis
271616088f transtive_relation: fix typo in comment for parents 2017-12-04 10:46:35 -05:00
Niko Matsakis
7409ffd17e outlives/env: Fix comment that lost surrounding context. 2017-12-04 10:42:46 -05:00
Niko Matsakis
a3935961f0 region_infer: Fix typo in comment 2017-12-04 10:36:54 -05:00
Niko Matsakis
14480b401a free_region_map: Fix typo in comment: r_a <= r_b 2017-12-04 10:36:38 -05:00
Niko Matsakis
c1708abb07 type_check.rs: rustfmt 2017-12-04 09:14:39 -05:00
Niko Matsakis
506e80c899 remove unused span from eq_types (and rustfmt slightly) 2017-12-04 09:14:39 -05:00
Niko Matsakis
18cc0f9f37 document closure_base_def_id 2017-12-04 09:14:38 -05:00
Niko Matsakis
2e63bb3419 fix debruijn account in for_each_free_region 2017-12-04 09:14:38 -05:00
Niko Matsakis
243bf3f718 rename "free region" to "universally quantified region"
This has been bugging me. All the regions appear free in the source;
the real difference is that some of them are universally quantified
(those in the function signature) and some are existentially
quantified (those for which we are inferring values).
2017-12-04 09:14:38 -05:00
Niko Matsakis
fa813f74a2 introduce closure_env_ty helper to compute ty of closure env arg
Previously the code was somewhat duplicated.
2017-12-04 09:14:38 -05:00
Niko Matsakis
7f247add41 move liberate_late_bound_regions to a method on the tcx
No reason for it to live on `Inherited`.
2017-12-04 09:14:37 -05:00
Niko Matsakis
e9067bd5cc MIR dump: restructure pretty to be more extensible by other code 2017-12-04 09:14:37 -05:00
Niko Matsakis
49d2274cfe constraint_generation: create liveness constraints more thoroughly
We now visit just the stuff in the CFG, and we add liveness
constraints for all the random types, regions etc that appear within
rvalues and statements.
2017-12-04 09:14:35 -05:00
Niko Matsakis
4de7336862 extend TransitiveRelation with parents function 2017-12-04 08:51:14 -05:00
Niko Matsakis
663e7a4f08 promote region_infer into its own module 2017-12-04 08:51:13 -05:00
Niko Matsakis
fb4b06ab3b rename greater_than to reachable_from 2017-12-04 08:51:13 -05:00
Niko Matsakis
45f6027196 break type-checking of aggregate-kind out into helper function 2017-12-04 08:51:13 -05:00
Niko Matsakis
31d61f1f86 rename implied_bounds module to bounds 2017-12-04 08:51:13 -05:00
Niko Matsakis
c45307fae1 extract the code to create OutlivesBounds into its own module
Now it can be reused by the NLL code.
2017-12-04 08:51:13 -05:00
Niko Matsakis
1f33145ae9 make no_late_bound_regions a method on Binder<T> 2017-12-04 08:51:12 -05:00
Niko Matsakis
5562663a6c make resolve_regions_and_report_errors take an OutlivesEnv
This revealed some shortcomings, one of which is fixed. Fixes #45937.
2017-12-04 08:51:12 -05:00
Niko Matsakis
abd7d88139 move free_regions_map into infer::outlives 2017-12-04 08:51:12 -05:00
Niko Matsakis
aa51603870 extract the implied_bounds code into a helper function 2017-12-04 08:51:12 -05:00
Zack M. Davis
22b31758ec region_infer: BitMatrix representation of region values
This should be more efficient than allocating two BTreeSets for every
region variable?—as it is written in #45670.
2017-12-04 08:51:11 -05:00
Paul Daniel Faria
a9cb25b23a inform constraint generation using maybe-init
In particular, if we see a variable is DROP-LIVE, but it is not
MAYBE-INIT, then we can ignore the drop. This leavess attempt to use
more complex refinements of the idea (e.g., for subpaths or subfields)
to future work.
2017-12-04 08:51:11 -05:00
Niko Matsakis
08c8d7e919 borrow_check.rs: rustfmt 2017-12-04 08:51:10 -05:00
Kenjiro Nakayama
3e46fa2c9a Fix invalid docs path for compiler plugins 2017-12-04 22:39:39 +09:00
Niko Matsakis
a96b0cf86d replace constant regions with a post-inference check
Rather than declaring some region variables to be constant, and
reporting errors when they would have to change, we instead populate
each free region X with a minimal set of points (the CFG plus end(X)),
and then we let inference do its thing. This may add other `end(Y)`
points into X; we can then check after the fact that indeed `X: Y`
holds.

This requires a bit of "blame" detection to find where the bad
constraint came from: we are currently using a pretty dumb
algorithm. Good place for later expansion.
2017-12-04 08:25:21 -05:00
Niko Matsakis
932452ecc7 separate out the liveness constraints from the final value
It will be useful later for diagnostics to be able to remember where
things were live.
2017-12-04 08:25:20 -05:00
bors
1a8282a9b4 Auto merge of #46486 - scottmcm:i128-target-option, r=nagisa
Add an i128_lowering flag in TargetOptions

Not actually enabled by default anywhere yet.

r? @nagisa

cc #45676 @est31
2017-12-04 12:38:27 +00:00
bors
c16f480fa6 Auto merge of #46485 - khuey:cursor-read_exact, r=Manishearth
Add a specialization of read_exact for Cursor.

The read_exact implementation for &[u8] is optimized and usually allows LLVM to reduce a read_exact call for small numbers of bytes to a bounds check and a register load instead of a generic memcpy.  On a workload I have that decompresses, deserializes (via bincode), and processes some data, this leads to a 40% speedup by essentially eliminating the deserialization overhead entirely.
2017-12-04 10:02:48 +00:00
Scott McMurray
1bc402fd80 Add an i128_lowering flag in TargetOptions
Not actually enabled by default anywhere yet.
2017-12-03 21:53:48 -08:00
Kyle Huey
02c1862fb5 Add a specialization of read_exact for Cursor.
The read_exact implementation for &[u8] is optimized and usually allows LLVM to reduce a read_exact call for small numbers of bytes to a bounds check and a register load instead of a generic memcpy.  On a workload I have that decompresses, deserializes (via bincode), and processes some data, this leads to a 40% speedup by essentially eliminating the deserialization overhead entirely.
2017-12-03 20:45:12 -08:00
bors
fdfbcf85d5 Auto merge of #46482 - frewsxcv:rollup, r=frewsxcv
Rollup of 8 pull requests

- Successful merges: #45957, #46260, #46432, #46442, #46454, #46462, #46465, #46473
- Failed merges:
2017-12-03 23:02:40 +00:00
Corey Farwell
48d38555e5 Rollup merge of #46473 - frewsxcv:frewsxcv-param-name, r=TimNN
Consistent parameter name for numeric ‘checked’ operations.

Some checked operations use `rhs` as a parameter name, and some use
`other`. For the sake of consistency, unify everything under the `rhs`
name.

Fixes https://github.com/rust-lang/rust/issues/46308.
2017-12-03 17:43:50 -05:00
Corey Farwell
909a8de953 Rollup merge of #46465 - nak3:fix-invalid-link, r=kennytm
Fix invalid link to lint_plugin_test.rs

The path to `lint_plugin_test.rs` was moved to `src/test/ui-fulldeps/`
from `src/test/run-pass-fulldeps/` in 38ef85696d

This patch updates it in the docs.
2017-12-03 17:43:49 -05:00
Corey Farwell
94dbbacd45 Rollup merge of #46462 - sinkuu:copyprop_reg2, r=arielb1
Fix CopyPropagation regression (2)

Remaining part of MIR copyprop regression by (I think) #45380, which I missed in #45753.

```rust
fn foo(mut x: i32) -> i32 {
    let y = x;
    x = 123; // `x` is assigned only once in MIR, but cannot be propagated to `y`
    y
}
```

So any assignment to an argument cannot be propagated.
2017-12-03 17:43:48 -05:00
Corey Farwell
7c4f74d16e Rollup merge of #46454 - GuillaumeGomez:search-overlap, r=QuietMisdreavus
Fix search results overlap

Fixes #46434.

r? @QuietMisdreavus
2017-12-03 17:43:47 -05:00
Corey Farwell
697c5ba0d9 Rollup merge of #46442 - est31:master, r=alexcrichton
Remove an unstable and dead compiler flag

The last use has been removed by commit fb9ca16b3b .
2017-12-03 17:43:46 -05:00
Corey Farwell
fcf1e73647 Rollup merge of #46432 - tromey:doc-fix-46307, r=estebank
Fix documentation for DecodeUtf16Error

Fixes #46307
2017-12-03 17:43:45 -05:00
Corey Farwell
b9ffbff959 Rollup merge of #46260 - ExpHP:builtin-macro-doc-sync, r=steveklabnik
Make doc stubs for builtin macros reflect existing support for trailing commas

This modifies the `macro_rules!` stubs in `std` for some of the compiler builtin macros in order to better reflect their currently supported grammar.  To my understanding these stubs have no impact on compiler output whatsoever, and only exist so that they may appear in the documentation.

P.S. It is in fact true that `env!` supports trailing commas while `option_env!` currently does not.  (I have another issue for this)

I don't imagine there's any way to automatically test these stubs, but I did *informally* test the new definitions on the playpen to see that they accept the desired invocations, as well as inspect the updated doc output.
2017-12-03 17:43:44 -05:00