about summary refs log tree commit diff
path: root/src/librustc_expand/mbe
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-3248/+0
2020-08-18Promote missing_fragment_specifier to hard errorAleksey Kladov-32/+14
It has been deny_by_default since 2017 (and warned for some time before that), so it seems reasonable to promote it. The specific technical motivation to do this now is to remove a field from `ParseSess` -- it is a global state, and global state makes extracting libraries annoying. Closes #40107
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-4/+4
2020-08-15replaced log with tracingGurpreet Singh-1/+1
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-21/+31
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-02Use NonterminalKind for MetaVarDeclAleksey Kladov-131/+69
This is more type safe and allows us to remove a few dead branches
2020-08-02Introduce NonterminalKindAleksey Kladov-203/+20
It encapsulate the (part of) the interface between the parser and macro by example (macro_rules) parser. The second bit is somewhat more general `parse_ast_fragment`, which is the reason why we keep some `parse_xxx` functions as public.
2020-07-02Auto merge of #73954 - Manishearth:rollup-8qvh170, r=Manishearthbors-2/+2
Rollup of 10 pull requests Successful merges: - #73414 (Implement `slice_strip` feature) - #73564 (linker: Create GNU_EH_FRAME header by default when producing ELFs) - #73622 (Deny unsafe ops in unsafe fns in libcore) - #73684 (add spans to injected coverage counters, extract with CoverageData query) - #73812 (ast_pretty: Pass some token streams and trees by reference) - #73853 (Add newline to rustc MultiSpan docs) - #73883 (Compile rustdoc less often.) - #73885 (Fix wasm32 being broken due to a NodeJS version bump) - #73903 (Changes required for rustc/cargo to build for iOS targets) - #73938 (Optimise fast path of checked_ops with `unlikely`) Failed merges: r? @ghost
2020-07-01Rollup merge of #73569 - Aaron1011:fix/macro-rules-group, r=petrochenkovManish Goregaokar-47/+64
Handle `macro_rules!` tokens consistently across crates When we serialize a `macro_rules!` macro, we used a 'lowered' `TokenStream` for its body, which has all `Nonterminal`s expanded in-place via `nt_to_tokenstream`. This matters when an 'outer' `macro_rules!` macro expands to an 'inner' `macro_rules!` macro - the inner macro may use tokens captured from the 'outer' macro in its definition. This means that invoking a foreign `macro_rules!` macro may use a different body `TokenStream` than when the same `macro_rules!` macro is invoked in the same crate. This difference is observable by proc-macros invoked by a `macro_rules!` macro - a `None`-delimited group will be seen in the same-crate case (inserted when convering `Nonterminal`s to the `proc_macro` crate's structs), but no `None`-delimited group in the cross-crate case. To fix this inconsistency, we now insert `None`-delimited groups when 'lowering' a `Nonterminal` `macro_rules!` body, just as we do in `proc_macro_server`. Additionally, we no longer print extra spaces for `None`-delimited groups - as far as pretty-printing is concerned, they don't exist (only their contents do). This ensures that `Display` output of a `TokenStream` does not depend on which crate a `macro_rules!` macro was invoked from. This PR is necessary in order to patch the `solana-genesis-programs` for the upcoming hygiene serialization breakage (https://github.com/rust-lang/rust/pull/72121#issuecomment-646924847). The `solana-genesis-programs` crate will need to use a proc macro to re-span certain tokens in a nested `macro_rules!`, which requires us to consistently use a `None`-delimited group. See `src/test/ui/proc-macro/nested-macro-rules.rs` for an example of the kind of nested `macro_rules!` affected by this crate.
2020-07-01Handle `None`-delimited groups when parsing `macro_rules!` macroAaron Hill-47/+63
When a `macro_rules!` macro expands to another `macro_rules!` macro, we may see `None`-delimited groups in odd places when another crate deserializes the 'inner' macro. This commit 'unwraps' an outer `None`-delimited group to avoid breaking existing code. See https://github.com/rust-lang/rust/pull/73569#issuecomment-650860457 for more details. The proper fix is to handle `None`-delimited groups systematically throughout the parser, but that will require significant work. In the meantime, this hack lets us fix important hygiene bugs in macros
2020-07-01Insert NoDelim groups around nonterminals when lowering macro_rulesAaron Hill-0/+1
2020-07-01Remove `token::FlattenGroup`Vadim Petrochenkov-9/+6
2020-06-27ast_pretty: Pass some token streams and trees by referenceVadim Petrochenkov-2/+2
2020-06-26proc_macro: Stop flattening groups with dummy spansVadim Petrochenkov-7/+10
2020-06-15Always capture tokens for `macro_rules!` argumentsAaron Hill-4/+25
2020-06-09expand: Give reasonable NodeIds to lints associated with macro definitionsVadim Petrochenkov-13/+24
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-14/+12
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-2/+4
2020-04-04macro_rules: `NtLifetime` cannot start with an identifierVadim Petrochenkov-1/+1
2020-03-30Use if let instead of match when only matching a single variant ↵Matthias Krüger-13/+12
(clippy::single_match) Makes code more compact and reduces nestig.
2020-03-27suggest semi on expr mac!() good as stmt mac!().Mazdak Farrokhzad-1/+18
2020-03-25Rename `def_span` to `guess_head_span`Esteban Küber-1/+1
2020-03-24expand: address review commentsMazdak Farrokhzad-18/+11
2020-03-24expand: add recovery for parse_ntMazdak Farrokhzad-16/+19
2020-03-24defatalize `compile_declarative_macro`Mazdak Farrokhzad-16/+32
2020-03-24mbe::transcribe: defatalize errors.Mazdak Farrokhzad-13/+22
2020-03-24generic_extension: defatalize Error caseMazdak Farrokhzad-1/+5
2020-03-24nix panictry! in ParserAnyMacro::makeMazdak Farrokhzad-31/+46
2020-03-21parse: nix unused `root_module_name`.Mazdak Farrokhzad-2/+0
2020-03-20can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.Mazdak Farrokhzad-1/+1
2020-03-18parser/expand: minor cleanupMazdak Farrokhzad-2/+2
2020-03-18outline modules: parse -> expand.Mazdak Farrokhzad-25/+12
2020-03-16Make macro metavars respect (non-)hygieneMatthew Jasper-24/+33
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-2/+2
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-09Address review commentsVadim Petrochenkov-4/+1
2020-03-09rustc_parse: Use `Token::ident` where possibleVadim Petrochenkov-12/+6
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-03Improve weird formatting by moving comment inside else-code block.Matthias Krüger-3/+3
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-15/+15
2020-02-29use .copied() instead of .map(|x| *x) on iteratorsMatthias Krüger-1/+1
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-4/+3
example: let s: String = format!("hello").into();
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-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-1/+1
Transition macro_legacy_warnings into a hard error Fixes https://github.com/rust-lang/rust/issues/67098. r? @petrochenkov