about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2016-11-12Cleanup macro_parser::parse, removing a few clones.Mark-Simulacrum-51/+35
2016-11-11Change implementation of syntax::util::SmallVector to use ↵Mark-Simulacrum-268/+75
data_structures::SmallVec.
2016-11-11Auto merge of #37246 - goffrie:no-loop, r=jseyfriedbors-1/+3
Don't spin expanding stmt macros. If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 and #37234 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state. I'm not sold on this strategy (checking `tokens_consumed`), so if anyone has a better idea, I'm all ears!
2016-11-10Elimite `$crate` before invokng custom derives.Jeffrey Seyfried-0/+2
2016-11-10Rollup merge of #37661 - brson:qmarkstab, r=nikomatsakisEduard-Mihai Burtescu-1/+1
question_mark was stabilized in 1.13
2016-11-10syntax: don't fake a block around closures' bodies during parsing.Eduard Burtescu-103/+55
2016-11-09Rollup merge of #37614 - keeperofdakeys:proc_macro, r=jseyfriedEduard-Mihai Burtescu-5/+31
macros 1.1: Allow proc_macro functions to declare attributes to be mark as used This PR allows proc macro functions to declare attribute names that should be marked as used when attached to the deriving item. There are a few questions for this PR. - Currently this uses a separate attribute named `#[proc_macro_attributes(..)]`, is this the best choice? - In order to make this work, the `check_attribute` function had to be modified to not error on attributes marked as used. This is a pretty large change in semantics, is there a better way to do this? - I've got a few clones where I don't know if I need them (like turning `item` into a `TokenStream`), can these be avoided? - Is switching to `MultiItemDecorator` the right thing here? Also fixes https://github.com/rust-lang/rust/issues/37563.
2016-11-09Rollup merge of #37428 - estebank:generic-type-error-span, r=sanxiynEduard-Mihai Burtescu-0/+8
Point to type argument span when used as trait Given the following code: ``` rust struct Foo<T: Clone>(T); use std::ops::Add; impl<T: Clone, Add> Add for Foo<T> { type Output = usize; fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } ``` present the following output: ``` nocode error[E0404]: `Add` is not a trait --> file3.rs:5:21 | 5 | impl<T: Clone, Add> Add for Okok<T> { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ``` Fixes #35987.
2016-11-09question_mark was stabilized in 1.13Brian Anderson-1/+1
2016-11-08Point to type argument span when used as traitEsteban Küber-0/+8
Given the following code: ```rust struct Foo<T: Clone>(T); use std::ops::Add; impl<T: Clone, Add> Add for Foo<T> { type Output = usize; fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } ``` present the following output: ```nocode error[E0404]: `Add` is not a trait --> file3.rs:5:21 | 5 | impl<T: Clone, Add> Add for Okok<T> { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ```
2016-11-08Partially stabilize RFC 1506 "Clarify relationships between ADTs"Vadim Petrochenkov-18/+17
2016-11-08Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakisbors-16/+3
Stabilize `..` in tuple (struct) patterns I'd like to nominate `..` in tuple and tuple struct patterns for stabilization. This feature is a relatively small extension to existing stable functionality and doesn't have known blockers. The feature first appeared in Rust 1.10 6 months ago. An example of use: https://github.com/rust-lang/rust/pull/36203 Closes https://github.com/rust-lang/rust/issues/33627 r? @nikomatsakis
2016-11-08Rename KNOWN_ATTRS to BUILT_ATTRS, and create KNOWN_ATTRSJosh Driver-5/+31
KNOWN_ATTRIBUTES should really be named BUILT_ATTRIBUTES, while KNOWN_ATTRIBUTES should be used to mark attributes as known, similar to USED_ATTRIBUTES.
2016-11-05Fix tests from the rollupAlex Crichton-1/+1
2016-11-05Merge branch 'selfgate' of https://github.com/petrochenkov/rust into rollupAlex Crichton-0/+3
2016-11-05Rollup merge of #37569 - jseyfried:improve_expansion_perf, r=eddybAlex Crichton-388/+294
macros: improve expansion performance This PR fixes that regression, further improves performance on recursive, `tt`-heavy workloads, and makes a variety of other improvements to parsing and expansion performance. Expansion performance improvements: | Test case | Run-time | Memory usage | | -------------- | -------- | ------------ | | libsyntax | 8% | 10% | | librustc | 15% | 6% | | librustc_trans | 30% | 6% | | #37074 | 20% | 15% | | #34630 | 40% | 8% | r? @eddyb
2016-11-05Rollup merge of #37501 - alexcrichton:windows-subsystem, r=brsonAlex Crichton-0/+9
rustc: Add knowledge of Windows subsystems. This commit is an implementation of [RFC 1665] which adds support for the `#![windows_subsystem]` attribute. This attribute allows specifying either the "windows" or "console" subsystems on Windows to the linker. [RFC 1665]: https://github.com/rust-lang/rfcs/blob/master/text/1665-windows-subsystem.md Previously all Rust executables were compiled as the "console" subsystem which meant that if you wanted a graphical application it would erroneously pop up a console whenever opened. When compiling an application, however, this is undesired behavior and the "windows" subsystem is used instead to have control over user interactions. This attribute is validated, but ignored on all non-Windows platforms. cc #37499
2016-11-04Remove field `TtReader::next_tok`.Jeffrey Seyfried-7/+2
2016-11-04Improve `tt`-heavy expansion performance.Jeffrey Seyfried-5/+23
2016-11-03Move doc comment desugaring into the parser.Jeffrey Seyfried-33/+16
2016-11-03Avoid recontructing the `Parser` in `macro_parser.rs`.Jeffrey Seyfried-42/+16
2016-11-03Make `ast::ExprKind` smaller.Jeffrey Seyfried-31/+17
2016-11-03Reimplement "macros: Improve `tt` fragments" with better performance.Jeffrey Seyfried-18/+61
2016-11-03Revert "macros: Improve `tt` fragments"Jeffrey Seyfried-20/+3
This reverts commit 41745f30f751364bdce14428b7d3ffa5dd028903.
2016-11-03Reduce the size of `Token` and make it cheaper to clone by refactoringJeffrey Seyfried-226/+159
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-11-03Clean up `parser.parse_token_tree()`.Jeffrey Seyfried-22/+13
2016-11-03Add feature gate for Self and associated types in struct expressions and ↵Vadim Petrochenkov-0/+3
patterns
2016-11-03Stabilize `..` in tuple (struct) patternsVadim Petrochenkov-16/+3
2016-10-31Changed most vec! invocations to use square bracesiirelu-74/+74
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-31rustc: Add knowledge of Windows subsystems.Alex Crichton-0/+9
This commit is an implementation of [RFC 1665] which adds support for the `#![windows_subsystem]` attribute. This attribute allows specifying either the "windows" or "console" subsystems on Windows to the linker. [RFC 1665]: https://github.com/rust-lang/rfcs/blob/master/text/1665-windows-subsystem.md Previously all Rust executables were compiled as the "console" subsystem which meant that if you wanted a graphical application it would erroneously pop up a console whenever opened. When compiling an application, however, this is undesired behavior and the "windows" subsystem is used instead to have control over user interactions. This attribute is validated, but ignored on all non-Windows platforms. cc #37499
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-182/+66
2016-10-28Auto merge of #37373 - nnethercote:html5ever-more-more, r=nrcbors-21/+51
Avoid more allocations when compiling html5ever These three commits reduce the number of allocations performed when compiling html5ever from 13.2M to 10.8M, which speeds up compilation by about 2%. r? @nrc
2016-10-28Auto merge of #37367 - jseyfried:import_crate_root, r=nrcbors-4/+9
Support `use *;` and `use ::*;`. Fixes #31484. r? @nrc
2016-10-28Rollup merge of #36206 - mcarton:35755, r=pnkfelixGuillaume Gomez-0/+11
Fix bad error message with `::<` in types Fix #36116. Before: ```rust error: expected identifier, found `<` --> src/test/compile-fail/issue-36116.rs:16:52 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^ error: chained comparison operators require parentheses --> src/test/compile-fail/issue-36116.rs:16:52 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments error: expected expression, found `)` --> src/test/compile-fail/issue-36116.rs:16:57 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^ error: expected identifier, found `<` --> src/test/compile-fail/issue-36116.rs:20:17 | 20 | let g: Foo::<i32> = Foo { _a: 42 }; | ^ error: aborting due to 5 previous errors ``` After: ```rust error: unexpected token: `::` --> src/test/compile-fail/issue-36116.rs:16:50 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^^ | = help: use `<...>` instead of `::<...>` if you meant to specify type arguments error: unexpected token: `::` --> src/test/compile-fail/issue-36116.rs:20:15 | 20 | let g: Foo::<i32> = Foo { _a: 42 }; | ^^ | = help: use `<...>` instead of `::<...>` if you meant to specify type arguments error: aborting due to 2 previous errors ```
2016-10-28Fix bad error message with `::<` in typesmcarton-0/+11
2016-10-27Auto merge of #37245 - goffrie:recovery, r=nrcbors-2/+10
Recover out of an enum or struct's braced block. If we encounter a syntax error inside of a braced block, then we should fail by consuming the rest of the block if possible. This implements such recovery for enums and structs. Fixes #37113.
2016-10-27Auto merge of #37128 - nrc:depr-attr, r=@alexcrichtonbors-48/+117
Deprecate no_debug and custom_derive r? @nikomatsakis
2016-10-26Auto merge of #11994 - eddyb:struct-literal-field-shorthand, r=nrcbors-15/+43
Implement field shorthands in struct literal expressions. Implements #37340 in a straight-forward way: `Foo { x, y: f() }` parses as `Foo { x: x, y: f() }`. Because of the added `is_shorthand` to `ast::Field`, this is `[syntax-breaking]` (cc @Manishearth). * [x] Mark the fields as being a shorthand (the exact same way we do it in patterns), for pretty-printing. * [x] Gate the shorthand syntax with `#![feature(field_init_shorthand)]`. * [x] Don't parse numeric field as identifiers. * [x] Arbitrary field order tests.
2016-10-26Don't spin expanding stmt macros.Geoffry Song-1/+3
If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state.
2016-10-26Recover out of an enum or struct's braced block.Geoffry Song-2/+10
If we encounter a syntax error inside of a braced block, then we should fail by consuming the rest of the block if possible. This implements such recovery for enums and structs. Fixes #37113.
2016-10-27review changesNick Cameron-8/+24
2016-10-27Implement field shorthands in struct literal expressions.Eduard Burtescu-15/+43
2016-10-27Deprecate custom_deriveNick Cameron-1/+6
Has a custom deprecation since deprecating features is not supported and is a pain to implement
2016-10-27deprecate no_debugNick Cameron-1/+1
2016-10-27Add possibility of deprecating attributesNick Cameron-44/+92
2016-10-26Rollup merge of #37414 - thepowersgang:fix-typo, r=nrcGuillaume Gomez-1/+1
Fix typo in libsyntax, it was bothering me May I present - the world's shortest diff.
2016-10-25Auto merge of #36421 - TimNN:check-abis, r=alexcrichtonbors-28/+22
check target abi support This PR checks for each extern function / block whether the ABI / calling convention used is supported by the current target. This was achieved by adding an `abi_blacklist` field to the target specifications, listing the calling conventions unsupported for that target.
2016-10-26Fix typo, it bothered meJohn Hodge-1/+1
2016-10-25Don't use `Rc` in `TokenTreeOrTokenTreeVec`.Nicholas Nethercote-3/+3
This avoids 800,000 allocations when compiling html5ever.
2016-10-25Use `SmallVector` for `TtReader::stack`.Nicholas Nethercote-13/+45
This avoids 800,000 heap allocations when compiling html5ever. It requires tweaking `SmallVector` a little.