about summary refs log tree commit diff
path: root/compiler/rustc_expand/src
AgeCommit message (Collapse)AuthorLines
2020-10-19Fix brace problem in panic message in rustc_expand.Mara Bos-1/+2
2020-10-14Remove unused code from remaining compiler cratesest31-111/+0
2020-10-07Detect blocks that could be struct expr bodiesEsteban Küber-2/+2
This approach lives exclusively in the parser, so struct expr bodies that are syntactically correct on their own but are otherwise incorrect will still emit confusing errors, like in the following case: ```rust fn foo() -> Foo { bar: Vec::new() } ``` ``` error[E0425]: cannot find value `bar` in this scope --> src/file.rs:5:5 | 5 | bar: Vec::new() | ^^^ expecting a type here because of type ascription error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> src/file.rs:5:15 | 5 | bar: Vec::new() | ^^^^^ only `Fn` traits may use parentheses error[E0107]: wrong number of type arguments: expected 1, found 0 --> src/file.rs:5:10 | 5 | bar: Vec::new() | ^^^^^^^^^^ expected 1 type argument ``` If that field had a trailing comma, that would be a parse error and it would trigger the new, more targetted, error: ``` error: struct literal body without path --> file.rs:4:17 | 4 | fn foo() -> Foo { | _________________^ 5 | | bar: Vec::new(), 6 | | } | |_^ | help: you might have forgotten to add the struct literal inside the block | 4 | fn foo() -> Foo { Path { 5 | bar: Vec::new(), 6 | } } | ``` Partially address last part of #34255.
2020-10-02Improve E0777 help messageGuillaume Gomez-4/+13
2020-10-01Import struct_span_err macro instead of prepending itGuillaume Gomez-2/+2
2020-10-01Create E0777 error code for "invalid literal in derive"Guillaume Gomez-4/+9
2020-09-28expand: Minor fn ptr call cleanupVadim Petrochenkov-3/+3
2020-09-28expand: Stop un-interpolating `NtIdent`s before passing them to built-in macrosVadim Petrochenkov-25/+2
This was a big hack, and built-in macros should be able to deal with `NtIdents` in the input by themselves like any other parser code.
2020-09-17Remove redundant #![feature(...)] 's from compiler/est31-1/+0
2020-09-16Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-SimulacrumDylan DPC-2/+2
Detect overflow in proc_macro_server subspan * Detect overflow in proc_macro_server subspan * Add tests for overflow in Vec::drain * Add tests for overflow in String / VecDeque operations using ranges
2020-09-10Attach tokens to `ast::Stmt`Aaron Hill-7/+25
We currently only attach tokens when parsing a `:stmt` matcher for a `macro_rules!` macro. Proc-macro attributes on statements are still unstable, and need additional work.
2020-09-10Attach `TokenStream` to `ast::Visibility`Aaron Hill-8/+27
A `Visibility` does not have outer attributes, so we only capture tokens when parsing a `macro_rules!` matcher
2020-09-10Attach `TokenStream` to `ast::Path`Aaron Hill-2/+2
2020-09-10Attach tokens to `NtMeta` (`ast::AttrItem`)Aaron Hill-0/+1
An `AttrItem` does not have outer attributes, so we only capture tokens when parsing a `macro_rules!` matcher
2020-09-10Attach `TokenStream` to `ast::Ty`Aaron Hill-5/+10
A `Ty` does not have outer attributes, so we only capture tokens when parsing a `macro_rules!` matcher
2020-09-10Attach `TokenStream` to `ast::Block`Aaron Hill-1/+7
A `Block` does not have outer attributes, so we only capture tokens when parsing a `macro_rules!` matcher
2020-09-10Syntactically permit unsafety on modsDavid Tolnay-10/+31
2020-09-10Auto merge of #76291 - matklad:spacing, r=petrochenkovbors-8/+8
Rename IsJoint -> Spacing Builds on #76286 and might conflict with #76285 r? `@petrochenkov`
2020-09-10Revert "Rollup merge of #76285 - matklad:censor-spacing, r=petrochenkov"Tyler Mandry-17/+5
This reverts commit 85cee57fd791d670d92dc61e0ad71594128dd45a, reversing changes made to b4d387302416c90a3f70211770292d8d8ab5e07d.
2020-09-09Auto merge of #76406 - GuillaumeGomez:create-e0774, r=pickfire,jyn514bors-3/+6
Create E0774
2020-09-09Rollup merge of #76355 - calebcartwright:reduce-rustfmt-visibility, ↵Dylan DPC-2/+1
r=nikomatsakis remove public visibility previously needed for rustfmt `submod_path_from_attr` in rustc_expand::module was previously public because it was also consumed by rustfmt. However, we've done a bit of refactoring in rustfmt and no longer need to use this function. This changes the visibility to the parent mod as was originally going to be done before the rustfmt dependency was realized (https://github.com/rust-lang/rust/commit/c189565edc5c9fc516170885b3a3061b936205fb#diff-cd1b379893bae95f7991d5a3f3c6d337R201)
2020-09-08Create new E0774 code errorGuillaume Gomez-3/+6
2020-09-04rustc_expand: remove pub visibility for rustfmtCaleb Cartwright-2/+1
2020-09-04Detect overflow in proc_macro_server subspanTomasz Miąsko-2/+2
2020-09-03Optimize Cursor::look_aheadAleksey Kladov-3/+8
Cloning a tt is cheap, but not free (there's Arc inside).
2020-09-03Rename IsJoint -> SpacingAleksey Kladov-8/+8
To match better naming from proc-macro
2020-09-03Move jointness censoring to proc_macroAleksey Kladov-4/+11
Proc-macro API currently exposes jointness in `Punct` tokens. That is, `+` in `+one` is **non** joint. Our lexer produces jointness info for all tokens, so we need to censor it *somewhere* Previously we did this in a lexer, but it makes more sense to do this in a proc-macro server.
2020-09-02Auto merge of #76170 - matklad:notrivia, r=petrochenkovbors-1/+1
Remove trivia tokens r? @ghost
2020-09-01Rollup merge of #76132 - Aaron1011:mac-call-stmt, r=petrochenkovTyler Mandry-4/+8
Factor out StmtKind::MacCall fields into `MacCallStmt` struct In PR #76130, I add a fourth field, which makes using a tuple variant somewhat unwieldy.
2020-09-01Auto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkovbors-4/+7
Run cfg-stripping on generic parameters before invoking derive macros Fixes #75930 This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute on a generic paramter is unusual, and combining it with a proc-macro derive is probably even more unusual. I don't expect this to cause any breakage.
2020-09-01Remove trivia tokensAleksey Kladov-1/+1
2020-08-31Rollup merge of #76050 - matklad:pos, r=petrochenkovAleksey Kladov-257/+0
Remove unused function
2020-08-30Add `-Z proc-macro-backtrace` to allow showing proc-macro panicsAaron Hill-19/+24
Fixes #75050 Previously, we would unconditionally suppress the panic hook during proc-macro execution. This commit adds a new flag -Z proc-macro-backtrace, which allows running the panic hook for easier debugging.
2020-08-30Factor out StmtKind::MacCall fields into `MacCallStmt` structAaron Hill-4/+8
In PR #76130, I add a fourth field, which makes using a tuple variant somewhat unwieldy.
2020-08-30Move lexer unit tests to rustc_lexerAleksey Kladov-257/+0
StringReader is an intornal abstraction which at the moment changes a lot, so these unit tests cause quite a bit of friction. Moving them to rustc_lexer and more ingerated-testing style should make them much less annoying, hopefully without decreasing their usefulness much. Note that coloncolon tests are removed (it's unclear what those are testing). \r\n tests are removed as well, as we normalize line endings even before lexing.
2020-08-30Run cfg-stripping on generic parameters before invoking derive macrosAaron Hill-4/+7
Fixes #75930 This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute on a generic paramter is unusual, and combining it with a proc-macro derive is probably even more unusual. I don't expect this to cause any breakage.
2020-08-30mv compiler to compiler/mark-0/+11065