Commit Graph

3352 Commits

Author SHA1 Message Date
Ben Lewis
a6c4025fac perf: eagerly convert literals to consts, this avoids creating loads on unevaluated consts
which requires a lot of unnecessary work to evaluate them further down the line.
2020-01-14 07:47:45 +13:00
bors
59c1db0339 Auto merge of #67901 - matthewjasper:split-mir-build, r=nagisa
Split MIR building into its own crate

This moves `rustc_mir::{build, hair, lints}` to `rustc_mir_build`.
The new crate only has a `provide` function as it's public API.

Based on #67898

cc @Centril @rust-lang/compiler
r? @oli-obk
2020-01-12 09:44:55 +00:00
Matthew Jasper
b358929251 Split rustc_mir::{build, hair, lints} into their own crate 2020-01-12 09:39:26 +00:00
Mazdak Farrokhzad
cc51d0350e
Rollup merge of #68045 - Centril:liberate-lints, r=Mark-Simulacrum
Move more of `rustc::lint` into `rustc_lint`

Based on https://github.com/rust-lang/rust/pull/67806.

Here we try to consolidate more of the linting infra into `rustc::lint`. Some high-level notes:

- We now store an `Lrc<dyn Any + Send + Sync>` as opposed to `Lrc<LintStore>` in the `GlobalCtxt`. This enables us to avoid referring to the type, breaking a cyclic dependency, and so we can move things from `rustc::lint` to `rustc_lint`.

- `in_derive_expansion` is, and needs to, be moved as a method on `Span`.

- We reduce the number of ways on `tcx` to emit a lint so that the developer UX is more streamlined.

- `LintLevelsBuilder` is moved to `rustc_lint::levels`, leaving behind `LintLevelMap/Set` in a purified form due to current constraints (hopefully fixable in the future after https://github.com/rust-lang/rust/pull/68133).

- `struct_lint_level` is moved to `rustc::lint` due to current dependency constraints.

- `rustc::lint::context` is moved to `rustc_lint::context`.

- The visitors in `rustc::lint` are moved to `rustc_lint::passes`.
2020-01-12 03:27:59 +01:00
bors
1389494ac1 Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
Promote references to constants instead of statics

r? @oli-obk
2020-01-11 14:46:17 +00:00
Mazdak Farrokhzad
8be2a04c7e pacify the parallel compiler 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
16bf2783b5 inline maybe_lint_level_root 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
f577b44712 move LintSource to levels 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
6f1a79cabe GlobalCtxt: Erase LintStore type. 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
c151782d76 reduce diversity in linting methods 2020-01-11 07:42:26 +01:00
Mazdak Farrokhzad
3a2af3242c canonicalize some lint imports 2020-01-11 07:42:15 +01:00
Yuki Okushi
7ae0618e0a
Rollup merge of #68050 - Centril:canon-error, r=Mark-Simulacrum
Canonicalize rustc_error imports

r? @Mark-Simulacrum
2020-01-11 04:50:53 +09:00
Yuki Okushi
793b1be6df
Rollup merge of #67258 - Centril:open-ended-ranges, r=oli-obk
Introduce `X..`, `..X`, and `..=X` range patterns

Tracking issue: https://github.com/rust-lang/rust/issues/67264
Feature gate: `#![feature(half_open_range_patterns)]`

---------------------------

In this PR, we introduce range-from (`X..`), range-to (`..X`), and range-to-inclusive (`..=X`) patterns.
These correspond to the `RangeFrom`, `RangeTo`, and `RangeToInclusive` expression forms introduced with the same syntaxes. The correspondence is both syntactic and semantic (in the sense that e.g. a `X..` pattern matching on a scrutinee `s` holds exactly when `(X..).contains(&s)` holds).

---------------------------

Noteworthy:

- The compiler complexity added with this PR is around 10 lines (discounting new tests, which account for the large PR size).

- `...X` is accepted syntactically with the same meaning as `..=X`. This is done primarily to simplify and unify the implementation & spec. If-and-when we decide to make `X...Y` a hard error on a new edition, we can do the same for `...X` patterns as well.

- `X...` and `X..=` is rejected syntactically just like it is for the expression equivalents. We should perhaps make these into semantic restrictions (cc @petrochenkov).

- In HAIR, these half-open ranges are represented by inserting the max/min values for the approprate types. That is, `X..` where `X: u8` would become `X..=u8::MAX` in HAIR (note the `..=` since `RangeFrom` includes the end).

- Exhaustive integer / char matching does not (yet) allow for e.g. exhaustive matching on `0usize..` or `..5usize | 5..` (same idea for `isize`). This would be a substantially more invasive change, and could be added in some other PR.

- The issues with slice pattern syntax has been resolved as we decided to use `..` to mean a "rest-pattern" and `[xs @ ..]` to bind the rest to a name in a slice pattern.

- Like with https://github.com/rust-lang/rust/pull/35712, which provided `X..Y` range patterns, this is not yet backed up by an RFC. I'm providing this experimental implementation now to have something concrete to discuss. I would be happy to provide an RFC for this PR as well as for #35712 to finalize and confirm the ideas with the larger community.

Closes https://github.com/rust-lang/rfcs/issues/947.

---------------------------

r? @varkor cc @matthewjasper @oli-obk

I would recommend reviewing this (in particular HAIR-lowering and pattern parsing changes) with whitespace changes ignored.
2020-01-11 04:50:46 +09:00
Michael Woerister
ad65e3e6bc Fix some rebasing fallout. 2020-01-10 10:57:36 +01:00
Michael Woerister
83e921d770 Run 'x.py fmt'. 2020-01-10 10:19:39 +01:00
Michael Woerister
6848ed2d65 self-profile: Fix issue with handling query blocking. 2020-01-10 10:19:39 +01:00
Michael Woerister
b8ead417a6 Initial support for recording query keys in self-profiling data. 2020-01-10 10:19:39 +01:00
Michael Woerister
a62c040929 self-profile: Switch to new approach for event_id generation that enables query-invocation-specific event_ids. 2020-01-10 10:18:21 +01:00
Santiago Pastorino
5d9b399044 Remove PlaceBase enum and make Place base field be local: Local 2020-01-10 09:08:25 +01:00
Santiago Pastorino
fd5aa32c35 Remove Static from PlaceBase 2020-01-10 09:08:24 +01:00
Santiago Pastorino
1688719214 Promote Refs to constants instead of static 2020-01-10 09:08:24 +01:00
Mazdak Farrokhzad
8bd3d240e3 nix syntax::errors & prefer rustc_errors over errors 2020-01-10 07:41:30 +01:00
Mazdak Farrokhzad
d5598aa7a0 Introduce #![feature(half_open_range_patterns)].
This feature adds `X..`, `..X`, and `..=X` patterns.
2020-01-10 07:29:04 +01:00
Mazdak Farrokhzad
3bfa28c3a8
Rollup merge of #67922 - Centril:lowering-cleanup, r=petrochenkov
rustc_ast_lowering: misc cleanup & rustc dep reductions

- The first two commits do some code simplification.
- The next three do some file splitting (getting `lib.rs` below the 3kloc tidy lint).
- The remaining commits reduce the number of `rustc::` imports. This works towards making lowering independent of the `rustc` crate.

r? @oli-obk cc @Zoxc
2020-01-10 02:47:33 +01:00
Yuki Okushi
a366aa6249
Rollup merge of #68040 - sinkuu:unused, r=petrochenkov
Cleanup
2020-01-10 04:18:42 +09:00
Mazdak Farrokhzad
69b1e5cc3d {rustc::util -> rustc_data_structures}::captures 2020-01-09 08:57:24 +01:00
John Kåre Alsaker
5427601e9e Change -Z time event naming scheme and make them generic activities 2020-01-09 07:06:40 +01:00
Shotaro Yamada
dbcce10bb1 Remove unused struct ClosureUpvar 2020-01-09 11:47:32 +09:00
Mazdak Farrokhzad
ea9a03dbb8
Rollup merge of #67986 - JohnTitor:fix-ice-rust-call, r=varkor
Display more informative ICE

Fixes #66696
2020-01-09 00:22:13 +01:00
Mazdak Farrokhzad
60bef14bbc
Rollup merge of #67630 - oli-obk:extern_ptr_dangling, r=spastorino
Treat extern statics just like statics in the "const pointer to static" representation

fixes #67612

r? @spastorino

cc @RalfJung this does not affect runtime promotion at all. This is just about promotion within static item bodies.
2020-01-09 00:22:05 +01:00
Yuki Okushi
b85b1dd465
Rollup merge of #67781 - cjgillot:passes-const, r=oli-obk
Move `is_min_const_fn` query to librustc_mir.

The only two uses of the associated methods are in `librustc_mir` and
`librustdoc`. Please tell me if there is a better choice.

cc #65031
2020-01-09 00:29:08 +09:00
Camille GILLOT
c1c09bee29 Move is_min_const_fn query to librustc_mir.
The only two uses of the associated methods are in librustc_mir and
librustdoc. Please tell me if there is a better choice.
2020-01-08 10:37:37 +01:00
Camille GILLOT
588296adfe Move constness.rs to librustc_mir. 2020-01-08 10:22:04 +01:00
Yuki Okushi
c524f3ca98 Display more informative ICE 2020-01-08 17:12:19 +09:00
Mazdak Farrokhzad
2c3e5d3de0 - remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
2020-01-08 04:25:33 +01:00
Camille GILLOT
f629baf96c Move magic traits queries to rustc::traits::drop. 2020-01-07 18:14:32 +01:00
Camille GILLOT
86ec4b5f85 Move required_region_bounds to rustc::infer::opaque_types. 2020-01-07 18:08:47 +01:00
Camille GILLOT
24d09c7c1b Move free_region_map to rustc::ty. 2020-01-07 18:07:36 +01:00
Camille GILLOT
e905d5da93 Move structural_match to rustc::traits. 2020-01-07 18:07:08 +01:00
Camille GILLOT
73667af444 Move ty::wf to traits. 2020-01-07 18:03:53 +01:00
Camille GILLOT
787cd5493a Make traits::util::* free functions. 2020-01-07 17:48:41 +01:00
Camille GILLOT
56a0aec07f Move subst_and_normalize_erasing_regionsto rustc::ty. 2020-01-07 17:47:49 +01:00
Camille GILLOT
a80bff87c1 Move normalize_erasing_regions to rustc::ty. 2020-01-07 17:46:23 +01:00
Camille GILLOT
7118e33bfd Remove private methods from TyCtxt impl block: rustc::ty::print::pretty. 2020-01-07 17:42:13 +01:00
Camille GILLOT
640cae257b Remove private methods from TyCtxt impl block: rustc::ty::outlives. 2020-01-07 17:41:23 +01:00
Camille GILLOT
0d9f4fb270 Remove trivial function. 2020-01-07 17:40:31 +01:00
Yuki Okushi
318d6c259d
Rollup merge of #67909 - varkor:obsolete-const-print, r=davidtwco
Fix ICE in const pretty printing and resolve FIXME

Consts now have a `fmt::Display` impl, so we can just use that to pretty-print.

This resolves an ICE in https://github.com/rust-lang/rust/issues/61936, though it hits more ICEs afterwards. I couldn't find a test case that was resolved by this that didn't hit errors later on.
2020-01-07 13:46:08 +09:00
bors
ebbb2bf37a Auto merge of #67886 - Centril:rustc_hir_canon_imports, r=nagisa
Nix `rustc_hir` reexports in rustc::hir

r? @Zoxc cc @Mark-Simulacrum
2020-01-06 12:55:40 +00:00
varkor
8f94d9bb08 Fix ICE in const pretty printing and resolve FIXME
Consts now have a `fmt::Display` impl, so we can just use that to pretty-print.
2020-01-06 00:11:27 +00:00
Aaron Hill
db2c4f214f
Fix typo 2020-01-05 15:00:55 -05:00