about summary refs log tree commit diff
path: root/src/librustc_expand
AgeCommit message (Collapse)AuthorLines
2020-05-28standardize limit comparisons with `Limit` typeDavid Wood-5/+6
This commit introduces a `Limit` type which is used to ensure that all comparisons against limits within the compiler are consistent (which can result in ICEs if they aren't). Signed-off-by: David Wood <david@davidtw.co>
2020-05-24Collect tokens for `ast::Expr`Aaron Hill-2/+10
2020-05-22Remove `macro_defs` mapAaron Hill-1/+10
We store store the `DefId` directly in `ExpnData`. This will allow us to serialize `ExpnData` in PR #72121 without needing to manage a side table.
2020-05-19Auto merge of #68717 - petrochenkov:stabexpat, r=varkorbors-31/+0
Stabilize fn-like proc macros in expression, pattern and statement positions I.e. all the positions in which stable `macro_rules` macros are supported. Depends on https://github.com/rust-lang/rust/pull/68716 ("Stabilize `Span::mixed_site`"). cc https://github.com/rust-lang/rust/issues/54727 cc https://github.com/rust-lang/rust/issues/54727#issuecomment-580647446 Stabilization report: https://github.com/rust-lang/rust/pull/68717#issuecomment-623197503.
2020-05-17Rollup merge of #72233 - dtolnay:literal, r=petrochenkovDylan DPC-3/+8
Fix {:#?} representation of proc_macro::Literal Before: ```rust TokenStream [ Ident { ident: "name", span: #0 bytes(37..41), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(42..43), }, Literal { lit: Lit { kind: Str, symbol: "SNPP", suffix: None }, span: Span { lo: BytePos(44), hi: BytePos(50), ctxt: #0 } }, Punct { ch: ',', spacing: Alone, span: #0 bytes(50..51), }, Ident { ident: "owner", span: #0 bytes(56..61), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(62..63), }, Literal { lit: Lit { kind: Str, symbol: "Canary M Burns", suffix: None }, span: Span { lo: BytePos(64), hi: BytePos(80), ctxt: #0 } }, ] ``` After: ```rust TokenStream [ Ident { ident: "name", span: #0 bytes(37..41), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(42..43), }, Literal { kind: Str, symbol: "SNPP", suffix: None, span: #0 bytes(44..50), }, Punct { ch: ',', spacing: Alone, span: #0 bytes(50..51), }, Ident { ident: "owner", span: #0 bytes(56..61), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(62..63), }, Literal { kind: Str, symbol: "Canary M Burns", suffix: None, span: #0 bytes(64..80), }, ] ```
2020-05-15Fix {:#?} representation of proc_macro::LiteralDavid Tolnay-3/+8
Before: TokenStream [ Ident { ident: "name", span: #0 bytes(37..41), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(42..43), }, Literal { lit: Lit { kind: Str, symbol: "SNPP", suffix: None }, span: Span { lo: BytePos(44), hi: BytePos(50), ctxt: #0 } }, Punct { ch: ',', spacing: Alone, span: #0 bytes(50..51), }, Ident { ident: "owner", span: #0 bytes(56..61), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(62..63), }, Literal { lit: Lit { kind: Str, symbol: "Canary M Burns", suffix: None }, span: Span { lo: BytePos(64), hi: BytePos(80), ctxt: #0 } }, ] After: TokenStream [ Ident { ident: "name", span: #0 bytes(37..41), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(42..43), }, Literal { kind: Str, symbol: "SNPP", suffix: None, span: #0 bytes(44..50), }, Punct { ch: ',', spacing: Alone, span: #0 bytes(50..51), }, Ident { ident: "owner", span: #0 bytes(56..61), }, Punct { ch: '=', spacing: Alone, span: #0 bytes(62..63), }, Literal { kind: Str, symbol: "Canary M Burns", suffix: None, span: #0 bytes(64..80), }, ]
2020-05-14cleanup stale FIXME(#64197)sergey-melnychuk-2/+2
2020-05-08Fix testsCamille GILLOT-9/+9
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-81/+60
2020-05-03Stabilize fn-like proc macros in expression, pattern and statement positionsVadim Petrochenkov-31/+0
2020-05-03Implement `confusable_idents` lint.Charles Lew-4/+5
2020-04-24Avoid unused Option::map resultsJosh Stone-4/+4
These are changes that would be needed if we add `#[must_use]` to `Option::map`, per #71484.
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-2/+5
2020-04-18Move `MapInPlace` to rustc_data_structuresYuki Okushi-2/+2
2020-04-14Remove unused single_step flagMark Rousskov-5/+1
This appears to have never been used ever since its introduction in 61c7569d4 -- the plugin discussed on the PR introducing that commit, 34811, never materialized. It's also simple to readd in the current scheme, but given that macro expansion is already quite complicated, additional useless state seems good to remove while we're not using it.
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-28Auto merge of #70261 - Centril:angle-args-partition, r=varkorbors-1/+2
Move arg/constraint partition check to validation & improve recovery - In the first commit, we move the check rejecting e.g., `<'a, Item = u8, String>` from the parser into AST validation. - We then use this to improve the code for parsing generic arguments. - And we add recovery for e.g., `<Item = >` (missing), `<Item = 42>` (constant), and `<Item = 'a>` (lifetime). This is also preparatory work for supporting https://github.com/rust-lang/rust/issues/70256. r? @varkor
2020-03-27parse: move constraint/arg restriction to ast_validation.Mazdak Farrokhzad-1/+2
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-24expand: nix unused methodMazdak Farrokhzad-4/+1
2020-03-24defatalize `compile_declarative_macro`Mazdak Farrokhzad-16/+32
2020-03-24mbe::transcribe: defatalize errors.Mazdak Farrokhzad-29/+22
2020-03-24remove ExtCxt::struct_span_warnMazdak Farrokhzad-3/+2
2020-03-24defatalize ProcMacroDerive::expandMazdak Farrokhzad-20/+8
Also remove ExtCtxt::struct_span_fatal.
2020-03-24defatalize AttrProcMacro::expandMazdak Farrokhzad-18/+16
2020-03-24defatalize BangProcMacro::expandMazdak Farrokhzad-19/+27
2020-03-24generic_extension: defatalize Error caseMazdak Farrokhzad-1/+5
2020-03-24nix remaining rustc_expand::panictry! uses.Mazdak Farrokhzad-20/+1
2020-03-24nix panictry! in ParserAnyMacro::makeMazdak Farrokhzad-32/+47
2020-03-24rustc_expand::base: nix panictry! usesMazdak Farrokhzad-4/+16
2020-03-22parse: nix new_sub_parser_from_fileMazdak Farrokhzad-2/+2
2020-03-21parse: nix unused `root_module_name`.Mazdak Farrokhzad-5/+2
2020-03-21Rollup merge of #69497 - Zoxc:ast-fragment-error, r=petrochenkovDylan DPC-4/+14
Don't unwind when hitting the macro expansion recursion limit This removes one use of `FatalError.raise()`. r? @petrochenkov
2020-03-20can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.Mazdak Farrokhzad-1/+1
2020-03-19Don't unwind when hitting the macro expansion recursion limitJohn Kåre Alsaker-4/+14
2020-03-18fix pre-expansion linting infraMazdak Farrokhzad-3/+18
2020-03-18tweak outline module parsing spansMazdak Farrokhzad-24/+25
2020-03-18parser/expand: minor cleanupMazdak Farrokhzad-2/+2
2020-03-18{rustc_parse -> rustc_expand}::configMazdak Farrokhzad-2/+536
2020-03-18{rustc_parse::parser -> rustc_expand}::moduleMazdak Farrokhzad-4/+308
2020-03-18move Directory -> parser::moduleMazdak Farrokhzad-3/+5
2020-03-18outline modules: parse -> expand.Mazdak Farrokhzad-56/+58
2020-03-18expand: use push_directoryMazdak Farrokhzad-7/+7
2020-03-17Rollup merge of #68746 - matthewjasper:metahygiene, r=petrochenkovMazdak Farrokhzad-24/+33
Make macro metavars respect (non-)hygiene This makes them more consistent with other name resolution while not breaking any code on crater.
2020-03-17Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasperMazdak Farrokhzad-60/+124
expand: Implement something similar to `#[cfg(accessible(path))]` cc https://github.com/rust-lang/rust/issues/64797 The feature is implemented as a `#[cfg_accessible(path)]` attribute macro rather than as `#[cfg(accessible(path))]` because it needs to wait until `path` becomes resolvable, and `cfg` cannot wait, but macros can wait. Later we can think about desugaring or not desugaring `#[cfg(accessible(path))]` into `#[cfg_accessible(path)]`. This implementation is also incomplete in the sense that it never returns "false" from `cfg_accessible(path)`, it requires some tweaks to resolve, which is not quite ready to answer queries like this during early resolution. However, the most important part of this PR is not `cfg_accessible` itself, but expansion infrastructure for retrying expansions. Before this PR we could say "we cannot resolve this macro path, let's try it later", with this PR we can say "we cannot expand this macro, let's try it later" as well. This is a pre-requisite for - turning `#[derive(...)]` into a regular attribute macro, - properly supporting eager expansion for macros that cannot yet be resolved like ``` fn main() { println!(not_available_yet!()); } macro_rules! make_available { () => { #[macro_export] macro_rules! not_available_yet { () => { "Hello world!" } }} } make_available!(); ```
2020-03-16Make macro metavars respect (non-)hygieneMatthew Jasper-24/+33