summary refs log tree commit diff
path: root/src/libsyntax/fold.rs
AgeCommit message (Collapse)AuthorLines
2017-01-25Auto merge of #35712 - oli-obk:exclusive_range_patterns, r=nikomatsakisbors-2/+12
exclusive range patterns adds `..` patterns to the language under a feature gate (`exclusive_range_pattern`). This allows turning ``` rust match i { 0...9 => {}, 10...19 => {}, 20...29 => {}, _ => {} } ``` into ``` rust match i { 0..10 => {}, 10..20 => {}, 20..30 => {}, _ => {} } ```
2017-01-23Remove `open_span` and `close_span` from `Delimited`.Jeffrey Seyfried-2/+0
2017-01-19add exclusive range patterns under a feature gateOliver Schneider-2/+12
2017-01-17Auto merge of #39110 - petrochenkov:sum, r=eddybbors-13/+8
Merge ObjectSum and PolyTraitRef in AST/HIR + some other refactoring `ObjectSum` and `PolyTraitRef` are the same thing (list of bounds), they exist separately only due to parser quirks. The second commit merges them. The first commit replaces `Path` with `Ty` in (not yet supported) equality predicates. They are parsed as types anyway and arbitrary types can always be disguised as paths using aliases, so this doesn't add any new functionality. The third commit uses `Vec` instead of `P<[T]>` in AST. AST is not immutable like HIR and `Vec`s are more convenient for it, unnecessary conversions are also avoided. The last commit renames `parse_ty_sum` (which is used for parsing types in general) into `parse_ty`, and renames `parse_ty` (which is used restricted contexts where `+` is not permitted due to operator priorities or other reasons) into `parse_ty_no_plus`. This is the first part of https://github.com/rust-lang/rust/issues/39085#issuecomment-272743755 and https://github.com/rust-lang/rust/issues/39080 focused on data changes and mechanical renaming, I'll submit a PR with parser changes a bit later. r? @eddyb
2017-01-17Rename ObjectSum into TraitObject in AST/HIRVadim Petrochenkov-2/+2
2017-01-17Use resizable Vec instead of P<[T]> in ASTVadim Petrochenkov-3/+2
2017-01-17AST/HIR: Merge ObjectSum and PolyTraitRefVadim Petrochenkov-6/+2
2017-01-16AST/HIR: Replace Path with Type in WhereEqPredicateVadim Petrochenkov-4/+4
2017-01-16Rename ExprKind::Vec to Array in HIR and HAIR.Scott Olson-2/+2
This is a clearer name since they represent [a, b, c] array literals.
2017-01-12Auto merge of #38814 - Ralith:cfg-fields, r=jseyfriedbors-0/+2
syntax: enable attributes and cfg on struct fields This enables conditional compilation of field initializers in a struct literal, simplifying construction of structs whose fields are themselves conditionally present. For example, the intializer for the constant in the following becomes legal, and has the intuitive effect: ```rust struct Foo { #[cfg(unix)] bar: (), } const FOO: Foo = Foo { #[cfg(unix)] bar: (), }; ``` It's not clear to me whether this calls for the full RFC process, but the implementation was simple enough that I figured I'd begin the conversation with code.
2017-01-11syntax: struct field attributes and cfgBenjamin Saunders-0/+2
2017-01-03Fold all spans in the AST.Jeffrey Seyfried-7/+7
2016-12-25Auto merge of #38566 - jseyfried:fix_import_resolution_bug, r=eddybbors-15/+14
Fix bug in import resolution Fixes #38535 and fixes #38556. r? @nrc
2016-12-23Fix import resolution bug and fold all idents in the AST.Jeffrey Seyfried-15/+14
2016-12-22Refactor how global paths are represented (for both ast and hir).Jeffrey Seyfried-2/+1
2016-12-19Optimize `ast::PathSegment`.Jeffrey Seyfried-1/+1
2016-11-21Implement the `loop_break_value` feature.Geoffry Song-4/+5
This implements RFC 1624, tracking issue #37339. - `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the currently deduced type of that loop, the desired type, and a list of break expressions currently seen. `loop` loops get a fresh type variable as their initial type (this logic is stolen from that for arrays). `while` loops get `()`. - `break {expr}` looks up the broken loop, and unifies the type of `expr` with the type of the loop. - `break` with no expr unifies the loop's type with `()`. - When building MIR, `loop` loops no longer construct a `()` value at termination of the loop; rather, the `break` expression assigns the result of the loop. `while` loops are unchanged. - `break` respects contexts in which expressions may not end with braced blocks. That is, `while break { break-value } { while-body }` is illegal; this preserves backwards compatibility. - The RFC did not make it clear, but I chose to make `break ()` inside of a `while` loop illegal, just in case we wanted to do anything with that design space in the future. This is my first time dealing with this part of rustc so I'm sure there's plenty of problems to pick on here ^_^
2016-11-21Fix fallout in `rustdoc` and tests.Jeffrey Seyfried-3/+2
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-1/+2
2016-11-20Refactor `P<ast::MetaItem>` -> `ast::MetaItem`.Jeffrey Seyfried-10/+9
2016-11-20Move `MetaItemKind`'s `Name` to a field of `MetaItem`.Jeffrey Seyfried-6/+7
2016-11-20Refactor away `ast::Attribute_`.Jeffrey Seyfried-10/+7
2016-11-10syntax: don't fake a block around closures' bodies during parsing.Eduard Burtescu-1/+1
2016-11-03Make `ast::ExprKind` smaller.Jeffrey Seyfried-30/+16
2016-11-03Reduce the size of `Token` and make it cheaper to clone by refactoringJeffrey Seyfried-13/+18
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-4/+1
2016-10-27Implement field shorthands in struct literal expressions.Eduard Burtescu-4/+5
2016-10-01Rollup merge of #34764 - pnkfelix:attrs-on-generic-formals, r=eddybManish Goregaokar-1/+11
First step for #34761
2016-09-28libsyntax: clearer names for some AST partsJonas Schievink-5/+5
This applies the HIR changes from the previous commits to the AST, and is thus a syntax-[breaking-change] Renames `PatKind::Vec` to `PatKind::Slice`, since these are called slice patterns, not vec patterns. Renames `TyKind::Vec`, which represents the type `[T]`, to `TyKind::Slice`. Renames `TyKind::FixedLengthVec` to `TyKind::Array`.
2016-09-23Add attribute support to generic lifetime and type parameters.Felix S. Klock II-1/+11
I am using `ThinAttributes` rather than a vector for attributes attached to generics, since I expect almost all lifetime and types parameters to not carry any attributes.
2016-09-17Ensure that macro invocations are folded and visited the same order.Jeffrey Seyfried-53/+31
2016-09-13Refactor `noop_fold_stmt_kind` out of `noop_fold_stmt`.Jeffrey Seyfried-37/+13
2016-08-29Future proof the AST for `union`.Jeffrey Seyfried-0/+4
2016-08-28Rollup merge of #35850 - SergioBenitez:master, r=nrcJeffrey Seyfried-1/+18
Implement RFC#1559: allow all literals in attributes Implemented rust-lang/rfcs#1559, tracked by #34981.
2016-08-28Rollup merge of #35618 - jseyfried:ast_view_path_refactor, r=eddybJeffrey Seyfried-12/+4
Refactor `PathListItem`s This refactors away variant `Mod` of `ast::PathListItemKind` and refactors the remaining variant `Ident` to a struct `ast::PathListItem_`.
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-1/+18
2016-08-21Refactor away variant `ast::PathListItemKind::Mod`Jeffrey Seyfried-12/+4
and refactor `ast::PathListItemKind::Ident` -> `ast::PathListItem_`.
2016-08-18Add Span field for Generics structsGuillaume Gomez-1/+2
2016-08-13Rename empty/bang to neverAndrew Cann-1/+1
Split Ty::is_empty method into is_never and is_uninhabited
2016-08-13Remove obsolete divergence related stuffAndrew Cann-1/+0
Replace FnOutput with Ty Replace FnConverging(ty) with ty Purge FnDiverging, FunctionRetTy::NoReturn and FunctionRetTy::None
2016-08-13Start implementation of RFC 1216 (make ! a type)Andrew Cann-0/+1
Add `TyKind::Empty` and fix resulting build errors.
2016-08-12syntax: add anonymized type syntax, i.e. impl TraitA+TraitB.Eduard Burtescu-0/+3
2016-07-04Revert "Change `fold_tt` and `fold_tts` to take token trees by value ↵Jeffrey Seyfried-19/+27
(instead of by reference)" This reverts commit 5bf7970ac70b4e7781e7b2f3816720aa62fac6fd.
2016-06-29Give `ast::ExprKind::Paren` no-op expressions the same node ids as their ↵Jeffrey Seyfried-2/+11
children.
2016-06-26Rollup merge of #34436 - jseyfried:no_block_expr, r=eddybJeffrey Seyfried-2/+1
To allow these braced macro invocation, this PR removes the optional expression from `ast::Block` and instead uses a `StmtKind::Expr` at the end of the statement list. Currently, braced macro invocations in blocks can expand into statements (and items) except when they are last in a block, in which case they can only expand into expressions. For example, ```rust macro_rules! make_stmt { () => { let x = 0; } } fn f() { make_stmt! {} //< This is OK... let x = 0; //< ... unless this line is commented out. } ``` Fixes #34418.
2016-06-26Rollup merge of #34339 - jseyfried:thin_vec, r=petrochenkov,ManishearthJeffrey Seyfried-8/+5
Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`.
2016-06-26Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddybJeffrey Seyfried-43/+34
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26Rollup merge of #33943 - jseyfried:libsyntax_cleanup, r=nrcJeffrey Seyfried-30/+19
Miscellaneous low priority cleanup in `libsyntax`.
2016-06-26Rollup merge of #34385 - cgswords:tstream, r=nrcJeffrey Seyfried-0/+1
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-1/+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.