about summary refs log tree commit diff
path: root/src/libsyntax/ast.rs
AgeCommit message (Collapse)AuthorLines
2016-05-29Auto merge of #33929 - petrochenkov:pathir, r=eddybbors-8/+4
Separate bindings from other patterns in HIR Now when name resolution is done on AST, we can avoid dumping everything that looks like an identifier into `PatKind::Ident` in HIR. `hir::PatKind::Ident` is removed, fresh bindings are now called `hir::PatKind::Binding`, everything else goes to `hir::PatKind::Path`. I intend to do something with `PatKind::Path`/`PatKind::QPath` as well using resolution results, but it requires some audit and maybe some deeper refactoring of relevant resolution/type checking code to do it properly. I'm submitting this part of the patch earlier to notify interested parties that I'm working on this. cc @jseyfried r? @eddyb
2016-05-28Address review commentsVadim Petrochenkov-2/+4
2016-05-28Refactor away some functions from hir::pat_utilVadim Petrochenkov-12/+6
2016-05-27Auto merge of #33706 - jseyfried:refactor_cfg, r=nrcbors-20/+5
Perform `cfg` attribute processing during macro expansion and fix bugs This PR refactors `cfg` attribute processing and fixes bugs. More specifically: - It merges gated feature checking for stmt/expr attributes, `cfg_attr` processing, and `cfg` processing into a single fold. - This allows feature gated `cfg` variables to be used in `cfg_attr` on unconfigured items. All other feature gated attributes can already be used on unconfigured items. - It performs `cfg` attribute processing during macro expansion instead of after expansion so that macro-expanded items are configured the same as ordinary items. In particular, to match their non-expanded counterparts, - macro-expanded unconfigured macro invocations are no longer expanded, - macro-expanded unconfigured macro definitions are no longer usable, and - feature gated `cfg` variables on macro-expanded macro definitions/invocations are now errors. This is a [breaking-change]. For example, the following would break: ```rust macro_rules! m { () => { #[cfg(attr)] macro_rules! foo { () => {} } foo!(); // This will be an error macro_rules! bar { () => { fn f() {} } } #[cfg(attr)] bar!(); // This will no longer be expanded ... fn g() { f(); } // ... so that `f` will be unresolved. #[cfg(target_thread_local)] // This will be a gated feature error macro_rules! baz { () => {} } } } m!(); ``` r? @nrc
2016-05-27Rollup merge of #33644 - petrochenkov:selfast, r=nrcManish Goregaokar-47/+41
The AST part of https://github.com/rust-lang/rust/pull/33505. https://github.com/rust-lang/rust/pull/33505 isn't landed yet, so this PR is based on top of it. r? @nrc plugin-[breaking-change] cc #31645 @Manishearth
2016-05-27Rollup merge of #33639 - petrochenkov:dotdot, r=nmatsakisManish Goregaokar-7/+9
cc https://github.com/rust-lang/rust/issues/33627 r? @nikomatsakis plugin-[breaking-change] cc https://github.com/rust-lang/rust/issues/31645 @Manishearth
2016-05-26Add and use `HasAttrs` traitJeffrey Seyfried-20/+5
2016-05-26Address review commentsVadim Petrochenkov-2/+2
2016-05-26Implement `..` in tuple (struct) patternsVadim Petrochenkov-7/+9
2016-05-25Add a new AST-only type variant `ImplicitSelf`Vadim Petrochenkov-5/+5
2016-05-25Remove ExplicitSelf from ASTVadim Petrochenkov-45/+39
2016-05-24syntax/hir: give loop labels a spanGeorg Brandl-4/+4
This makes the "shadowing labels" warning *not* print the entire loop as a span, but only the lifetime. Also makes #31719 go away, but does not fix its root cause (the span of the expanded loop is still wonky, but not used anymore).
2016-05-16Remove hir::IdentVadim Petrochenkov-0/+4
2016-05-15Auto merge of #33505 - petrochenkov:self, r=nrcbors-18/+65
Remove ExplicitSelf from HIR `self` argument is already kept in the argument list and can be retrieved from there if necessary, so there's no need for the duplication. The same changes can be applied to AST, I'll make them in the next breaking batch. The first commit also improves parsing of method declarations and fixes https://github.com/rust-lang/rust/issues/33413. r? @eddyb
2016-05-14syntax: Refactor parsing of method declarationsVadim Petrochenkov-18/+65
Fix spans and expected token lists, fix #33413 + other cosmetic improvements Add test for #33413 Convert between `Arg` and `ExplicitSelf` precisely Simplify pretty-printing for methods
2016-05-11save-analysis: give better text info in value fieldsNick Cameron-4/+1
2016-05-09Move resolution to before loweringJeffrey Seyfried-0/+38
2016-04-25Rollup merge of #33041 - petrochenkov:path, r=nrc,ManishearthManish Goregaokar-11/+9
Paths are mostly parsed without taking whitespaces into account, e.g. `std :: vec :: Vec :: new ()` parses successfully, however, there are some special cases involving keywords `super`, `self` and `Self`. For example, `self::` is considered a path start only if there are no spaces between `self` and `::`. These restrictions probably made sense when `self` and friends weren't keywords, but now they are unnecessary. The first two commits remove this special treatment of whitespaces by removing `token::IdentStyle` entirely and therefore fix https://github.com/rust-lang/rust/issues/14109. This change also affects naked `self` and `super` (which are not tightly followed by `::`, obviously) they can now be parsed as paths, however they are still not resolved correctly in imports (cc @jseyfried, see `compile-fail/use-keyword.rs`), so https://github.com/rust-lang/rust/issues/29036 is not completely fixed. The third commit also makes `super`, `self`, `Self` and `static` keywords nominally (before this they acted as keywords for all purposes) and removes most of remaining \"special idents\". The last commit (before tests) contains some small improvements - some qualified paths with type parameters are parsed correctly, `parse_path` is not used for parsing single identifiers, imports are sanity checked for absence of type parameters - such type parameters can be generated by syntax extensions or by macros when https://github.com/rust-lang/rust/issues/10415 is fixed (~~soon!~~already!). This patch changes some pretty basic things in `libsyntax`, like `token::Token` and the keyword list, so it's a plugin-[breaking-change]. r? @eddyb
2016-04-24Remove some old code from libsyntaxVadim Petrochenkov-3/+3
2016-04-24syntax: Make static/super/self/Self keywords + special ident cleanupVadim Petrochenkov-1/+1
2016-04-24syntax: Get rid of token::IdentStyleVadim Petrochenkov-7/+5
2016-04-24thread tighter span for closures aroundNiko Matsakis-1/+3
Track the span corresponding to the `|...|` part of the closure.
2016-04-14Add a span to the `Crate` variant of `ast::Visibility`Jeffrey Seyfried-1/+1
2016-04-06Rollup merge of #32570 - eddyb:tis-but-a-front, r=nikomatsakisManish Goregaokar-0/+17
r? @nikomatsakis Conflicts: src/librustc_save_analysis/lib.rs src/libsyntax/ast_util.rs
2016-04-06Move span into `StructField`Vadim Petrochenkov-3/+2
2016-04-06Get rid of ast::StructFieldKindVadim Petrochenkov-33/+2
2016-04-06syntax: dismantle ast_util.Eduard Burtescu-0/+17
2016-04-02Add `Crate` and `Restricted` variants to `ast::Visibility`Jeffrey Seyfried-0/+2
2016-04-02Make `ast::Visibility` non-copyableJeffrey Seyfried-4/+4
2016-04-02Remove `ast::Visibility::inherit_from` (it is unused and has obsolete semantics)Jeffrey Seyfried-9/+0
2016-03-24fatal error instead of ICE for impossible range during HIR loweringAlex Burka-0/+5
End-less ranges (`a...`) don't parse but bad syntax extensions could conceivably produce them. Unbounded ranges (`...`) do parse and are caught here. The other panics in HIR lowering are all for unexpanded macros, which cannot be constructed by bad syntax extensions.
2016-03-22try! -> ?Jorge Aparicio-2/+2
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-14Add `default` as contextual keyword, and parse it for impl items.Aaron Turon-4/+11
2016-03-12Removed integer suffixes in libsyntax cratesrinivasreddy-3/+3
2016-03-09Auto merge of #31631 - jonas-schievink:agoraphobia, r=nrcbors-1/+1
[breaking-batch] Move more uses of `panictry!` out of libsyntax
2016-03-07implement the `?` operatorJorge Aparicio-0/+3
The `?` postfix operator is sugar equivalent to the try! macro, but is more amenable to chaining: `File::open("foo")?.metadata()?.is_dir()`. `?` is accepted on any *expression* that can return a `Result`, e.g. `x()?`, `y!()?`, `{z}?`, `(w)?`, etc. And binds more tightly than unary operators, e.g. `!x?` is parsed as `!(x?)`. cc #31436
2016-02-27libsyntax: parse inclusive rangesAlex Burka-2/+11
2016-02-16Move more uses of `panictry!` out of libsyntaxJonas Schievink-1/+1
[breaking-change] for syntax extensions
2016-02-16Split PatKind::Enum into PatKind::TupleStruct and PatKind::PathVadim Petrochenkov-1/+1
2016-02-13Split ast::PatKind::Enum into tuple struct and path patternsVadim Petrochenkov-10/+16
2016-02-13Rename ast::Pat_ and its variantsVadim Petrochenkov-19/+18
2016-02-11Remove some unnecessary indirection from AST structuresVadim Petrochenkov-7/+7
2016-02-11[breaking-change] don't glob export ast::PathListItem_ variantsOliver 'ker' Schneider-10/+9
2016-02-11[breaking-change] don't glob export ast::StrStyle variantsOliver 'ker' Schneider-3/+2
2016-02-11[breaking-change] don't glob export ast::Visibility variantsOliver 'ker' Schneider-3/+2
2016-02-11[breaking-change] don't glob export ast::TraitItemKind variantsOliver 'ker' Schneider-6/+5
2016-02-11[breaking-change] don't glob export ast::Mutablity variantsOliver 'ker' Schneider-3/+2
2016-02-11[breaking-change] don't glob export ast::MetaItem_Oliver 'ker' Schneider-15/+15
2016-02-11[breaking-change] don't glob export ast::MacStmtStyleOliver 'ker' Schneider-4/+3
2016-02-11[breaking-change] don't glob export ast::KleeneOp variantsOliver 'ker' Schneider-1/+0