rust/src/libsyntax
Mazdak Farrokhzad b864d23f34
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
2020-02-18 22:16:26 +01:00
..
ast libsyntax: Unconfigure tests during normal build 2019-08-02 01:59:01 +03:00
attr 1. move allow_internal_unstable to rustc_attr 2020-02-01 18:58:08 +01:00
expand Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
util parser: fuse free fn parsing together. 2020-02-13 10:39:24 +01:00
ast.rs Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov 2020-02-18 22:16:26 +01:00
build.rs Remove licenses 2018-12-25 21:08:33 -07:00
Cargo.toml 1. move allow_internal_unstable to rustc_attr 2020-02-01 18:58:08 +01:00
entry.rs Normalize syntax::symbol imports. 2020-01-02 13:57:04 +01:00
lib.rs Auto merge of #68708 - Mark-Simulacrum:stage0-step, r=pietroalbini 2020-02-04 14:16:18 +00:00
mut_visit.rs Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov 2020-02-18 22:16:26 +01:00
node_id.rs 1. move node_id to syntax 2020-02-01 18:58:08 +01:00
ptr.rs Format the world 2019-12-22 17:42:47 -05:00
README.md rustc-guide has moved 2018-11-26 15:03:13 -06:00
token.rs parser: fuse free fn parsing together. 2020-02-13 10:39:24 +01:00
tokenstream.rs Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
visit.rs Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov 2020-02-18 22:16:26 +01:00

The syntax crate contains those things concerned purely with syntax that is, the AST ("abstract syntax tree"), parser, pretty-printer, lexer, macro expander, and utilities for traversing ASTs.

For more information about how these things work in rustc, see the rustc guide: