Commit Graph

75435 Commits

Author SHA1 Message Date
bors
8c4ff22a2d Auto merge of #48411 - nikomatsakis:chalkify-canonical-query-mir, r=eddyb
introduce canonical queries, use for normalization and dropck-outlives

This branch adds in the concept of a **canonicalized trait query** and uses it for three specific operations:

- `infcx.at(cause, param_env).normalize(type_foldable)`
    - normalizes all associated types in `type_foldable`
- `tcx.normalize_erasing_regions(param_env, type_foldable)`
    - like normalize, but erases regions first and in the result; this leads to better caching
- `infcx.at(cause, param_env).dropck_outlives(ty)`
    - produces the set of types that must be live when a value of type `ty` is dropped
    - used from dropck but also NLL outlives

This is a kind of "first step" towards a more Chalk-ified approach. It leads to a **big** speedup for NLL, which is basically dominated by the dropck-outlives computation. Here are some timing measurements for the `syn` crate (pre-branch measurements coming soon):

| Commit | NLL disabled | NLL enabled |
| ------- | --- | --- |
| Before my branch | 5.43s | 8.99s |
| After my branch | 5.36s | 7.25s |

(Note that NLL enabled still does *all the work* that NLL disabled does, so this is not really a way to compare the performance of NLL versus the AST-based borrow checker directly.) Since this affects all codepaths, I'd like to do a full perf run before we land anything.

Also, this is not the "final point" for canonicalization etc. I think canonicalization can be made substantially faster, for one thing. But it seems like a reasonable starting point for a branch that's gotten a bit larger than I would have liked.

**Commit convention:** First of all, this entire branch ought to be a "pure refactoring", I believe, not changing anything about external behavior. Second, I've tagged the most important commits with `[VIC]` (very important commit), so you can scan for those. =)

r? @eddyb
2018-03-13 15:24:45 +00:00
Niko Matsakis
17c4103f3f add "text" sections for things that seem likely to be a problem 2018-03-13 11:22:08 -04:00
Niko Matsakis
29dc902beb remove dead code 2018-03-13 11:22:08 -04:00
Niko Matsakis
d326738586 replace inline docs with references to rustc-guide 2018-03-13 11:22:08 -04:00
Niko Matsakis
fc04c41a40 add a debug assertion that only outlives-oblig. result from norm. 2018-03-13 11:22:08 -04:00
Niko Matsakis
6288faa3a3 trans_apply_param_substs => subst_and_normalize_erasing_regions
Consolidate `trans_apply_param_substs` and
`trans_apply_param_substs_env`. Also remove `trans_impl_self_ty`
2018-03-13 11:22:08 -04:00
Niko Matsakis
0d17f95465 short-circuit work when instantiating query responses
Also, perform substitution in smaller parts.
2018-03-13 11:22:08 -04:00
Niko Matsakis
03c5428be3 short-circuit dropck_outlives for simple cases 2018-03-13 11:22:07 -04:00
Niko Matsakis
1e4e632ad8 add regression tests for various MIR bugs that get fixed
Fixes #31567
Fixes #47470
Fixes #48132
Fixes #48179
2018-03-13 11:22:07 -04:00
Niko Matsakis
36e5092dfa add some debug output 2018-03-13 11:22:07 -04:00
Niko Matsakis
0a2ac85e3f move drain_fulfillment_cx_or_panic to be private to traits::trans 2018-03-13 11:22:07 -04:00
Niko Matsakis
e4728e494e transition various normalization functions to the new methods
In particular:

- `fully_normalize_monormophic_ty` => `normalize_erasing_regions`
- `normalize_associated_type_in_env` => `normalize_erasing_regions`
- `fully_normalize_associated_types_in` => `normalize_erasing_regions`
- `erase_late_bound_regions_and_normalize` => `normalize_erasing_late_bound_regions`
2018-03-13 11:22:07 -04:00
Niko Matsakis
211d9ad7db introduce tcx.normalize_erasing_regions(..) operaton [VIC] 2018-03-13 11:22:07 -04:00
Niko Matsakis
ca87d24467 introduce infcx.at(..).dropck_outlives(..) operaton [VIC]
Backed by a canonicalized query. This computes all the types/regions that need
to be live when the destructor runs (i.e., that the dtor may access).
2018-03-13 11:22:07 -04:00
Niko Matsakis
3a50b41da4 introduce infcx.at(..).normalize(..) operation [VIC]
It is backed by the new `normalize_projection_ty` query, which uses
canonicalization.
2018-03-13 11:22:05 -04:00
Niko Matsakis
8c024fdafb in Foo(X) dep-nodes, allow X to be a ty not a tt
Before, the identifier `X` was also used when generating a pattern
to match against the dep-node. So `Foo(DefId)` would generate a match
pattern like:

    match foo {
        Foo(DefId) => ...
    }

This does not scale to more general types like `&'tcx
Ty<'tcx>`. Therefore, we now require *exactly one* argument (the macro
was internally tupling anyway, and no actual nodes use more than one
argument), and then we can generate a fixed pattern like:

    match foo {
        Foo(arg) => ...
    }

Huzzah. (Also, hygiene is nice.)
2018-03-13 11:21:31 -04:00
Niko Matsakis
993c1488cc add canonicalize method to InferCtxt [VIC] 2018-03-13 11:21:31 -04:00
Niko Matsakis
80b4c45ee4 change ParamEnv::and to sometimes keep the environment [VIC]
In general, we've been moving towards a semantics where you can have
contradictory where-clauses, and we try to honor them.  There are
already existing run-pass tests where we take that philosophy as
well (e.g., `compile-fail/issue-36839.rs`). The current behavior of
`and`, where it strips the environment, breaks that code.
2018-03-13 11:21:31 -04:00
Niko Matsakis
64d4ed300b move ParamEnv methods from ty/util to ty/mod 2018-03-13 11:21:30 -04:00
Niko Matsakis
6d0f9319df refactor ParamEnv::empty(Reveal) into two distinct methods
- `ParamEnv::empty()` -- does not reveal all, good for typeck
- `ParamEnv::reveal_all()` -- does, good for trans
- `param_env.with_reveal_all()` -- converts an existing parameter environment
2018-03-13 11:21:30 -04:00
Niko Matsakis
1d377d10a1 add handy helper for Cell<usize>, used for perf stats 2018-03-13 11:21:30 -04:00
Niko Matsakis
652b3b71f3 random reformatting 2018-03-13 11:21:30 -04:00
Niko Matsakis
0037cca2f7 comment the purpose of TransNormalize 2018-03-13 11:21:30 -04:00
Niko Matsakis
d0aff859d5 make regions "traceable" so you can do infcx.at(..).eq(r1, r2) 2018-03-13 11:21:30 -04:00
Niko Matsakis
10ae216b75 fix typo in comment 2018-03-13 11:21:30 -04:00
Niko Matsakis
5ddcd09b53 add TypeRelation and Lift impls for Kind 2018-03-13 11:21:29 -04:00
Niko Matsakis
23837c1901 improve TypeFoldable/Lift macros and make a bunch of stuff use them
Improvements:

- Use Clone not Copy for the "simple cases"
- Separate TypeFoldable and Lift for the "simple cases"
- Support generics type parameters
- Support named fields in enum variants
- etc
2018-03-13 11:21:29 -04:00
Niko Matsakis
f873c1e2db require Lifted types to outlive 'tcx 2018-03-13 11:21:29 -04:00
bors
e65547d4fa Auto merge of #48958 - alexcrichton:update-rls-rustc, r=sfackler
Update the rls-rustc package

Should hopefully fix compiling the rls!
2018-03-13 09:18:12 +00:00
bors
c7cbe14264 Auto merge of #48955 - kennytm:rollup, r=kennytm
Rollup of 13 pull requests

- Successful merges: #48201, #48705, #48725, #48824, #48877, #48880, #48887, #48928, #48934, #48480, #48631, #48898, #48954
- Failed merges:
2018-03-12 23:47:10 +00:00
kennytm
99d0ac0b65
Rollup merge of #48954 - GuillaumeGomez:missing-links-fmt, r=QuietMisdreavus
Add missing links
2018-03-13 05:02:03 +08:00
kennytm
e30d89d7a5
Rollup merge of #48898 - GuillaumeGomez:remove-empty-section, r=QuietMisdreavus
Remove auto trait implementation section when empty

Fixes #48882.
2018-03-13 05:01:37 +08:00
kennytm
15d71d3285
Rollup merge of #48631 - focusaurus:remember-collapse-setting, r=QuietMisdreavus
Remember state of top-level collapse toggle widget

This change allows the big top-right expand/collapse toggle to remember its setting across navigation or page reloads. Prior to this change, there was this annoyance:

- browse to some docs
- Click the minus button to collapse them
- browse to other docs (or reload the page)
- Everything is expanded again

The solution is based on storing a simple boolean flag in localStorage. I think it's a good improvement, but it does introduce the following potentially surprising behavior:

- browse to some docs
- click the minus button to collapse them
- click to expand a particular item (not the main top-right big one)
- reload the page, everything is collapsed

Paired with @debugsteven on this.
2018-03-13 05:01:15 +08:00
kennytm
684c6d17c5
Rollup merge of #48480 - jethrogb:patch-5, r=alexcrichton
Clarify interfaction between File::set_len and file cursor
2018-03-13 05:00:26 +08:00
Alex Crichton
9b1c69ec93 Update the rls-rustc package
Should hopefully fix compiling the rls!
2018-03-12 13:02:49 -07:00
Guillaume Gomez
bda5a45793 Add missing links 2018-03-12 20:47:34 +01:00
kennytm
34d9ffec17
Rollup merge of #48934 - Phlosioneer:42453-debug-hygene, r=petrochenkov
Fix hygene issue when deriving Debug

The code for several of the core traits doesn't use hygenic macros.
This isn't a problem, except for the Debug trait, which is the only
one that uses a variable, named "builder".

Variables can't share names with unit structs, so attempting to
[derive(Debug)] on any type while a unit struct with the name
"builder" was in scope would result in an error.

This commit just changes the name of the variable to
"__debug_trait_builder", because I couldn't figure out how to get a
list of all unit structs in-scope from within the derive expansion
function. If someone wants to have a unit struct with
the exact name "__debug_trait_builder", they'll just have to do it
without a [derive(Debug)].

I also checked the implementations of the other built-in derives to
ensure they didn't declare any variables.
2018-03-13 00:54:33 +08:00
kennytm
14574db793
Rollup merge of #48928 - zackmdavis:span_suggestion_field_day, r=estebank
in which some labels and notes are upgraded to structured suggestions

(Meanwhile, a couple of parse-fail tests are moved to UI tests so that
the reader can see the new output, and an existing UI test is given a
more evocative name.)

r? @estebank
2018-03-13 00:54:32 +08:00
kennytm
2d13cc4d79
Rollup merge of #48887 - alexcrichton:update-stdsimd, r=kennytm
Update stdsimd module

Pulls in a redesigned `std::simd` module as well as a replacement for the
`is_target_feature_detected!` macro
2018-03-13 00:54:31 +08:00
kennytm
3d2db9bba8
Rollup merge of #48880 - petrochenkov:badstderr, r=kennytm
tidy: Add a check for stray `.stderr` and `.stdout` files in UI test directories
2018-03-13 00:54:30 +08:00
kennytm
5d0918908a
Rollup merge of #48877 - GuillaumeGomez:vec-missing-links, r=QuietMisdreavus
Add missing urls

r? @QuietMisdreavus
2018-03-13 00:54:28 +08:00
kennytm
e22a994a47
Rollup merge of #48824 - davidalber:update-conduct, r=steveklabnik
Propagating upstream code of conduct changes

[This repository's code of conduct](https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md) is out of sync with the [rust-www code of conduct](https://github.com/rust-lang/rust-www/blob/master/en-US/conduct.md) due changes from rust-lang/rust-www#1062. This PR propagates those changes and brings the files back into sync.

r? @steveklabnik
2018-03-13 00:54:27 +08:00
kennytm
f84cab421b
Rollup merge of #48725 - humenda:master, r=nikomatsakis
Update L4Re target specification

Due to the dynamically generated linker arguments of the L4Re build system, it is not a good idea to hard-code them in Rust. This PR undoes this step. It also adds an empty implementation to retrieve the number of CPUs.
2018-03-13 00:54:26 +08:00
kennytm
7bd8f6ea31
Rollup merge of #48705 - klnusbaum:update_rfc_process, r=aturon
Update Feature Request instructions

As noted in #48393 the contribution instructions for submitting a Feature Request are a little hasty, suggesting that the user immediately create an issue in the RFC repository. For users that want to submit a feature request, let's instead point them directly to the README file for the RFC repository, which contains detailed instructions on how to submit a Feature Request.
2018-03-13 00:54:25 +08:00
kennytm
fdb5181f25
Rollup merge of #48201 - NovemberZulu:master, r=steveklabnik
rephrase UnsafeCell doc

As shown by discussions on users.rust-lang.org [[1]], [[2]], UnsafeCell doc is not totally clear. I tried to made the doc univocal regarding what is allowed and what is not. The edits are based on my understanding following [[1]].

[1]: https://users.rust-lang.org/t/unsafecell-behavior-details/1560
[2]: https://users.rust-lang.org/t/is-there-a-better-way-to-overload-index-indexmut-for-a-rc-refcell/15591/12
2018-03-13 00:54:24 +08:00
bors
883e74645d Auto merge of #48770 - bobtwinkles:two_phase_borrows_rewrite, r=pnkfelix
Two phase borrows rewrite

This definitely needs a careful review. Both @pnkfelix and @nikomatsakis  were involved with the design of this so they're natural choices here. I'm r?'ing @pnkfelix since they wrote the original two-phase borrow implementation. Also ping @KiChjang who expressed interest in working on this. I'm going to leave a few comments below pointing out some of the more dangerous changes I made (i.e. what I would like reviewers to pay special attention too.)

r? @pnkfelix
2018-03-12 12:58:09 +00:00
bors
222b0eb583 Auto merge of #48295 - Keruspe:master, r=alexcrichton
rustbuild: pass datadir to rust-installer

This fixes zsh completion install when $datadir != $prefix/share
2018-03-12 08:11:19 +00:00
bors
4eea3597f2 Auto merge of #48938 - alexcrichton:no-leak-makeflags, r=kennytm
test: Forcibly remove MAKEFLAGS in compiletest

When executing run-make tests we run a risk of leaking the `MAKEFLAGS`
environment variable if `./x.py` itself was called from `make` (aka `make check
-j3` as the OSX bots do). We may then leak accidentally fds into the child
process and trick it into thinking it's got a jobserver!

Hopefully addresses [this] spurious failure

[this]: https://github.com/rust-lang/rust/pull/48295#issuecomment-372134717
2018-03-12 05:28:13 +00:00
bors
178becdd7c Auto merge of #48549 - alexcrichton:update-cargo, r=Mark-Simulacrum
Update Cargo submodule

Hopefully a routine update...
2018-03-11 20:28:34 +00:00
Alex Crichton
9a3128ec1d test: Forcibly remove MAKEFLAGS in compiletest
When executing run-make tests we run a risk of leaking the `MAKEFLAGS`
environment variable if `./x.py` itself was called from `make` (aka `make check
-j3` as the OSX bots do). We may then leak accidentally fds into the child
process and trick it into thinking it's got a jobserver!

Hopefully addresses [this] spurious failure

[this]: https://github.com/rust-lang/rust/pull/48295#issuecomment-372134717
2018-03-11 13:15:46 -07:00