diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-18 22:16:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-18 22:16:26 +0100 |
| commit | b864d23f3484aad297e998f3cd50a4277122d070 (patch) | |
| tree | 0a2343b3fe8b7d622cee5fef9971b261daaa079c /src/librustc_interface | |
| parent | 981acd90353b40e9529de0eda21ba5b4071134d5 (diff) | |
| parent | 045b7d53a3fe94d2f6cb32d029a3f5d74e174ed9 (diff) | |
Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov
parse: fuse associated and extern items up to defaultness
Language changes:
- The grammar of extern `type` aliases is unified with associated ones, and becomes:
```rust
TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ;
```
Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`).
(Work still remains to fuse this with free `type` aliases, but this can be done later.)
- The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes:
```rust
GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ;
```
- A semantic restriction is added to enforce the presence of the expression (the body).
- A semantic restriction is added to reject `const _` in associated contexts.
Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR.
-----------------------
We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s.
r? @petrochenkov
Diffstat (limited to 'src/librustc_interface')
| -rw-r--r-- | src/librustc_interface/util.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 72abfa15a1f..99e9878bfd8 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -686,7 +686,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> { fn flat_map_trait_item(&mut self, i: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> { let is_const = match i.kind { ast::AssocItemKind::Const(..) => true, - ast::AssocItemKind::Fn(ref sig, _) => Self::is_sig_const(sig), + ast::AssocItemKind::Fn(ref sig, _, _) => Self::is_sig_const(sig), _ => false, }; self.run(is_const, |s| noop_flat_map_assoc_item(i, s)) |
