102825 Commits

Author SHA1 Message Date
Dylan MacKenzie
25122d09eb Const-check the discriminant of a SwitchInt 2019-11-21 16:55:13 -08:00
Dylan MacKenzie
5c377f37e4 Reorganize, bless and add tests for const control flow
This creates a new test directory, `ui/consts/control-flow` to hold
tests related to control flow in a const context. It also blesses all
existing tests with the new error messages, and adds new tests for the
`const_if_match` feature.
2019-11-21 16:55:13 -08: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
26d93f35f6 Add entry for const_if_match in unstable book 2019-11-21 15:23:51 -08:00
Dylan MacKenzie
ccb6e9884e Suggest const_if_match on nightly 2019-11-21 14:20:00 -08:00
Dylan MacKenzie
f4b9dc7d59 Make name work for MatchSource 2019-11-21 14:20:00 -08:00
Dylan MacKenzie
929ff68376 Hold a TyCtxt in the HIR const-checker 2019-11-21 14:20:00 -08:00
Dylan MacKenzie
a98d20a260 Allow Downcast projections if const_if_match enabled
These are generated when matching on enum variants to extract the value
within. We should have no problem evaluating these, but care should be
taken that we aren't accidentally allowing some other operation.
2019-11-21 14:20:00 -08:00
Dylan MacKenzie
e969fb2176 Don't transform short-circuiting logic if const_if_match enabled 2019-11-21 14:20:00 -08:00
Dylan MacKenzie
365d123689 Add feature gate for const if and match 2019-11-21 14:19:59 -08: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
QuietMisdreavus
0d7a7b5547 move cfg(doc) docs into a separate page 2019-11-21 15:38:30 +01:00
Guillaume Gomez
a056bf9714 Rename the cfg attribute from rustdoc to doc 2019-11-21 15:38:30 +01:00
Guillaume Gomez
086c8d3db7 Stabilize cfg rustdoc 2019-11-21 15:37:36 +01: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
df9fed17ed Update tidy check for error codes testing 2019-11-21 13:12:43 +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
MaulingMonkey
839d58ca56 debuginfo: Support for std::collections::Hash* in windows debuggers. 2019-11-20 19:27:42 -08:00
Aaron Hill
bc7b17c477
Fix cycle when debug-printing opaque types
Fixes #61577

When printing an opaque type in non-verbose mode, we use the
`tcx.predicates_of` query to retrieve the opaque type's bounds for
pretty-printing. However, the pervasiveness of logging within librustc
means that we may already be executing `tcx.predicates_of` for the
opaque type we're trying to print, leading to a cycle error.

This commit adds a new 'no queries' thread-local flag to the pretty
printer. This flag is enabled during the computation of `predicates_of`
for opaque types, and causes us to print the opaque type in 'verbose'
mode (which does not require computing any additinal queries). This
should only affect debug logging for highly nested log messages, not any
user-visible output.
2019-11-20 20:19:23 -05:00
Mazdak Farrokhzad
44cebe5970 reduce size of hir::ExprKind 2019-11-21 01:23:29 +01:00
Aaron Hill
a5c45f006a
Bump Miri for return code propagation 2019-11-20 17:26:49 -05:00
Phlosioneer
983cae77dd
Clarify Step Documentation
While the redesign is in progress (#62886), clarify the purpose of replace_zero and replace_one.
2019-11-20 14:40:54 -05:00
bors
f1b882b558 Auto merge of #66578 - Centril:rollup-pgz1v7t, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #66060 (Making ICEs and test them in incremental)
 - #66298 (rustdoc: fixes #64305: disable search field instead of hidding it)
 - #66457 (Just derive Hashstable in librustc)
 - #66496 (rustc_metadata: Privatize more things)
 - #66514 (Fix selected crate search filter)
 - #66535 (Avoid ICE when `break`ing to an unreachable label)
 - #66573 (Ignore run-make reproducible-build-2 on Mac)

Failed merges:

r? @ghost
2019-11-20 19:15:41 +00:00
Mark Rousskov
70805e6444 Delete ProcessCfgMod
The previous commit removes the use of this, and now we cleanup.
2019-11-20 14:07:57 -05:00