about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-118/+90
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-17ast: add a FIXMEMazdak Farrokhzad-0/+2
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-13/+12
2020-02-15ast: tweak AssocItemKind::Macro commentMazdak Farrokhzad-1/+1
2020-02-15Add additional commentAaron Hill-0/+6
2020-02-15Record proc macro harness order for use during metadata deserializationAaron Hill-3/+4
Fixes #68690 When we generate the proc macro harness, we now explicitly recorder the order in which we generate entries. We then use this ordering data to deserialize the correct proc-macro-data from the crate metadata.
2020-02-15visit: unify extern & assoc item visitingMazdak Farrokhzad-58/+40
2020-02-15ast: make ForeignItemKind an alias of AssocItemKindMazdak Farrokhzad-30/+3
2020-02-15parse extern constsMazdak Farrokhzad-2/+7
2020-02-15parse associated statics.Mazdak Farrokhzad-2/+4
2020-02-15ast/parser: fuse `static` & `const` grammars in all contexts.Mazdak Farrokhzad-3/+9
2020-02-15ast: make `= <expr>;` optional in free statics/consts.Mazdak Farrokhzad-9/+5
2020-02-15ast: normalize `ForeignItemKind::Ty` & `AssocItemKind::TyAlias`.Mazdak Farrokhzad-4/+12
2020-02-15ast: tweak comments of Foreign/AssocItemKindMazdak Farrokhzad-13/+10
2020-02-15ast: colocate AssocItem with ForeignItemMazdak Farrokhzad-39/+39
2020-02-15ast: move Generics into AssocItemKindsMazdak Farrokhzad-10/+11
2020-02-13parser: fuse free `fn` parsing together.Mazdak Farrokhzad-3/+7
2020-02-13IsAsync -> enum Async { Yes { span: Span, .. }, No }Mazdak Farrokhzad-18/+18
use new span for better diagnostics.
2020-02-13Constness -> enum Const { Yes(Span), No }Mazdak Farrokhzad-50/+18
Same idea for `Unsafety` & use new span for better diagnostics.
2020-02-05parser: merge `fn` grammars wrt. bodies & headersMazdak Farrokhzad-78/+80
also refactor `FnKind` and `visit_assoc_item` visitors
2020-02-04Auto merge of #68708 - Mark-Simulacrum:stage0-step, r=pietroalbinibors-1/+0
Step stage0 to bootstrap from 1.42 This also includes a commit which fixes the rustfmt downloading logic to redownload when the rustfmt channel changes, and bumps rustfmt to a more recent version.
2020-02-01syntax: reexport attr globalsMazdak Farrokhzad-0/+1
2020-02-01syntax::print -> new crate rustc_ast_prettyMazdak Farrokhzad-3540/+5
2020-02-011. move allow_internal_unstable to rustc_attrMazdak Farrokhzad-25/+0
2. as a result, drop rustc_errors dep from syntax
2020-02-011. move node_id to syntaxMazdak Farrokhzad-14/+50
2. invert rustc_session & syntax deps 3. drop rustc_session dep in rustc_hir
2020-02-01Move builtin attribute logic to new rustc_attr crate.Mazdak Farrokhzad-1052/+0
For now, this is all the crate contains, but more attribute logic & types will be moved there over time.
2020-02-01syntax: simplify HasAttrs codeMazdak Farrokhzad-21/+11
2020-02-01pretty: remove ParseSess dependencyMazdak Farrokhzad-20/+13
2020-02-01syntax: move GLOBALS to attr moduleMazdak Farrokhzad-37/+34
2020-02-01{syntax -> rustc_ast_passes}::node_countMazdak Farrokhzad-140/+0
2020-01-31Drop cfg(bootstrap) codeMark Rousskov-1/+0
2020-01-31Auto merge of #67340 - nnethercote:shrink-Nonterminal, r=petrochenkovbors-17/+22
Shrink `Nonterminal` These commits shrink `Nonterminal` from 240 bytes to 40 bytes. When building `serde_derive` they reduce the number of `memcpy` calls from 9.6M to 7.4M, and it's a tiny win on a few other benchmarks. r? @petrochenkov
2020-01-30clarify "incorrect issue" errorAndy Russell-21/+34
2020-01-30Use `P` for `NtMeta`.Nicholas Nethercote-3/+4
This commit reduces the size of `Nonterminal` from a 72 bytes to 40 bytes (on x86-64).
2020-01-30Use `P` for `NtTraitItem`, `NtImplItem`, and `NtForeignItem`.Nicholas Nethercote-15/+19
This commit reduces the size of `Nonterminal` from a whopping 240 bytes to 72 bytes (on x86-64), which gets it below the `memcpy` threshold. It also removes some impedance mismatches with `Annotatable`, which already uses `P` for these variants.
2020-01-26Suggest defining type parameter when appropriateEsteban Küber-0/+14
``` error[E0412]: cannot find type `T` in this scope --> file.rs:3:12 | 3 | impl Trait<T> for Struct {} | - ^ not found in this scope | | | help: you might be missing a type parameter: `<T>` ``` Fix #64298.
2020-01-23unused-parens: implement for block return valuesTyler Lanphear-5/+1
2020-01-22Rollup merge of #68441 - Centril:pprust-as_deref, r=Mark-SimulacrumTyler Mandry-2/+2
pprust: use as_deref Some drive-by cleanup.
2020-01-22pprust: use as_derefMazdak Farrokhzad-2/+2
2020-01-21Rollup merge of #68140 - ecstatic-morse:const-trait-bound-opt-out, r=oli-obkMazdak Farrokhzad-22/+32
Implement `?const` opt-out for trait bounds For now, such bounds are treated exactly the same as unprefixed ones in all contexts. [RFC 2632](https://github.com/rust-lang/rfcs/pull/2632) does not specify whether such bounds are forbidden outside of `const` contexts, so they are allowed at the moment. Prior to this PR, the constness of a trait bound/impl was stored in `TraitRef`. Now, the constness of an `impl` is stored in `ast::ItemKind::Impl` and the constness of a bound in `ast::TraitBoundModifer`. Additionally, constness of trait bounds is now stored in an additional field of `ty::Predicate::Trait`, and the combination of the constness of the item along with any `TraitBoundModifier` determines the constness of the bound in accordance with the RFC. Encoding the constness of impls at the `ty` level is left for a later PR. After a discussion in \#wg-grammar on Discord, it was decided that the grammar should not encode the mutual exclusivity of trait bound modifiers. The grammar for trait bound modifiers remains `[?const] [?]`. To encode this, I add a dummy variant to `ast::TraitBoundModifier` that is used when the syntax `?const ?` appears. This variant causes an error in AST validation and disappears during HIR lowering. cc #67794 r? @oli-obk
2020-01-20Parse `?const ?Trait`Dylan MacKenzie-0/+5
2020-01-20Add `constness` field to `ty::Predicate::Trait`Dylan MacKenzie-1/+2
2020-01-20Revert "Add a `constness` field to `ast::TraitRef`"Dylan MacKenzie-19/+4
This reverts commit fd4a6a12136c5b5d6bce4081e95890df1fd1febd.
2020-01-20Add `MaybeConst` variant to `{ast,hir}::TraitBoundModifier`Dylan MacKenzie-2/+9
2020-01-19Add `constness` field to `ast::ItemKind::Impl`Dylan MacKenzie-0/+12
2020-01-20Rollup merge of #68353 - Centril:code-liberation, r=petrochenkovDylan DPC-3/+0
Remove `rustc_error_codes` deps except in `rustc_driver` Remove dependencies on `rustc_error_codes` in all crates except for `rustc_driver`. This has some benefits: 1. Adding a new error code when hacking on the compiler only requires rebuilding at most `rustc_error_codes`, `rustc_driver`, and the reflexive & transitive closure of the crate where the new error code is being added and its reverse dependencies. This improves time-to-UI-tests (TTUT). 2. Adding an error description to an error code only requires rebuilding `rustc_error_codes` and `rustc_driver`. This should substantially improve TTUT. r? @petrochenkov cc @rust-lang/wg-diagnostics
2020-01-18remove rustc_error_codes deps except in rustc_driverMazdak Farrokhzad-3/+0
2020-01-18slice_patterns: remove internal uses of gateMazdak Farrokhzad-1/+1
2020-01-17Use named fields for `ast::ItemKind::Impl`Dylan MacKenzie-25/+44
2020-01-14Code review changes and fix rustdoc test.Ben Lewis-33/+6