]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 18 Feb 2020 21:16:26 +0000 (22:16 +0100)
committerGitHub <noreply@github.com>
Tue, 18 Feb 2020 21:16:26 +0000 (22:16 +0100)
commitb864d23f3484aad297e998f3cd50a4277122d070
tree0a2343b3fe8b7d622cee5fef9971b261daaa079c
parent981acd90353b40e9529de0eda21ba5b4071134d5
parent045b7d53a3fe94d2f6cb32d029a3f5d74e174ed9
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
17 files changed:
src/librustc_ast_lowering/lib.rs
src/librustc_ast_passes/ast_validation.rs
src/librustc_ast_passes/feature_gate.rs
src/librustc_ast_pretty/pprust.rs
src/librustc_builtin_macros/deriving/generic/mod.rs
src/librustc_builtin_macros/test.rs
src/librustc_expand/build.rs
src/librustc_interface/util.rs
src/librustc_lint/builtin.rs
src/librustc_parse/parser/item.rs
src/librustc_resolve/late.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/sig.rs
src/libsyntax/ast.rs
src/libsyntax/mut_visit.rs
src/libsyntax/visit.rs