102712 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
fd3bd29c18
Rollup merge of #66637 - RalfJung:typo, r=Centril
fix reoccuring typo: dereferencable -> dereferenceable
2019-11-22 19:57:54 +01:00
Mazdak Farrokhzad
8be9e90454
Rollup merge of #66633 - GuillaumeGomez:err-codes-cleanup, r=Dylan-DPC
Error code's long explanation cleanup

Continuing to clean up the error code's long explanation.

r? @Dylan-DPC
2019-11-22 19:57:52 +01:00
Mazdak Farrokhzad
a699945ead
Rollup merge of #66619 - guanqun:use-third-person-singular-verb, r=Centril
follow the convention in this file to use third-person singular verbs
2019-11-22 19:57:51 +01:00
Mazdak Farrokhzad
3031720d8f
Rollup merge of #66587 - matthewjasper:handle-static-as-const, r=oli-obk
Handle statics in MIR as const pointers

This is the first PR towards the goal of removing `PlaceBase::Static`. In this PR:

* Statics are lowered to dereferencing a const pointer.
* The temporaries holding such pointers are tracked in MIR, for the most part this is only used for diagnostics. There are two exceptions:
    * The borrow checker has some checks for thread-locals that directly use this data.
    * Const checking will suppress "cannot dereference raw pointer" diagnostics for pointers to `static mut`/`extern static`. This is to maintain the current behaviour (12 tests fail otherwise).

The following are left to future PRs (I think that @spastorino will be working on the first 3):

* Applying the same treatments to promoted statics.
* Removing `PlaceBase::Static`.
* Replacing `PlaceBase` with `Local`.
* Moving the ever growing collection of metadata that we have for diagnostics in MIR passes somewhere more appropriate.

r? @oli-obk
2019-11-22 19:57:49 +01:00
Mazdak Farrokhzad
c66b508137
Rollup merge of #66575 - Mark-Simulacrum:no-uii, r=petrochenkov
Remove pretty printing of specific nodes in AST

The ability to print a specific item as identified by NodeId or path
seems not particularly useful, and certainly carries quite a bit of
complexity with it.

This is intended to simplify our CLI parsing a bit and remove a
non-uncomplicated piece of it; I largely did this to remove the
dependency on NodeId from librustc/session but it's not really
necessary to do so in this invasive a way. The alternative is
moving it to librustc_interface or driver, probably.
2019-11-22 19:57:48 +01:00
Mazdak Farrokhzad
afc78e19dd
Rollup merge of #66566 - robamler:issue-66476, r=rkruppe
Document pitfall with `impl PartialEq<B> for A`

Fixes #66476 by turning the violating example into an explicit
counterexample.
2019-11-22 19:57:46 +01:00
Mazdak Farrokhzad
8cba0a9073
Rollup merge of #66183 - Centril:empty-vis-trait-decl, r=petrochenkov
*Syntactically* permit visibilities on trait items & enum variants

Fixes #65041

Suppose we have `$vis trait_item` or `$vis enum_variant` and `$vis` is a `:vis` macro fragment. Before this PR, this would fail to parse. This is now instead allowed as per language team consensus in https://github.com/rust-lang/rust/issues/65041#issuecomment-538105286. (See added tests for elaboration.)

Moreover, we now also permit visibility modifiers on trait items & enum variants *syntactically* but reject them with semantic checks (in `ast_validation`):

```rust
#[cfg(FALSE)]
trait Foo { pub fn bar(); } // OK

#[cfg(FALSE)]
enum E { pub U } // OK
```
2019-11-22 19:57:41 +01:00
Guillaume Gomez
a8de11cdd5 small error code explanations improvements 2019-11-22 19:14:09 +01:00
Guillaume Gomez
9bb2e3cd34 Improve E0061 long error explanation 2019-11-22 19:14:09 +01:00
Guillaume Gomez
f798804cd9 Improve E0057 long error explanation 2019-11-22 19:14:09 +01:00
Guillaume Gomez
60d9c2c239 Improve E0023 long error explanation 2019-11-22 19:14:09 +01:00
Guillaume Gomez
ea62c2e5b3 Improve E0015 long error explanation 2019-11-22 19:14:09 +01:00
Ralf Jung
9ff91ab2d3 fix reoccuring typo: dereferencable -> dereferenceable 2019-11-22 18:11:28 +01:00
bors
083b5a0a1b Auto merge of #66460 - cjgillot:hashstable_generic, r=Zoxc
Add a proc-macro to derive HashStable in librustc dependencies

A second proc-macro is added to derive HashStable for crates librustc depends on.
This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate.

Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc.
Types using them stay there too.

Split out of #66279
r? @Zoxc
2019-11-22 13:54:41 +00:00
bors
eaac45a9a9 Auto merge of #66565 - Mark-Simulacrum:syntax-cfg-mod, r=petrochenkov
Move process_configure_mod to rustc_parse

This removes the hack in favor of perhaps a less principled, but less painful, approach.

This also supports my work to decouple `Session` from librustc, as `ParseSess` currently has `Attribute` as "part" of it but after this PR will no longer do so.
2019-11-22 10:33:29 +00:00
Guanqun Lu
da5539cf7c follow the convention in this file to use third-person singular verbs 2019-11-22 15:37:11 +08:00
bors
564f2d30ed Auto merge of #66537 - nnethercote:delay-is_local_ever_initialized, r=spastorino
Delay an `is_local_ever_initialized` call.

This commit moves the call after a `return` that almost always runs. It
speeds up the `unicode_normalization` benchmark by about 2%.

r? @spastorino
2019-11-22 07:21:48 +00:00
Robert Bamler
5028fd8ab9 Document pitfall with impl PartialEq<B> for A
Fixes #66476 by turning the violating example into an explicit
counterexample.
2019-11-21 23:16:44 -08:00
bors
bd816fd76f Auto merge of #66524 - ecstatic-morse:compiletest-multiple-revisions, r=Centril
Support multiple revisions in `compiletest`

The `//[X]~` syntax filters errors for tests that are run across multiple cfgs with  `// revisions:`. This commit extends that syntax to accept `//[X,Y]~`, which will match multiple cfgs to the same error annotation. This is functionally the same as writing two comments, `//[X]~` and `//[Y]~`, but can fit on a single line.

While refactoring `compiletest` to support this, I also uncovered a small bug that was causing an incremental test to always pass, despite no errors being emitted.

r? @Centril
2019-11-22 04:06:52 +00:00
bors
abd69551bf Auto merge of #66282 - Centril:simplify-try, r=oli-obk
[mir-opt] asking `?`s in a more optimized fashion

This PR works towards https://github.com/rust-lang/rust/issues/66234 by providing two optimization passes meant to run in sequence:

- `SimplifyArmIdentity` which transforms something like:
  ```rust
  _LOCAL_TMP = ((_LOCAL_1 as Variant ).FIELD: TY );
  ((_LOCAL_0 as Variant).FIELD: TY) = move _LOCAL_TMP;
  discriminant(_LOCAL_0) = VAR_IDX;
  ```

  into:

  ```rust
  _LOCAL_0 = move _LOCAL_1
  ```

- `SimplifyBranchSame` which transforms `SwitchInt`s to identical basic blocks into a `goto` to the first reachable target.

Together, these are meant to simplify the following into just `res`:
```rust
match res {
    Ok(x) => Ok(x),
    Err(x) => Err(x),
}
```

It should be noted however that the desugaring of `?` includes a function call and so the first pass in this PR relies on inlining to substitute that function call for identity on `x`. Inlining requires `mir-opt-level=2` so this might not have any effect in perf-bot but let's find out.

r? @oli-obk -- This is WIP, but I'd appreciate feedback. :)
2019-11-22 00:16:40 +00:00
Dylan MacKenzie
c537f22900 Give name to full regex capture 2019-11-21 14:13:42 -08:00
Dylan MacKenzie
ae2293837e Change some tests to use the shorter comment style 2019-11-21 14:09:18 -08:00
Dylan MacKenzie
701f6e51b2 Fix broken incremental test
This test does not actually emit any warnings, since
`#![allow(warnings)]` was specified. `compiletest` was erroneously
ignoring `//~` tests and looking only for `//[X]~` ones. As a result of
the changes in the previous commit, we now look for `//~` comments in
incremental tests and expect them to appear in *all* revisions.
2019-11-21 14:08:33 -08:00
Dylan MacKenzie
54d51bc483 Allow multiple cfgs per comment in "revisions:" tests
The `//[X]~` syntax filters errors for tests that are run across
multiple cfgs with  `// revisions:`. This commit extends that syntax to
accept `//[X,Y]~`, which will match multiple cfgs to the same error
annotation. This is functionally the same as writing two comments,
`//[X]~` and `//[Y]~`, but can fit on a single line.
2019-11-21 14:08:33 -08:00
Matthew Jasper
bccc59a8e6 Address review comments 2019-11-21 21:20:47 +00:00
bors
f11759d38c Auto merge of #66610 - alexreg:trait-upcasting-cosmetic, r=Centril
Aggregation of drive-by cosmetic changes for trait-upcasting PR

Cherry-picked from #60900.

As requested by @Centril (and @nikomatsakis, I believe).

r? @Centril
2019-11-21 21:01:14 +00:00
Matthew Jasper
025630d189 Bless remaining test output 2019-11-21 20:55:17 +00:00
Matthew Jasper
9abc34ed9d Track pointers to statics in MIR 2019-11-21 20:55:17 +00:00
Matthew Jasper
c6d97dfd83 Fix rebase 2019-11-21 20:55:17 +00:00
Santiago Pastorino
47a3294a1c Readjust constant evaluation for operands 2019-11-21 20:54:55 +00:00
Santiago Pastorino
36006955e7 Simplify pattern 2019-11-21 20:54:55 +00:00
Santiago Pastorino
ae9677c82f Readjust const qualification to detect statics again 2019-11-21 20:54:55 +00:00
Oliver Scherer
a1d04cc1d8 Remove statics from HAIR by lowering them to a pointer constant 2019-11-21 20:54:33 +00:00
Mazdak Farrokhzad
2f00e86cb5 Introduce MIR optimizations for simplifying x? on Results.
This optimization depends on inlining for the identity
conversions introduced by the lowering of the `?`.
To take advantage of `SimplifyArmIdentity`, `-Z mir-opt-level=2`
is required because that triggers the inlining MIR optimization.
2019-11-21 20:05:16 +01:00
Alexander Regueiro
1b2de17647 Applied suggestions from code review. 2019-11-21 18:50:40 +00:00
Alexander Regueiro
51cb60cd3f Aggregation of drive-by cosmetic changes. 2019-11-21 18:50:38 +00:00
bors
53712f8637 Auto merge of #66389 - estebank:type-err-labels, r=petrochenkov
Specific labels when referring to "expected" and "found" types
2019-11-21 17:53:19 +00:00
bors
35ef33a89d Auto merge of #66607 - Centril:rollup-yb7cl73, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #65355 (Stabilize `!` in Rust 1.41.0)
 - #65730 (Suggest to add lifetime constraint at explicit ouput of functions)
 - #66468 (Cleanup Miri SIMD intrinsics)
 - #66515 (Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`)
 - #66602 (Revert "Update Source Code Pro and include italics")

Failed merges:

r? @ghost
2019-11-21 14:30:02 +00:00
Mazdak Farrokhzad
5ab2bccbcd
Rollup merge of #66602 - GuillaumeGomez:revert-font, r=GuillaumeGomez
Revert "Update Source Code Pro and include italics"

This reverts commit ea9519bf16f0be137a814a49c9fbaf232ba49a43.
2019-11-21 15:29:08 +01:00
Mazdak Farrokhzad
d7bb37d663
Rollup merge of #66515 - Centril:cheaper-inline-asm, r=oli-obk
Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`

r? @oli-obk
2019-11-21 15:29:07 +01:00
Mazdak Farrokhzad
02b38ac0ff
Rollup merge of #66468 - RalfJung:simd-cleanup, r=oli-obk
Cleanup Miri SIMD intrinsics

r? @oli-obk @eddyb Cc @gnzlbg
2019-11-21 15:29:05 +01:00
Mazdak Farrokhzad
e4a634189e
Rollup merge of #65730 - csmoe:return-lifetime, r=nikomatsakis
Suggest to add lifetime constraint at explicit ouput of functions

Closes #62097
2019-11-21 15:29:02 +01:00
Mazdak Farrokhzad
0828d5327b
Rollup merge of #65355 - Centril:almost-is-never-enough, r=oli-obk
Stabilize `!` in Rust 1.41.0

This PR stabilizes the `never_type` (written `!`). The type represents computations that we know diverge in the type system and therefore has no values / inhabitants / elements / members.

The current nightly version is 1.40.0 which will become stable on 2019-12-19.

Tracking issue: https://github.com/rust-lang/rust/issues/35121.
Closes https://github.com/rust-lang/rust/issues/57012.
Closes https://github.com/rust-lang/rust/issues/58184.
Original stabilization report: https://github.com/rust-lang/rust/issues/57012#issuecomment-452398538

Additional notes:

- In #62661 we reserved `impl<T> From<!> for T` so this concern should be resolved.
- The type inference fallback change is moved to `#![feature(never_type_fallback)]` (https://github.com/rust-lang/rust/issues/65992).
- You can find all of the tests referencing `never_type` in this PR which also reorganizes these tests whereas they were more scattered before.

r? @nikomatsakis
2019-11-21 15:29:00 +01:00
Mazdak Farrokhzad
238d03b3a3 never_type: test interaction with auto traits 2019-11-21 15:09:18 +01:00
Mazdak Farrokhzad
089229a193 Redefine core::convert::Infallible as !. 2019-11-21 14:55:33 +01:00
Mazdak Farrokhzad
6eb0627b49 Gate fallback via #![feature(never_type_fallback)]. 2019-11-21 14:55:33 +01:00
Mazdak Farrokhzad
8f6197f39f Remove #![feature(never_type)] from tests.
Also remove `never_type` the feature-gate test.
2019-11-21 14:55:32 +01:00
Mazdak Farrokhzad
15c30ddd69 Stabilize the never_type, written !. 2019-11-21 14:55:32 +01:00
Guillaume Gomez
d0b67ddc0f Revert "Update Source Code Pro and include italics"
This reverts commit ea9519bf16f0be137a814a49c9fbaf232ba49a43.
2019-11-21 11:18:23 +01:00
Mazdak Farrokhzad
44cebe5970 reduce size of hir::ExprKind 2019-11-21 01:23:29 +01:00