about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2017-01-23Remove `open_span` and `close_span` from `Delimited`.Jeffrey Seyfried-13/+10
2017-01-22Refactor `TokenStream`.Jeffrey Seyfried-78/+4
2017-01-20Rollup merge of #39118 - jseyfried:token_tree_based_parser, r=nrcAlex Crichton-100/+49
Refactor the parser to consume token trees This is groundwork for efficiently parsing attribute proc macro invocations, bang macro invocations, and `TokenStream`-based attributes and fragment matchers. This improves parsing performance by 8-15% and expansion performance by 0-5% on a sampling of the compiler's crates. r? @nrc
2017-01-20Rollup merge of #38842 - abonander:proc_macro_attribute, r=jseyfriedAlex Crichton-3/+27
Implement `#[proc_macro_attribute]` This implements `#[proc_macro_attribute]` as described in https://github.com/rust-lang/rfcs/pull/1566 The following major (hopefully non-breaking) changes are included: * Refactor `proc_macro::TokenStream` to use `syntax::tokenstream::TokenStream`. * `proc_macro::tokenstream::TokenStream` no longer emits newlines between items, this can be trivially restored if desired * `proc_macro::TokenStream::from_str` does not try to parse an item anymore, moved to `impl MultiItemModifier for CustomDerive` with more informative error message * Implement `#[proc_macro_attribute]`, which expects functions of the kind `fn(TokenStream, TokenStream) -> TokenStream` * Reactivated `#![feature(proc_macro)]` and gated `#[proc_macro_attribute]` under it * `#![feature(proc_macro)]` and `#![feature(custom_attribute)]` are mutually exclusive * adding `#![feature(proc_macro)]` makes the expansion pass assume that any attributes that are not built-in, or introduced by existing syntax extensions, are proc-macro attributes * Fix `feature_gate::find_lang_feature_issue()` to not use `unwrap()` * This change wasn't necessary for this PR, but it helped debugging a problem where I was using the wrong feature string. * Move "completed feature gate checking" pass to after "name resolution" pass * This was necessary for proper feature-gating of `#[proc_macro_attribute]` invocations when the `proc_macro` feature flag isn't set. Prototype/Litmus Test: [Implementation](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/src/lib.rs#L13) -- [Usage](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/examples/post_service.rs#L35)
2017-01-17Auto merge of #39110 - petrochenkov:sum, r=eddybbors-31/+7
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-17Avoid interpolated token trees.Jeffrey Seyfried-17/+3
2017-01-17Clean up `ext::tt::transcribe`.Jeffrey Seyfried-74/+35
2017-01-17Refactor the parser to consume token trees.Jeffrey Seyfried-18/+24
2017-01-17Introduce `string_reader.parse_all_token_trees()`.Jeffrey Seyfried-7/+3
2017-01-17Give the `StringReader` a `sess: &ParseSess`.Jeffrey Seyfried-1/+1
2017-01-16Implement `#[proc_macro_attribute]`Austin Bonander-3/+27
* Add support for `#[proc_macro]` * Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it * Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`, error on legacy import of proc macros via `#[macro_use]`
2017-01-17Auto merge of #39090 - solson:exprkind-array, r=eddybbors-1/+1
Rename ExprKind::Vec to Array in HIR and HAIR. This is a clearer name since they represent `[a, b, c]` array literals. r? @eddyb
2017-01-17syntax: Rename parse_ty -> parse_ty_no_plus, parse_ty_sum -> parse_tyVadim Petrochenkov-3/+3
2017-01-17Use resizable Vec instead of P<[T]> in ASTVadim Petrochenkov-21/+4
2017-01-17AST/HIR: Merge ObjectSum and PolyTraitRefVadim Petrochenkov-7/+0
2017-01-16Rename ExprKind::Vec to Array in HIR and HAIR.Scott Olson-1/+1
This is a clearer name since they represent [a, b, c] array literals.
2017-01-15Mark the pushpop_unsafe feature as "removed"est31-1/+0
This marks the pushpop_unsafe feature as removed inside the feature_gate. It was added in commit 1829fa5199bae5a192c771807c532badce14be37 and then removed again in commit d399098fd82e0bf3ed61bbbbcdbb0b6adfa4c808 . Seems that the second commit forgot to mark it as removed in feature_gate.rs. This enables us to remove another element from the whitelist of non gate tested unstable lang features (issue #39059).
2017-01-12Auto merge of #38814 - Ralith:cfg-fields, r=jseyfriedbors-1/+8
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-1/+8
2017-01-02rustc: Stabilize the `proc_macro` featureAlex Crichton-1/+0
This commit stabilizes the `proc_macro` and `proc_macro_lib` features in the compiler to stabilize the "Macros 1.1" feature of the language. Many more details can be found on the tracking issue, #35900. Closes #35900
2016-12-30Such large. Very 128. Much bits.Simonas Kazlauskas-7/+13
This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which understands and supports 128-bit integers throughout. The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported, this strategy is good enough to get past the first bootstrap stages to end up with a fully working 128-bit capable compiler. In order for this strategy to work, number of locations had to be changed to use associated max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?) had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works (former not necessarily producing the right results in stage1). This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-23Auto merge of #38533 - jseyfried:legacy_custom_derive_deprecation, r=nrcbors-0/+2
Allow legacy custom derive authors to disable warnings in downstream crates This PR allows legacy custom derive authors to use a pre-deprecated method `registry.register_custom_derive()` instead of `registry.register_syntax_extension()` to avoid downstream deprecation warnings. r? @nrc
2016-12-23Allow legacy custom derive authors to disable warnings in downstream crates.Jeffrey Seyfried-0/+2
2016-12-22Refactor how global paths are represented (for both ast and hir).Jeffrey Seyfried-3/+7
2016-12-20Rollup merge of #38171 - jseyfried:cleanup, r=nrcAlex Crichton-140/+85
Miscellaneous cleanup/refactoring in `resolve` and `syntax::ext` r? @nrc
2016-12-19Optimize `ast::PathSegment`.Jeffrey Seyfried-17/+14
2016-12-19Auto merge of #38194 - sgrif:sg-no-span-mangling, r=nrcbors-15/+3
Don't perform span mangling when building field/tup access nodes There are no guarantees that the two spans used to create the new one come from the same place or are even valid. Fixes #36081.
2016-12-18Refactor out `mark.as_placeholder_id()`.Jeffrey Seyfried-5/+9
2016-12-18Avoid including attributes in bang macro invocations.Jeffrey Seyfried-25/+19
2016-12-18Remove scope placeholders, remove method `add_macro` of `ext::base::Resolver`.Jeffrey Seyfried-85/+38
2016-12-18Remove `MacroDef`'s fields `imported_from` and `allow_internal_unstable`,Jeffrey Seyfried-7/+4
remove `export` argument of `resolver.add_macro()`.
2016-12-18Remove some unused functions and fix formatting.Jeffrey Seyfried-6/+6
2016-12-17Auto merge of #38205 - jseyfried:fix_module_directory_regression, r=eddybbors-12/+14
macros: fix the expected paths for a non-inline module matched by an `item` fragment Fixes #38190. r? @nrc
2016-12-07macros: fix the expected paths for a non-inline module matched by an `item` ↵Jeffrey Seyfried-12/+14
fragment.
2016-12-06Don't perform span mangling when building field/tup access nodesSean Griffin-15/+3
There are no guarantees that the two spans used to create the new one come from the same place or are even valid. Fixes #36081.
2016-12-06annotate stricter lifetimes on LateLintPass methods to allow them to forward ↵Oliver Schneider-1/+1
to a Visitor
2016-11-30Support paths in macro invocations.Jeffrey Seyfried-6/+1
2016-11-22Auto merge of #37487 - goffrie:break, r=nikomatsakisbors-1/+1
Implement the `loop_break_value` feature. 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, loops no longer construct a `()` value at termination of the loop; rather, the `break` expression assigns the result of the loop. - ~~I have also changed the loop scoping in MIR-building so that the test of a while loop is not considered to be part of that loop. This makes the rules consistent with #37360. The new loop scopes in typeck also follow this rule. That means that `loop { while (break) {} }` now terminates instead of looping forever. This is technically a breaking change.~~ - ~~On that note, expressions like `while break {}` and `if break {}` no longer parse because `{}` is interpreted as an expression argument to `break`. But no code except compiler test cases should do that anyway because it makes no sense.~~ - 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-21Implement the `loop_break_value` feature.Geoffry Song-1/+1
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-22Start warning cycle.Jeffrey Seyfried-1/+1
2016-11-22Clean up directory ownership semantics.Jeffrey Seyfried-22/+28
2016-11-21Cleanup `InternedString`.Jeffrey Seyfried-5/+4
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-26/+21
places.
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-29/+30
2016-11-20Refactor `P<ast::MetaItem>` -> `ast::MetaItem`.Jeffrey Seyfried-10/+10
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-11/+11
2016-11-20Refactor away `ast::Attribute_`.Jeffrey Seyfried-4/+4
2016-11-17Resolve imports during expansion.Jeffrey Seyfried-2/+13
2016-11-12Remove extra level of nesting.Mark-Simulacrum-35/+32
2016-11-12Move next_eis out of main loop to avoid re-allocating and dropping it.Mark-Simulacrum-1/+2