Commit Graph

101125 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
0da94a45e9
Rollup merge of #65710 - ehuss:update-cargo, r=alexcrichton
Update cargo

6 commits in 3a9abe3f065554a7fbc59f440df2baba4a6e47ee..3ba5f27170db10af7a92f2b682e049397197b8fa
2019-10-15 15:55:35 +0000 to 2019-10-22 15:05:18 +0000
- Fix typo in `cargo install --profile` help (rust-lang/cargo#7532)
- Use stricter -Z flag parsing. (rust-lang/cargo#7531)
- Set timestamp on generated files in archive to now (rust-lang/cargo#7523)
- Support rustc's `-Z panic-abort-tests` in Cargo (rust-lang/cargo#7460)
- rustfmt for nightly changes. (rust-lang/cargo#7526)
- Allow --all-features in root of virtual workspace. (rust-lang/cargo#7525)
2019-10-24 20:20:02 +02:00
Mazdak Farrokhzad
9c04bd1b4d
Rollup merge of #65627 - varkor:const-generics-forbid-non-structural_match, r=petrochenkov
Forbid non-`structural_match` types in const generics

Fixes https://github.com/rust-lang/rust/issues/60286.
2019-10-24 20:20:01 +02:00
Mazdak Farrokhzad
cdb7634f0c
Rollup merge of #65625 - petrochenkov:cstore, r=Mark-Simulacrum,Zoxc
Turn crate store into a resolver output

Crate store (`CStore`) is a vector of data (`CrateMetadata`) associated with extern crates loaded during the current compilation session.

All crates are loaded in the resolver when resolving either paths pointing to extern prelude or `extern crate` items. (There are also a couple of crates like panic runtime that are loaded kind of like implicit `extern crate`s, but that also happens in resolve.)

The use of `CStore` from `rustc_plugin` (which is outside of the resolver) was unnecessary because legacy plugins are not added to the crate store and don't use `CrateNum`s.

So, `CStore` can be produced by the resolver instead of being kept in some really global data (`rustc_interface::Compiler`) like now.

As a result of crate store being more "local" we can now remove some locks and `Lrc`s.
2019-10-24 20:19:59 +02:00
Vadim Petrochenkov
94216ce3ad rustc_interface: Remove ExpansionResult and some Steals 2019-10-24 21:12:05 +03:00
Vadim Petrochenkov
9f5a530b84 rustc_metadata: Minimize use of Lrc in crate store
Crate metadatas are still stored as `Lrc<CrateMetadata>` in `CStore` because crate store has to be cloneable due to `Resolver::clone_outputs`.
2019-10-24 20:54:16 +03:00
Vadim Petrochenkov
c5fee33e7a rustc_metadata: Remove RwLock from CStore 2019-10-24 20:54:16 +03:00
Vadim Petrochenkov
3534ca8f49 Turn crate store into a resolver output 2019-10-24 20:54:16 +03:00
Vadim Petrochenkov
5fd796ad06 rustc: Combine resolver outputs into a single struct 2019-10-24 20:51:33 +03:00
Vadim Petrochenkov
fb353f050a resolve: Privatize all resolver fields 2019-10-24 20:51:33 +03:00
Vadim Petrochenkov
222503a354 rustc: Add a convenience alias for dyn MetadataLoader + Sync 2019-10-24 20:51:33 +03:00
Vadim Petrochenkov
175d325ccb rustc_metadata: Move some code around
Plugin search doesn't need a crate loader, only crate locator
2019-10-24 20:51:33 +03:00
Vadim Petrochenkov
2cda75c48f rustc_metadata: Remove unnecessary use of crate store in plugin loader 2019-10-24 20:51:33 +03:00
Vadim Petrochenkov
2c16f84490 rustc_driver: Remove unnecessary use of crate store 2019-10-24 20:50:11 +03:00
bors
8e0007f829 Auto merge of #65474 - Mark-Simulacrum:rustc-dev-split, r=pietroalbini
Split the rustc target libraries into separate rustc-dev component

This is re-applies a squashed version of #64823 as well as including #65337 to fix bugs noted after merging the first PR.

The second PR is confirmed as fixing windows-gnu, and presumably also fixes other platforms, such as musl (i.e. #65335 should be fixed); `RUSTUP_DIST_SERVER=https://dev-static.rust-lang.org rustup toolchain install nightly-2019-10-16` can be installed to confirm that this is indeed the case.
2019-10-24 07:27:00 +00:00
bors
55e00631e5 Auto merge of #65733 - Centril:rollup-0zth66f, r=Centril
Rollup of 12 pull requests

Successful merges:

 - #64178 (More Clippy fixes for alloc, core and std)
 - #65144 (Add Cow::is_borrowed and Cow::is_owned)
 - #65193 (Lockless LintStore)
 - #65479 (Add the `matches!( $expr, $pat ) -> bool` macro)
 - #65518 (Avoid ICE when checking `Destination` of `break` inside a closure)
 - #65583 (rustc_metadata: use a table for super_predicates, fn_sig, impl_trait_ref.)
 - #65641 (Derive `Rustc{En,De}codable` for `TokenStream`.)
 - #65648 (Eliminate `intersect_opt`.)
 - #65657 (Remove `InternedString`)
 - #65691 (Update E0659 error code long explanation to 2018 edition)
 - #65696 (Fix an issue with const inference variables sticking around under Chalk + NLL)
 - #65704 (relax ExactSizeIterator bound on write_bytes)

Failed merges:

r? @ghost
2019-10-24 03:38:57 +00:00
Mazdak Farrokhzad
3cd7a17406
Rollup merge of #65704 - RalfJung:exact-size, r=oli-obk
relax ExactSizeIterator bound on write_bytes

Too many iterators don't have that bound. Instead we do run-time checks.

r? @oli-obk
2019-10-23 22:19:24 +02:00
Mazdak Farrokhzad
b2b35797d0
Rollup merge of #65696 - varkor:nll-chalk-const-generics-issue, r=eddyb
Fix an issue with const inference variables sticking around under Chalk + NLL

Fixes https://github.com/rust-lang/rust/issues/65675.
Fixes https://github.com/rust-lang/rust/issues/62579.

r? @eddyb
cc @LukasKalbertodt @skinny121
2019-10-23 22:19:22 +02:00
Mazdak Farrokhzad
ba9a9ebb25
Rollup merge of #65691 - GuillaumeGomez:2018-edition-E0659, r=Dylan-DPC
Update E0659 error code long explanation to 2018 edition

Fixes #65571

r? @Centril
2019-10-23 22:19:21 +02:00
Mazdak Farrokhzad
a649b1666c
Rollup merge of #65657 - nnethercote:rm-InternedString-properly, r=eddyb
Remove `InternedString`

This PR removes `InternedString` by converting all occurrences to `Symbol`. There are a handful of places that need to use the symbol chars instead of the symbol index, e.g. for stable sorting; local conversions `LocalInternedString` is used in those places.

r? @eddyb
2019-10-23 22:19:19 +02:00
Mazdak Farrokhzad
951b8c84be
Rollup merge of #65648 - nnethercote:rm-intersect_opt, r=nikomatsakis
Eliminate `intersect_opt`.

Its fourth argument is always `Some(pred)`, so the pattern matching is
unnecessary. This commit inlines and removes it.

r? @nikomatsakis
2019-10-23 22:19:17 +02:00
Mazdak Farrokhzad
4a870aaee4
Rollup merge of #65641 - nnethercote:derive-TokenStream-Encodable-Decodable, r=petrochenkov
Derive `Rustc{En,De}codable` for `TokenStream`.

`TokenStream` used to be a complex type, but it is now just a newtype
around a `Lrc<Vec<TreeAndJoint>>`. Currently it uses custom encoding
that discards the `IsJoint` and custom decoding that adds `NonJoint`
back in for every token tree. This requires building intermediate
`Vec<TokenTree>`s.

This commit makes `TokenStream` derive `Rustc{En,De}codable`. This
simplifies the code, and avoids the creation of the intermediate
vectors, saving up to 3% on various benchmarks. It also changes the AST
JSON output in one test.

r? @petrochenkov
2019-10-23 22:19:16 +02:00
Mazdak Farrokhzad
c192e318ca
Rollup merge of #65583 - eddyb:more-query-like-cross-crate-tables, r=michaelwoerister
rustc_metadata: use a table for super_predicates, fn_sig, impl_trait_ref.

This is an attempt at a part of #65407, i.e. moving parts of cross-crate "metadata" into tables that match queries more closely.

Three new tables should be enough to see some perf/metadata size changes.
(need to do something similar to https://github.com/rust-lang/rust/pull/59953#issuecomment-542521919)

There are other bits of data that could be made into tables, but they can be more compact so the impact would likely be not as bad, and they're also more work to set up.
2019-10-23 22:19:14 +02:00
Mazdak Farrokhzad
6bb7449fdb
Rollup merge of #65518 - estebank:i-want-to-break-free, r=eddyb
Avoid ICE when checking `Destination` of `break` inside a closure

Fix #65383, fix #62480. This is a `[regression-from-stable-to-stable]` and a fairly small change to avoid the ICE by properly handling this case.
2019-10-23 22:19:13 +02:00
Mazdak Farrokhzad
a1514b4758
Rollup merge of #65479 - SimonSapin:matches, r=alexcrichton
Add the `matches!( $expr, $pat ) -> bool` macro

# Motivation

This macro is:

* General-purpose (not domain-specific)
* Simple (the implementation is short)
* Very popular [on crates.io](https://crates.io/crates/matches) (currently 37th in all-time downloads)
* The two previous points combined make it number one in [left-pad index](https://twitter.com/bascule/status/1184523027888988160) score

As such, I feel it is a good candidate for inclusion in the standard library.

In fact I already felt that way five years ago: https://github.com/rust-lang/rust/pull/14685 (Although the proof of popularity was not as strong at the time.)

# API

<details>
<del>

Back then, the main concern was that this macro may not be quite universally-enough useful to belong in the prelude.

Therefore, this PR adds the macro such that using it requires one of:

```rust
use core::macros::matches;
use std::macros::matches;
```

</del>
</details>

Like arms of a `match` expression, the macro supports multiple patterns separated by `|` and optionally followed by `if` and a guard expression:

```rust
let foo = 'f';
assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));

let bar = Some(4);
assert!(matches!(bar, Some(x) if x > 2));
```

<details>
<del>

# Implementation constraints

A combination of reasons make it tricky for a standard library macro not to be in the prelude.

Currently, all public `macro_rules` macros in the standard library macros end up “in the prelude” of every crate not through `use std::prelude::v1::*;` like for other kinds of items, but through `#[macro_use]` on `extern crate std;`. (Both are injected by `src/libsyntax_ext/standard_library_imports.rs`.)

`#[macro_use]` seems to import every macro that is available at the top-level of a crate, even if through a `pub use` re-export.

Therefore, for `matches!` not to be in the prelude, we need it to be inside of a module rather than at the root of `core` or `std`.

However, the only way to make a `macro_rules` macro public outside of the crate where it is defined appears to be `#[macro_export]`. This exports the macro at the root of the crate regardless of which module defines it. See [macro scoping](https://doc.rust-lang.org/reference/macros-by-example.html#scoping-exporting-and-importing) in the reference.

Therefore, the macro needs to be defined in a crate that is not `core` or `std`.

# Implementation

This PR adds a new `matches_macro` crate as a private implementation detail of the standard library. This crate is `#![no_core]` so that libcore can depend on it. It contains a `macro_rules` definition with `#[macro_export]`.

libcore and libstd each have a new public `macros` module that contains a `pub use` re-export of the macro. Both the module and the macro are unstable, for now.

The existing private `macros` modules are renamed `prelude_macros`, though their respective source remains in `macros.rs` files.

</del>
</details>
2019-10-23 22:19:11 +02:00
Mazdak Farrokhzad
7c043e284a
Rollup merge of #65193 - Mark-Simulacrum:lockless-lintstore, r=nikomatsakis
Lockless LintStore

This removes mutability from the lint store after registration. Each commit stands alone, for the most part, though they don't make sense out of sequence.

The intent here is to move LintStore to a more parallel-friendly architecture, although also just a cleaner one from an implementation perspective. Specifically, this has the following changes:
 * We no longer implicitly register lints when registering lint passes
    * For the most part this means that registration calls now likely want to call something like:
       `lint_store.register_lints(&Pass::get_lints())` as well as `register_*_pass`.
    * In theory this is a simplification as it's much easier for folks to just register lints and then have passes that implement whichever lint however they want, rather than necessarily tying passes to lints.
 * Lint passes still have a list of associated lints, but a followup PR could plausibly change that
   * This list must be known for a given pass type, not instance, i.e., `fn get_lints()` is the signature instead of `fn get_lints(&self)` as before.
 * We do not store pass objects, instead storing constructor functions. This means we always get new passes when running lints (this happens approximately once though for a given compiler session, so no behavior change is expected).
 * Registration API is _much_ simpler: generally all functions are just taking `Fn() -> PassObject` rather than several different `bool`s.
2019-10-23 22:19:10 +02:00
Mazdak Farrokhzad
4b9fbfbc29
Rollup merge of #65144 - clarfon:moo, r=sfackler
Add Cow::is_borrowed and Cow::is_owned

Implements #65143.
2019-10-23 22:19:08 +02:00
Mazdak Farrokhzad
426c6cf84f
Rollup merge of #64178 - mati865:clippy, r=scottmcm
More Clippy fixes for alloc, core and std

Continuation of https://github.com/rust-lang/rust/pull/63805
2019-10-23 22:19:07 +02:00
varkor
624e34a5d0 Account for const generalisation in nll_relate 2019-10-23 18:00:35 +01:00
varkor
12f68e6987 Account for const generalisation in combine 2019-10-23 17:40:18 +01:00
varkor
cc7294c751 Add regression test for #62579 2019-10-23 17:09:56 +01:00
Simon Sapin
e76a184615 Document guard expressions in matches! 2019-10-23 15:46:42 +02:00
Simon Sapin
f7ebe19338 Add tracking issue for the matches! macro
https://github.com/rust-lang/rust/issues/65721
2019-10-23 15:35:36 +02:00
Simon Sapin
7472cd46aa Move the matches! macro to the prelude 2019-10-23 15:35:36 +02:00
Simon Sapin
f69293ae80 Add core::macros::matches!( $expr, $pat ) -> bool
# Motivation

This macro is:

* General-purpose (not domain-specific)
* Simple (the implementation is short)
* Very popular [on crates.io](https://crates.io/crates/matches)
  (currently 37th in all-time downloads)
* The two previous points combined make it number one in
  [left-pad index](https://twitter.com/bascule/status/1184523027888988160)
  score

As such, I feel it is a good candidate for inclusion in the standard library.

In fact I already felt that way five years ago:
https://github.com/rust-lang/rust/pull/14685
(Although the proof of popularity was not as strong at the time.)

Back then, the main concern was that this macro may not be quite
universally-enough useful to belong in the prelude.

# API

Therefore, this PR adds the macro such that using it requires one of:

```
use core::macros::matches;
use std::macros::matches;
```

Like arms of a `match` expression,
the macro supports multiple patterns separated by `|`
and optionally followed by `if` and a guard expression:

```
let foo = 'f';
assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));

let bar = Some(4);
assert!(matches!(bar, Some(x) if x > 2));
```

# Implementation constraints

A combination of reasons make it tricky
for a standard library macro not to be in the prelude.

Currently, all public `macro_rules` macros in the standard library macros
end up “in the prelude” of every crate not through `use std::prelude::v1::*;`
like for other kinds of items,
but through `#[macro_use]` on `extern crate std;`.
(Both are injected by `src/libsyntax_ext/standard_library_imports.rs`.)

`#[macro_use]` seems to import every macro that is available
at the top-level of a crate, even if through a `pub use` re-export.

Therefore, for `matches!` not to be in the prelude, we need it to be
inside of a module rather than at the root of `core` or `std`.

However, the only way to make a `macro_rules` macro public
outside of the crate where it is defined
appears to be `#[macro_export]`.
This exports the macro at the root of the crate
regardless of which module defines it.
See [macro scoping](
https://doc.rust-lang.org/reference/macros-by-example.html#scoping-exporting-and-importing)
in the reference.

Therefore, the macro needs to be defined in a crate
that is not `core` or `std`.

# Implementation

This PR adds a new `matches_macro` crate as a private implementation detail
of the standard library.
This crate is `#![no_core]` so that libcore can depend on it.
It contains a `macro_rules` definition with `#[macro_export]`.

libcore and libstd each have a new public `macros` module
that contains a `pub use` re-export of the macro.
Both the module and the macro are unstable, for now.

The existing private `macros` modules are renamed `prelude_macros`,
though their respective source remains in `macros.rs` files.
2019-10-23 15:35:34 +02:00
bors
4a8c5b20c7 Auto merge of #57545 - bovinebuddha:object_safe_for_dispatch, r=nikomatsakis
Object safe for dispatch

cc #43561
2019-10-23 13:34:27 +00:00
bors
f466f52c1b Auto merge of #65716 - JohnTitor:rollup-fkcr85k, r=JohnTitor
Rollup of 14 pull requests

Successful merges:

 - #64145 (Target-feature documented as unsafe)
 - #65007 (Mention keyword closing policy)
 - #65417 (Add more coherence tests)
 - #65507 (Fix test style in unused parentheses lint test)
 - #65591 (Add long error explanation for E0588)
 - #65617 (Fix WASI sleep impl)
 - #65656 (Add option to disable keyboard shortcuts in docs)
 - #65678 (Add long error explanation for E0728)
 - #65681 (Code cleanups following up on #65576.)
 - #65686 (refactor and move `maybe_append` )
 - #65688 (Add some tests for fixed ICEs)
 - #65689 (bring back some Debug instances for Miri)
 - #65695 (self-profiling: Remove module names from some event-ids in codegen backend.)
 - #65706 (Add missing space in librustdoc)

Failed merges:

r? @ghost
2019-10-23 09:53:32 +00:00
Yuki Okushi
1df9081413
Rollup merge of #65706 - popzxc:add-missing-space, r=Mark-Simulacrum
Add missing space in librustdoc

It just hurts my eyes...

r? @Centril
2019-10-23 17:14:47 +09:00
Yuki Okushi
41850dfea6
Rollup merge of #65695 - michaelwoerister:fix-self-profiling-work-item-event-names, r=wesleywiser
self-profiling: Remove module names from some event-ids in codegen backend.

Event-IDs are not supposed to contain argument values. Event-IDs are the equivalent of function names. Proper support for parameters will be added to self-profiling down the line.

This PR fixes an oversight from https://github.com/rust-lang/rust/pull/64840.

r? @wesleywiser
2019-10-23 17:14:46 +09:00
Yuki Okushi
12f32c2f29
Rollup merge of #65689 - RalfJung:miri-debug, r=Centril
bring back some Debug instances for Miri

These were erroneously removed in https://github.com/rust-lang/rust/pull/65647, but Miri needs them.

r? @Centril Cc @nnethercote @oli-obk
2019-10-23 17:14:44 +09:00
Yuki Okushi
c3e5413813
Rollup merge of #65688 - JohnTitor:add-some-tests, r=Dylan-DPC
Add some tests for fixed ICEs

Fixes #41366 from 1.35.0
Fixes #51431 from 1.31.0-nightly (77af31408 2018-10-11) (on my local)
Fixes #52437 from nightly
Fixes #63496 from nightly

r? @Centril
2019-10-23 17:14:43 +09:00
Yuki Okushi
5bac361776
Rollup merge of #65686 - yjhmelody:yjhmelody-patch-1, r=Centril
refactor and move `maybe_append`
2019-10-23 17:14:42 +09:00
Yuki Okushi
7fc6ce9db2
Rollup merge of #65681 - sunfishcode:followup, r=Centril
Code cleanups following up on #65576.

This makes a few code cleanups to follow up on the review comments in
https://github.com/rust-lang/rust/pull/65576.

r? @Centril
2019-10-23 17:14:40 +09:00
Yuki Okushi
b7994653a1
Rollup merge of #65678 - JohnTitor:add-e0728-explanation, r=GuilliaumeGomez
Add long error explanation for E0728

Part of #61137

r? @GuillaumeGomez
2019-10-23 17:14:39 +09:00
Yuki Okushi
88e3ae2eb4
Rollup merge of #65656 - GuillaumeGomez:option-disable-shortcut, r=Dylan-DPC
Add option to disable keyboard shortcuts in docs

Fixes #65211.

r? @Manishearth
2019-10-23 17:14:37 +09:00
Yuki Okushi
ff2442ff36
Rollup merge of #65617 - newpavlov:patch-2, r=alexcrichton
Fix WASI sleep impl

Closes #65607

@sunfishcode
Is it fine to use 0 for the `identifier` field? What is this field used for?
2019-10-23 17:14:36 +09:00
Yuki Okushi
6f6f3e8cd7
Rollup merge of #65591 - GuillaumeGomez:long-err-explanation-E0588, r=Dylan-DPC
Add long error explanation for E0588

Part of #61137.

r? @kinnison
2019-10-23 17:14:34 +09:00
Yuki Okushi
1dbb010c9a
Rollup merge of #65507 - polyedre:master, r=nikomatsakis
Fix test style in unused parentheses lint test

I think this fixes #63237
I'm not sure if I had to add text after the `//~ ERROR` comments.
This is my first pull request, so I'm open to feedback.
This issues already received one pull request [here](https://github.com/rust-lang/rust/pull/63257) but it was marked as closed for inactivity.

r?  @nikomatsakis
2019-10-23 17:14:33 +09:00
Yuki Okushi
557d27637d
Rollup merge of #65417 - weiznich:more_coherence_tests, r=nikomatsakis
Add more coherence tests

I've wrote the missing test cases listed in [this google doc](https://docs.google.com/spreadsheets/d/1WlroTEXE6qxxGvEOhICkUpqguYZP9YOZEvnmEtSNtM0/edit#gid=0)

> The other thing that might be useful is to rename the existing tests so they all fit the new naming scheme we were using.

I'm not entirely sure how to do this. If everything from the google sheet is covered could I just remove the remaining tests in `src/test/ui/coherence` or is there something in there that should remain?

cc #63599

r? @nikomatsakis
2019-10-23 17:14:31 +09:00
Yuki Okushi
bd82de0de6
Rollup merge of #65007 - BO41:keywords, r=nikomatsakis
Mention keyword closing policy

closes #59233 / https://github.com/rust-lang/rust/issues/59233#issuecomment-478362693

rewording suggestions welcome

> Also in the referenced issue, the commit number of the new commit
> that could close that issue is not really informative. The PR number itself appeared in the issue
> is more informative and concise.

@lzutao what do you mean with that? Is this fixed by the new "May be fixed by #XXXXX"?
2019-10-23 17:14:29 +09:00
Yuki Okushi
86992272d5
Rollup merge of #64145 - togiberlin:feature/target-features-doc, r=ehuss
Target-feature documented as unsafe

@nikomatsakis asked me to help out on the docs on this issue: https://github.com/rust-lang/rust/issues/63597

The following docs have been modified
- ```rustc -C help``` text for `target-feature`
- RustC book:

## Preview of src/doc/rustc/src/targets/index.md
![Screenshot 2019-09-17 at 12 22 45](https://user-images.githubusercontent.com/13764830/65033746-f7826700-d945-11e9-9dd2-d8f9b08f45de.png)

## Preview of src/doc/rustc/src/targets/known-issues.md
![Screenshot 2019-09-17 at 12 22 25](https://user-images.githubusercontent.com/13764830/65033774-00733880-d946-11e9-9398-90f01f3938d5.png)

Fixes #63597
2019-10-23 17:14:27 +09:00