about summary refs log tree commit diff
path: root/src/librustc_expand
AgeCommit message (Collapse)AuthorLines
2020-03-16Other `legacy` -> `macro_rules`Vadim Petrochenkov-6/+6
2020-03-16ast/hir: `MacroDef::legacy` -> `MacroDef::macro_rules`Vadim Petrochenkov-5/+5
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-49/+60
2020-03-10Store `TokenStream` in `rmeta::MacroDef`.Mazdak Farrokhzad-3/+3
This removes a hack from `load_macro_untracked` in which parsing is used.
2020-03-10builtin_macros: Add attribute macro `#[cfg_accessible(path)]`Vadim Petrochenkov-0/+1
2020-03-10expand: Implement support for retrying macro expansionsVadim Petrochenkov-51/+121
2020-03-09expand/builtin_macros: Minor cleanupVadim Petrochenkov-10/+3
2020-03-09Address review commentsVadim Petrochenkov-4/+1
2020-03-09rustc_parse: Use `Token::ident` where possibleVadim Petrochenkov-12/+6
2020-03-07Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkovMazdak Farrokhzad-1/+1
fix various typos
2020-03-06bless testsMatthias Krüger-1/+1
2020-03-06rustc_expand: Factor out `Annotatable::into_tokens` to a separate methodVadim Petrochenkov-32/+32
2020-03-06fix various typosMatthias Krüger-2/+2
2020-03-06Auto merge of #69586 - petrochenkov:unmerge, r=Centrilbors-3/+4
ast: Unmerge structures for associated items and foreign items Follow-up to https://github.com/rust-lang/rust/pull/69194. r? @Centril
2020-03-03Improve weird formatting by moving comment inside else-code block.Matthias Krüger-3/+3
2020-03-01ast: Unmerge structures for associated items and foreign itemsVadim Petrochenkov-3/+4
2020-03-01Rollup merge of #69580 - matthiaskrgr:map_clone, r=CentrilYuki Okushi-1/+1
use .copied() instead of .map(|x| *x) on iterators
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-67/+67
2020-02-29Make it build againVadim Petrochenkov-1/+1
2020-02-29use .copied() instead of .map(|x| *x) on iteratorsMatthias Krüger-1/+1
2020-02-28Rollup merge of #69541 - dotdash:format, r=Mark-SimulacrumMazdak Farrokhzad-4/+3
Remove unneeded calls to format!()
2020-02-28Rollup merge of #69522 - Centril:fix-69341, r=petrochenkovMazdak Farrokhzad-4/+3
error_derive_forbidden_on_non_adt: be more graceful Fixes #69341 which was injected by #67052. r? @petrochenkov
2020-02-28Rollup merge of #69481 - matthiaskrgr:single_char, r=ecstatic-morseMazdak Farrokhzad-2/+2
use char instead of &str for single char patterns
2020-02-28Rollup merge of #69384 - petrochenkov:nounnorm, r=CentrilMazdak Farrokhzad-2/+7
parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token` So, after https://github.com/rust-lang/rust/pull/69006, its follow-ups and an attempt to remove `Parser::prev_span` I came to the conclusion that the unnormalized token and its span is what you want in most cases, so it should be default. Normalization only makes difference in few cases where we are checking against `token::Ident` or `token::Lifetime` specifically. This PR uses `normalized_token` for those cases. Using normalization explicitly means that people writing code should remember about `NtIdent` and `NtLifetime` in general. (That is alleviated by the fact that `token.ident()` and `fn parse_ident_*` are already written.) Remembering about `NtIdent`, was, however, already the case, kind of, because the implicit normalization was performed only for the current/previous token, but not for things like `look_ahead`. As a result, most of token classification methods in `token.rs` already take `NtIdent` into account (this PR fixes a few pre-existing minor mistakes though). The next step is removing `normalized(_prev)_token` entirely and replacing it with `token.ident()` (mostly) and `token.normalize()` (occasionally). I want to make it a separate PR for that and run it though perf. `normalized_token` filled on every bump has both a potential to avoid repeated normalization, and to do unnecessary work in advance (it probably doesn't matter anyway, the normalization is very cheap). r? @Centril
2020-02-27don't use .into() to convert types into identical types.Matthias Krüger-11/+6
example: let s: String = format!("hello").into();
2020-02-27error_derive_forbidden_on_non_adt: be more gracefulMazdak Farrokhzad-4/+3
2020-02-27Remove unneeded calls to format!()Björn Steinbrink-4/+3
2020-02-27use char instead of &str for single char patternsMatthias Krüger-2/+2
2020-02-24syntax: Remove `Nt(Impl,Trait,Foreign)Item`Vadim Petrochenkov-3/+8
2020-02-24parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`Vadim Petrochenkov-2/+1
2020-02-24Add some missing support for `NtIdent`Vadim Petrochenkov-0/+6
2020-02-24parse/ast: move `Defaultness` into variants.Mazdak Farrokhzad-8/+2
2020-02-24parser: tweak item kind wordingMazdak Farrokhzad-2/+2
2020-02-24parse: use `parse_item_common` in `parse_assoc_item_`.Mazdak Farrokhzad-4/+4
2020-02-24parse: use `parse_item_common` in `parse_foreign_item`.Mazdak Farrokhzad-2/+2
2020-02-24ast: add `Defaultness` to `Item`, making `AssocItem` an alias.Mazdak Farrokhzad-0/+5
2020-02-23Auto merge of #69084 - yaahc:delayed-doc-lint, r=petrochenkovbors-0/+12
Split non macro portion of unused_doc_comment from macro part into two passes/lints ## Motivation This change is motivated by the needs of the [spandoc library](https://github.com/yaahc/spandoc). The specific use case is that my macro is removing doc comments when an attribute is applied to a fn with doc comments, but I would like the lint to still appear when I forget to add the `#[spandoc]` attribute to a fn, so I don't want to have to silence the lint globally. ## Approach This change splits the `unused _doc_comment` lint into two lints, `unused_macro_doc_comment` and `unused_doc_comment`. The non macro portion is moved into an `early_lint_pass` rather than a pre_expansion_pass. This allows proc macros to silence `unused_doc_comment` warnings by either adding an attribute to silence it or by removing the doc comment before the early_pass runs. The `unused_macro_doc_comment` lint however will still be impossible for proc-macros to silence, but the only alternative that I can see is to remove this lint entirely, which I don't think is acceptable / is a decision I'm not comfortable making personally, so instead I opted to split the macro portion of the check into a separate lint so that it can be silenced globally with an attribute if necessary without needing to globally silence the `unused_doc_comment` lint as well, which is still desireable. fixes https://github.com/rust-lang/rust/issues/67838
2020-02-21rustfmt you cruel mistressJane Lusby-2/+3
2020-02-21clean things upJane Lusby-1/+7
2020-02-18Rollup merge of #69211 - petrochenkov:prevtok, r=CentrilMazdak Farrokhzad-3/+0
parser: Simplify treatment of macro variables in `Parser::bump` Follow-up to https://github.com/rust-lang/rust/pull/69006. Token normalization for `$ident` and `$lifetime` is merged directly into `bump`. Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling (as a result `bump` also doesn't call itself recursively anymore and can't make `prev_token` inconsistent). r? @Centril
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-5/+2
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-17parser: Do not call `bump` recursivelyVadim Petrochenkov-3/+0
Token normalization is merged directly into `bump`. Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling.
2020-02-17Auto merge of #69129 - Centril:macro-legacy-errors, r=petrochenkovbors-8/+5
Transition macro_legacy_warnings into a hard error Fixes https://github.com/rust-lang/rust/issues/67098. r? @petrochenkov
2020-02-17Rollup merge of #69186 - petrochenkov:kwrules, r=CentrilYuki Okushi-3/+3
[tiny] parser: `macro_rules` is a weak keyword r? @Centril
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-2/+2
2020-02-15ast: make `= <expr>;` optional in free statics/consts.Mazdak Farrokhzad-2/+2
2020-02-15ast: move Generics into AssocItemKindsMazdak Farrokhzad-3/+0
2020-02-15parser: `macro_rules` is a weak keywordVadim Petrochenkov-3/+3
2020-02-15Emit some additional `unused_doc_comments` lints outside of the main passVadim Petrochenkov-0/+5
2020-02-15Rollup merge of #69150 - nnethercote:68848-follow-up, r=petrochenkovYuki Okushi-17/+15
Follow-up to #68848 This PR contains some late changes to #68848 that somehow didn't get included when that PR was merged in a roll-up. r? @petrochenkov