summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2018-04-30Remove new enum variant from #50092 backportPietro Albini-9/+0
ExpansionKind::ForeignItems was added in #49350, which is not included in the 1.26 beta.
2018-04-30Warn on pointless `#[derive]` in more placesAustin Bonander-13/+85
This fixes the regression in #49934 and ensures that unused `#[derive]`s on statements, expressions and generic type parameters survive to trip the `unused_attributes` lint. For `#[derive]` on macro invocations it has a hardcoded warning since linting occurs after expansion. This also adds regression testing for some nodes that were already warning properly. closes #49934
2018-04-02Expand attribute macros on statements and expressions.Austin Bonander-19/+78
Retains the `stmt_expr_attributes` feature requirement for attributes on expressions. closes #41475 cc #38356
2018-03-27Auto merge of #49279 - varkor:generated-closure-return-type, r=alexcrichtonbors-5/+5
Fix implicit closure return type generation for libsyntax The `lambda` function for constructing closures in libsyntax was explicitly setting the return type to `_`, which resulted in incorrect corresponding syntax (as `|| -> _ x` is not valid, without the enclosing brackets). This meant the generated code, when printed, was invalid. I also took the opportunity to slightly improve the generated code for the `RustcEncodable::encode` method for unit structs. Fixes #42213.
2018-03-22Use FunctionRetTy::Default rather than an explicit TyKind::Infer for ↵varkor-5/+5
lambda-building This prevents explicit `-> _` return type annotations for closures generated by `lambda`.
2018-03-22Clean up raw identifier handling when recovering tokens from AST.Lymia Aluysia-3/+4
2018-03-18Return a is_raw parameter from Token::ident rather than having separate methods.Lymia Aluysia-4/+4
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-21/+24
2018-03-18Auto merge of #48917 - petrochenkov:import, r=oli-obkbors-13/+16
syntax: Make imports in AST closer to the source and cleanup their parsing This is a continuation of https://github.com/rust-lang/rust/pull/45846 in some sense.
2018-03-17Rename `Span::empty` to `Span::shrink_to_lo`, add `Span::shrink_to_hi`Vadim Petrochenkov-4/+4
2018-03-17AST: Keep distinction between `path` and `::path` in imports and visibilitiesVadim Petrochenkov-3/+7
Add the root segment for name resolution purposes only
2018-03-17AST: Make renames in imports closer to the sourceVadim Petrochenkov-6/+5
Fix `unused_import_braces` lint false positive on `use prefix::{self as rename}`
2018-03-17Reject `_` in `ident` matcherVadim Petrochenkov-17/+19
2018-03-17syntax: Make `_` an identifierVadim Petrochenkov-3/+1
2018-03-16Auto merge of #48524 - abonander:check-macro-stability, r=petrochenkovbors-17/+56
check stability of macro invocations I haven't implemented tests yet but this should be a pretty solid prototype. I think as-implemented it will also stability-check macro invocations in the same crate, dunno if we want that or not. I don't know if we want this to go through `rustc::middle::stability` or not, considering the information there wouldn't be available at the time of macro expansion (even for external crates, right?). r? @nrc closes #34079 cc @petrochenkov @durka @jseyfried #38356
2018-03-13Fix ICE on malformed plugin attributesMichael Lamparski-2/+4
2018-03-07check stability of macro invocationsAustin Bonander-17/+56
2018-03-05Turn features() into a query.Michael Woerister-17/+15
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-24/+27
2018-02-28Auto merge of #48056 - ExpHP:macro-commas, r=dtolnaybors-2/+4
Comprehensively support trailing commas in std/core macros I carefully organized the changes into four commits: * Test cases * Fixes for `macro_rules!` macros * Fixes for builtin macros * Docs for builtins **I can easily scale this back to just the first two commits for now if such is desired.** ### Breaking (?) changes * This fixes #48042, which is a breaking change that I hope people can agree is just a bugfix for an extremely dark corner case. * To fix five of the builtins, this changes `syntax::ext::base::get_single_str_from_tts` to accept a trailing comma, and revises the documentation so that this aspect is not surprising. **I made this change under the (hopefully correct) understanding that `libsyntax` is private rustc implementation detail.** After reviewing all call sites (which were, you guessed it, *precisely those five macros*), I believe the revised semantics are closer to the intended spirit of the function. ### Changes which may require concensus Up until now, it could be argued that some or all the following macros did not conceptually take a comma-separated list, because they only took one argument: * **`cfg(unix,)`** (most notable since cfg! is unique in taking a meta tag) * **`include{,_bytes,_str}("file.rs",)`** (in item form this might be written as "`include!{"file.rs",}`" which is even slightly more odd) * **`compile_error("message",);`** * **`option_env!("PATH",)`** * **`try!(Ok(()),)`** So I think these particular changes may require some sort of consensus. **All of the fixes for builtins are included this list, so if we want to defer these decisions to later then I can scale this PR back to just the first two commits.** ### Other notes/general requests for comment * Do we have a big checklist somewhere of "things to do when adding macros?" My hope is for `run-pass/macro-comma-support.rs` to remain comprehensive. * Originally I wanted the tests to also comprehensively forbid double trailing commas. However, this didn't work out too well: [see this gist and the giant FIXME in it](https://gist.github.com/ExpHP/6fc40e82f3d73267c4e590a9a94966f1#file-compile-fail_macro-comma-support-rs-L33-L50) * I did not touch `select!`. It appears to me to be a complete mess, and its trailing comma mishaps are only the tip of the iceberg. * There are [some compile-fail test cases](https://github.com/ExpHP/rust/blob/5fa97c35da2f0ee/src/test/compile-fail/macro-comma-behavior.rs#L49-L52) that didn't seem to work (rustc emits errors, but compile-fail doesn't acknowledge them), so they are disabled. Any clues? (Possibly related: These happen to be precisely the set of errors which are tagged by rustc as "this error originates in a macro outside of the current crate".) --- Fixes #48042 Closes #46241
2018-02-24Rollup merge of #48143 - nikomatsakis:termination_trait_in_tests, r=eddybManish Goregaokar-7/+3
Termination trait in tests Support the `Termination` trait in unit tests (cc https://github.com/rust-lang/rust/issues/43301) Also, a drive-by fix for #47075. This is joint work with @bkchr.
2018-02-22begin crate-relative paths with `crate`Niko Matsakis-7/+3
2018-02-18Replace dummy spans with empty spansSeiichi Uchida-5/+5
2018-02-18Change ast::Visibility to Spanned typeSeiichi Uchida-7/+16
2018-02-11Auto merge of #47752 - mark-i-m:at-most-once-rep, r=nikomatsakisbors-53/+171
Implement `?` macro repetition See rust-lang/rfcs#2298 (with disposition merge)
2018-02-07libsyntax/ext: trailing commas in builtin macrosMichael Lamparski-2/+4
Most notably this changes 'syntax::ext::base::get_single_str_from_tts' to accept a trailing comma, and revises the documentation so that this aspect is not surprising. I made this change under the understanding that this crate is private rustc implementation detail (I hope this is correct!). After reviewing all call sites, I believe the revised semantics are closer to the intended spirit of the function.
2018-01-30Update a few commentsMark Mansi-1/+4
2018-01-30stabilize match_beginning_vertJonathan Goodman-1/+0
2018-01-30Fix trailing whitespaceMark Mansi-1/+1
2018-01-30Improved tests + typo fixes + assertMark Mansi-0/+2
2018-01-30Add feature gate + testsMark Mansi-10/+68
2018-01-30Fix typo in error message + update testsMark Mansi-1/+1
2018-01-30Attempted fix for `?` kleene opMark Mansi-23/+21
2018-01-30Run rustfmt on macro_parser.rsMark Mansi-4/+6
2018-01-30Run rustfmt on quoted.rsMark Mansi-10/+21
2018-01-30Update the macro parser to allow at most once repetitions for `?` KleeneMark Mansi-16/+22
2018-01-30Allow `?` as a KleeneOp in the macro parserMark Mansi-46/+84
2018-01-30Rollup merge of #47732 - mark-i-m:markim_comments_0001, r=jseyfriedkennytm-126/+351
Run rustfmt and add doc comments to libsyntax/ext/tt/macro_parser.rs Similar to #47603 cc @theotherphil since you reviewed my other PR :smile: And because they are already assigned on #47603: r? @arielb1
2018-01-30Rollup merge of #47603 - mark-i-m:markim_comments_0000, r=jseyfriedkennytm-39/+173
Run rustfmt and add doc comments to libsyntax/ext/tt/quoted.rs I was already going to try to understand this code to try to implement rust-lang/rfcs#2298. I figured I would put that knowledge into comments and share... This PR contains _no changes_ to the code itself -- just formatting and comments. I'm not sure what the best way to do this is. I plan to make more such PR for other files, but I figured it would have fewer conflicts if I do it file by file...
2018-01-29fix typosMark Mansi-4/+4
2018-01-29Update commentMark Mansi-1/+2
2018-01-26A few more commentsMark Mansi-0/+8
2018-01-26Still more commentsMark Mansi-2/+26
2018-01-26Added/improved commentsMark Mansi-17/+61
2018-01-26Added lots of comments + minor reorganizationMark Mansi-34/+94
2018-01-26Added a bunch of comments to macro_parser.rsMark Mansi-10/+62
2018-01-26Run rustfmt on /libsyntax/ext/tt/macro_parser.rsMark Mansi-78/+114
2018-01-26Do not capture stderr in the compiler. Instead just panic silently for fatal ↵John Kåre Alsaker-9/+10
errors
2018-01-23Adds support for immovable generators. Move checking of invalid borrows ↵John Kåre Alsaker-1/+6
across suspension points to borrowck. Fixes #44197, #45259 and #45093.
2018-01-21Fix typosMark Mansi-3/+3