about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-3/+2
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
2016-06-28cleanup: use `DummyResult` to implement `MacroGenerable::dummy`Jeffrey Seyfried-0/+4
2016-06-26Rollup merge of #34339 - jseyfried:thin_vec, r=petrochenkov,ManishearthJeffrey Seyfried-1/+1
Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`.
2016-06-26Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddybJeffrey Seyfried-8/+10
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26Rollup merge of #34385 - cgswords:tstream, r=nrcJeffrey Seyfried-12/+16
syntax-[breaking-change] cc #31645 (Only breaking because ast::TokenTree is now tokenstream::TokenTree.) This pull request refactors TokenTrees into their own file as src/libsyntax/tokenstream.rs, moving them out of src/libsyntax/ast.rs, in order to prepare for an accompanying TokenStream implementation (per RFC 1566).
2016-06-25Rollup merge of #34403 - jonathandturner:move_liberror, r=alexcrichtonJeffrey Seyfried-2/+2
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes. As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
2016-06-25Rollup merge of #34213 - josephDunne:trait_item_macros, r=jseyfriedJeffrey Seyfried-0/+18
**syntax-[breaking-change]** cc #31645 New `TraitItemKind::Macro` variant This change adds support for macro expansion inside trait items by adding the new `TraitItemKind::Macro` and associated parsing code.
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-2/+2
2016-06-23Auto merge of #34253 - jseyfried:improve_multi_modifiers, r=nrcbors-27/+32
Allow `MultiItemModifier`s to expand into zero or many items Fixes #34223. r? @nrc
2016-06-21Refactored tokentrees into their own files in preparation for tokenstreams. ↵cgswords-12/+16
Modified tests to point to the new file now.
2016-06-18Auto merge of #34295 - jseyfried:cfg_decoration, r=eddybbors-0/+10
Perform `cfg` attribute processing on decorator-generated items Fixes https://users.rust-lang.org/t/unused-attribute-warning-for-custom-derive-attribute/6180. r? @nrc
2016-06-19Generalize and abstract `ThinAttributes`Jeffrey Seyfried-1/+1
2016-06-17Fix falloutJeffrey Seyfried-8/+10
2016-06-16Simplify gated cfg checkingJeffrey Seyfried-4/+0
2016-06-16Auto merge of #34239 - jseyfried:fix_macro_use_scope_regression, r=nrcbors-1/+1
Revert a change in the scope of macros imported from crates to fix a regression Fixes #34212. The regression was caused by #34032, which changed the scope of macros imported from extern crates to match the scope of macros imported from modules. r? @nrc
2016-06-16Strip unconfigured nodes from decorator-generated ASTJeffrey Seyfried-0/+10
2016-06-16Allow `MultiItemModifier`s to expand into zero or many itemsJeffrey Seyfried-11/+13
2016-06-16Implement `HasAttrs` for `Annotatable`Jeffrey Seyfried-16/+19
2016-06-13Auto merge of #33749 - jseyfried:fix_call_site_span, r=nrcbors-16/+0
Fix macro call site spans Fix macro call site spans. r? @nrc
2016-06-13Add support for macro expansion inside trait itemsJoseph Dunne-0/+18
2016-06-12Load macros from `#[macro_use]` crates earlier in expansionJeffrey Seyfried-1/+1
2016-06-09Add comment and clean up `expand_annotatable`Jeffrey Seyfried-0/+2
2016-06-09Load macros from `extern crate`s during expansion.Jeffrey Seyfried-1/+20
2016-05-28Fix macro call site spansJeffrey Seyfried-16/+0
2016-05-02replace fileline_{help,note} with {help,note}Niko Matsakis-4/+3
The extra filename and line was mainly there to keep the indentation relative to the main snippet; now that this doesn't include filename/line-number as a prefix, it is distracted.
2016-03-02Fix the search paths for macro-expanded non-inline modulesJeffrey Seyfried-0/+8
2016-02-16Add check on find_best_match_for_name and improve help message for undefined ↵ggomez-1/+6
macro
2016-02-13Rename ast::Pat_ and its variantsVadim Petrochenkov-3/+3
2016-02-11Remove some unnecessary indirection from AST structuresVadim Petrochenkov-16/+16
2016-02-11[breaking-change] don't glob export ast::Item_ variantsOliver 'ker' Schneider-1/+1
2016-02-11[breaking-change] don't pub export ast::Stmt_ variantsOliver Schneider-3/+3
2016-02-11[breaking-change] don't pub export ast::Lit_ variantsOliver Schneider-2/+2
2016-02-11[breaking-change] don't pub export ast::Ty_ variantsOliver Schneider-1/+1
2016-02-11[breaking-change] don't glob export ast::Expr_ variantsOliver Schneider-3/+3
2015-12-31Cut out a bunch of Result and panictry! boilerplate from libsyntax.Nick Cameron-1/+1
[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2015-12-30use structured errorsNick Cameron-11/+25
2015-12-23Auto merge of #30377 - Wafflespeanut:levenshtein, r=Manishearthbors-10/+3
fixes part of #30197
2015-12-17move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*Nick Cameron-1/+1
Also split out emitters into their own module.
2015-12-16Modify the Levenshtein-based suggestions to include importsRavi Shankar-10/+3
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-29/+0
2015-12-13remove deprecated APIs missed in #30182Tamir Duberstein-7/+0
2015-12-04Auto merge of #29850 - Kimundi:attributes_that_make_a_statement, r=pnkfelixbors-3/+4
See https://github.com/rust-lang/rfcs/pull/16 and https://github.com/rust-lang/rust/issues/15701 - Added syntax support for attributes on expressions and all syntax nodes in statement position. - Extended `#[cfg]` folder to allow removal of statements, and of expressions in optional positions like expression lists and trailing block expressions. - Extended lint checker to recognize lint levels on expressions and locals. - As per RFC, attributes are not yet accepted on `if` expressions. Examples: ```rust let x = y; { ... } assert_eq!((1, #[cfg(unset)] 2, 3), (1, 3)); let FOO = 0; ``` Implementation wise, there are a few rough corners and open questions: - The parser work ended up a bit ugly. - The pretty printer change was based mostly on guessing. - Similar to the `if` case, there are some places in the grammar where a new `Expr` node starts, but where it seemed weird to accept attributes and hence the parser doesn't. This includes: - const expressions in patterns - in the middle of an postfix operator chain (that is, after `.`, before indexing, before calls) - on range expressions, since `#[attr] x .. y` parses as `(#[attr] x) .. y`, which is inconsistent with `#[attr] .. y` which would parse as `#[attr] (.. y)` - Attributes are added as additional `Option<Box<Vec<Attribute>>>` fields in expressions and locals. - Memory impact has not been measured yet. - A cfg-away trailing expression in a block does not currently promote the previous `StmtExpr` in a block to a new trailing expr. That is to say, this won't work: ```rust let x = { #[cfg(foo)] Foo { data: x } #[cfg(not(foo))] Foo { data: y } }; ``` - One-element tuples can have their inner expression removed to become Unit, but just Parenthesis can't. Eg, `(#[cfg(unset)] x,) == ()` but `(#[cfg(unset)] x) == error`. This seemed reasonable to me since tuples and unit are type constructors, but could probably be argued either way. - Attributes on macro nodes are currently unconditionally dropped during macro expansion, which seemed fine since macro disappear at that point? - Attributes on `ast::ExprParens` will be prepend-ed to the inner expression in the hir folder. - The work on pretty printer tests for this did trigger, but not fix errors regarding macros: - expression `foo![]` prints as `foo!()` - expression `foo!{}` prints as `foo!()` - statement `foo![];` prints as `foo!();` - statement `foo!{};` prints as `foo!();` - statement `foo!{}` triggers a `None` unwrap ICE.
2015-11-27Introduce max_suggestion_distance function to avoid duplicating the heuristicFlorian Hartwig-4/+2
2015-11-26Added stmt_expr_attribute feature gateMarvin Löbel-3/+3
2015-11-26Add syntax support for attributes on expressions and all syntaxMarvin Löbel-0/+1
nodes in statement position. Extended #[cfg] folder to allow removal of statements, and of expressions in optional positions like expression lists and trailing block expressions. Extended lint checker to recognize lint levels on expressions and locals.
2015-11-26Add '!' to macro name suggestion, use fileline_help instead of span_helpFlorian Hartwig-1/+1
2015-11-26Add suggestion of similar macro names to `macro undefined` error messageFlorian Hartwig-0/+17
2015-11-24Auto merge of #30000 - Manishearth:unreachable-call, r=nrcbors-2/+2
Fixes #1889
2015-11-24Fix unreachable code in libsyntaxManish Goregaokar-2/+2
2015-11-23Auto merge of #29952 - petrochenkov:depr, r=brsonbors-1/+1
Part of https://github.com/rust-lang/rust/issues/29935 The deprecation lint is still called "deprecated", so people can continue using `#[allow(deprecated)]` and similar things.