796 Commits

Author SHA1 Message Date
Camille GILLOT
8284035372 Fallout in other crates. 2019-12-26 23:38:46 +01:00
bors
3e0a1c0910 Auto merge of #67592 - matthewjasper:cleanup-match, r=Centril
Prepare for lowering or-patterns

This is probably best reviewed commit-by-commit.

* Rustfmt `rustc_mir::build::{self, matches}`
* Remove `-Znll-dont-emit-read-for-match`
* Split `match_expr` into smaller functions
* Feature gate or-patterns in const contexts

cc https://github.com/rust-lang/rust/issues/54883

r? @Centril
2019-12-26 16:44:52 +00:00
Matthew Jasper
f1758a043f Feature gate or patterns in const contexts 2019-12-25 09:13:15 +00:00
Esteban Küber
66ea471f9d Handle more specific case E0222 2019-12-24 22:10:15 -08:00
Mark Rousskov
6891388e66 x.py fmt after previous deignore 2019-12-24 17:38:22 -05:00
varkor
35979a92bf Add span information to ExprKind::Assign 2019-12-23 11:20:13 +00:00
varkor
a5991c57cf Add the full issue reference to equality constraints in where clauses 2019-12-23 11:15:55 +00:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Camille GILLOT
9694ab9e18 Use Arena inside hir::Body. 2019-12-21 23:39:19 +01:00
Camille GILLOT
42c03e4bb4 Use Arena inside hir::Mod. 2019-12-21 23:34:34 +01:00
Camille GILLOT
e2526120f2 Use Arena inside hir::StructField. 2019-12-21 23:33:42 +01:00
Camille GILLOT
4f1c88be46 Use Arena inside hir::EnumDef. 2019-12-21 23:32:42 +01:00
Camille GILLOT
5fec1ca0ff Use Arena inside hir::ImplItem. 2019-12-21 23:31:47 +01:00
Camille GILLOT
0f7d77363b Use Arena inside hir::TraitItem. 2019-12-21 23:30:52 +01:00
Camille GILLOT
acf33f2d6b Use Arena inside hir::ForeignItem. 2019-12-21 23:29:27 +01:00
Camille GILLOT
abbe6259e1 Handle Attributes in arena. 2019-12-21 23:20:09 +01:00
Camille GILLOT
084e6722f9 Use Arena inside hir::Item. 2019-12-21 23:17:29 +01:00
Camille GILLOT
4dc79f1f7d Use Arena inside hir::Crate. 2019-12-21 23:12:44 +01:00
Mazdak Farrokhzad
a7aec3f207 1. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.
2. mir::Mutability -> ast::Mutability.
2019-12-20 22:22:44 +01:00
Mazdak Farrokhzad
ec82174fad
Rollup merge of #67131 - Centril:item-merge, r=petrochenkov
Merge `TraitItem` & `ImplItem into `AssocItem`

In this PR we:

- Merge `{Trait,Impl}Item{Kind?}` into `AssocItem{Kind?}` as discussed in https://github.com/rust-lang/rust/issues/65041#issuecomment-538105286.

   - This is done by using the cover grammar of both forms.

   - In particular, it requires that we syntactically allow (under `#[cfg(FALSE)]`):

      - `default`ness on `trait` items,

      - `impl` items without a body / definition (`const`, `type`, and `fn`),

      - and associated `type`s in `impl`s with bounds, e.g., `type Foo: Ord;`.

   - The syntactic restrictions are replaced by semantic ones in `ast_validation`.

- Move syntactic restrictions around C-variadic parameters from the parser into `ast_validation`:

    - `fn`s in all contexts now syntactically allow `...`,

    - `...` can occur anywhere in the list syntactically (`fn foo(..., x: usize) {}`),

    - and `...` can be the sole parameter (`fn foo(...) {}`.

r? @petrochenkov
2019-12-20 17:22:19 +01:00
Dylan MacKenzie
34ce0ba919 Use better name for local containing required feature gates 2019-12-13 10:39:15 -08:00
Dylan MacKenzie
80581be2c0 Replace Index impl with enabled method 2019-12-13 10:39:15 -08:00
Dylan MacKenzie
2b5ae1cb06 Apply suggestions from review 2019-12-13 10:39:14 -08:00
Dylan MacKenzie
a8e997c819 Improve comment 2019-12-13 10:39:14 -08:00
Dylan MacKenzie
ee233c07c6 Restructue HIR const-checker to handle features with multiple gates 2019-12-13 10:38:29 -08:00
Mazdak Farrokhzad
e52f902a8a AssocImplKind::{Method -> Fn}. 2019-12-12 18:05:05 +01:00
Mazdak Farrokhzad
abf2e7aa95 Remove ast::{Impl,Trait}{Item,ItemKind}. 2019-12-12 18:05:05 +01:00
Mazdak Farrokhzad
35e9e097e7 More c-variadic errors as semantic restrictions. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
3a57a2cca4 ast_validation: move trait item logic to proper place. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
0d41d0fe14 Move allow_c_varadic logic to ast_validation. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
b499a88dfc Unify assoc item visitors more. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
0d8a9d74e3 Unify associated item visitor. 2019-12-12 18:00:00 +01:00
Mazdak Farrokhzad
34d91709b6 parse: refactor fun ret ty & param ty 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
39073767a4 Unify {Trait,Impl}ItemKind::TyAlias structures. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
f6403c6c76 Use Option in ImplItemKind::Method. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
73557faed2 Use Option in ImplItemKind::Const. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
c4bbe9cbbe Alias TraitItem & ImplItem.
Allow defaultness on trait items syntactically.
2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
1b2a422f0a Simplify check_decl_no_pat. 2019-12-07 06:13:08 +01:00
Vadim Petrochenkov
0fac56717a syntax: Remove redundant span from ast::Mac
Also remove a couple of redundant `visit_mac` asserts
2019-12-02 21:56:34 +03:00
Mazdak Farrokhzad
79077f13ff move GateIssue to rustc_feature & simplify emit_feature_err 2019-11-30 07:40:28 +01:00
Mazdak Farrokhzad
d04b838a44 move is_builtin_attr to syntax::attr 2019-11-30 02:20:07 +01:00
Mazdak Farrokhzad
3d080a4a77 introduce crate rustc_feature and move active, accepted, and removed to it 2019-11-30 00:25:40 +01:00
Tyler Mandry
bb6236cd74
Rollup merge of #66754 - estebank:rustdoc-capitalization, r=Dylan-DPC
Various tweaks to diagnostic output
2019-11-26 17:56:19 -06:00
Esteban Küber
5ef47160e8 Tweak bad continue error 2019-11-25 13:30:52 -08:00
Matthew Jasper
a8efd31f2b Add raw address of expressions to the AST and HIR 2019-11-24 18:06:13 +00:00
bors
6d523ee501 Auto merge of #66507 - ecstatic-morse:const-if-match, r=oli-obk
Enable `if` and `match` in constants behind a feature flag

This PR is an initial implementation of #49146. It introduces a `const_if_match` feature flag and does the following if it is enabled:
- Allows `Downcast` projections, `SwitchInt` terminators and `FakeRead`s for matched places through the MIR const-checker.
- Allows `if` and `match` expressions through the HIR const-checker.
- Stops converting `&&` to `&` and `||` to `|` in `const` and `static` items.

As a result, the following operations are now allowed in a const context behind the feature flag:
- `if` and `match`
- short circuiting logic operators (`&&` and `||`)
- the `assert` and `debug_assert` macros (if the `const_panic` feature flag is also enabled)

However, the following operations remain forbidden:
- `while`, `loop` and `for` (see #52000)
- the `?` operator (calls `From::from` on its error variant)
- the `assert_eq` and `assert_ne` macros, along with their `debug` variants (calls `fmt::Debug`)

This PR is possible now that we use dataflow for const qualification (see #64470 and #66385).

r? @oli-obk
cc @rust-lang/wg-const-eval @eddyb
2019-11-23 01:13:41 +00: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
Dylan MacKenzie
ccb6e9884e Suggest const_if_match on nightly 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
365d123689 Add feature gate for const if and match 2019-11-21 14:19:59 -08:00