about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
AgeCommit message (Collapse)AuthorLines
2015-12-30use structured errorsNick Cameron-5/+10
2015-12-18Rollup merge of #30384 - nrc:diagnostics, r=@nikomatsakisManish Goregaokar-1/+1
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
2015-12-17Remove unused importsJeffrey Seyfried-1/+1
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-15Fix expansion testsSeo Sanghyeon-4/+13
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-11/+7
2015-12-04Auto merge of #29850 - Kimundi:attributes_that_make_a_statement, r=pnkfelixbors-10/+28
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-30Improved comments around dropped attributes in the macro expanderMarvin Löbel-2/+2
2015-11-26Added stmt_expr_attribute feature gateMarvin Löbel-3/+3
2015-11-26Some TLC for the MoveMap traitMarvin Löbel-0/+1
2015-11-26Fixed macro expander not folding attributes (though I'm not sure if that is ↵Marvin Löbel-15/+13
actually neccessary)
2015-11-26Add syntax support for attributes on expressions and all syntaxMarvin Löbel-9/+28
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 suggestion of similar macro names to `macro undefined` error messageFlorian Hartwig-0/+1
2015-11-22Look up macro names as well when suggesting replacements for function ↵Manish Goregaokar-15/+19
resolve errors fixes #5780
2015-11-16rename `ast::ImplItem_::*ImplItem` to `ast::ImplItemKind::*`Oliver Schneider-5/+5
2015-11-10Use deref coercionsSeo Sanghyeon-6/+6
2015-11-05remove excess string allocationSteve Klabnik-3/+1
&format!("...") is the same as "" if we're not doing any interpolation, and doesn't allocate an intermediate String.
2015-10-09hygiene for `for` loops, `if let`, `while let`Nick Cameron-15/+72
and some unrelated test cleanups
2015-10-09Fix stabilityNick Cameron-1/+1
2015-10-09Move placement in desugaring to loweringNick Cameron-154/+3
2015-10-09if let and while letNick Cameron-140/+4
2015-10-09Move `for` loop desugaring to loweringNick Cameron-94/+2
2015-10-01Stop re-exporting AttrStyle's variants and rename them.Ms2ger-1/+1
2015-09-26Auto merge of #28642 - petrochenkov:name3, r=nrcbors-22/+16
This PR removes random remaining `Ident`s outside of libsyntax and performs general cleanup In particular, interfaces of `Name` and `Ident` are tidied up, `Name`s and `Ident`s being small `Copy` aggregates are always passed to functions by value, and `Ident`s are never used as keys in maps, because `Ident` comparisons are tricky. Although this PR closes https://github.com/rust-lang/rust/issues/6993 there's still work related to it: - `Name` can be made `NonZero` to compress numerous `Option<Name>`s and `Option<Ident>`s but it requires const unsafe functions. - Implementation of `PartialEq` on `Ident` should be eliminated and replaced with explicit hygienic, non-hygienic or member-wise comparisons. - Finally, large parts of AST can potentially be converted to `Name`s in the same way as HIR to clearly separate identifiers used in hygienic and non-hygienic contexts. r? @nrc
2015-09-24Cleanup interfaces of Name, SyntaxContext and IdentVadim Petrochenkov-22/+16
Make sure Name, SyntaxContext and Ident are passed by value Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
2015-09-24Remove the deprecated box(PLACE) syntax.Eduard Burtescu-2/+2
2015-09-20Replace `ast::Mac_` enum with structAndrew Paseltiner-88/+75
Closes #28527.
2015-09-20Move tts instead of cloning in expansionManish Goregaokar-24/+25
2015-09-08Allow tracking issues for lang features.Huon Wilson-1/+3
This is similar to the libs version, which allow an `issue` field in the `#[unstable]` attribute. cc #28244
2015-09-01Auto merge of #28137 - nrc:remove-non-multi, r=huonwbors-83/+2
This is a [breaking-change] for syntax extension authors. The fix is to use MultiModifier or MultiDecorator, which have the same functionality but are more flexible. Users of syntax extensions are unaffected.
2015-09-01Remove the Modifier and Decorator kinds of syntax extensions.Nick Cameron-83/+2
This is a [breaking-change] for syntax extension authors. The fix is to use MultiModifier or MultiDecorator, which have the same functionality but are more flexible. Users of syntax extensions are unaffected.
2015-08-31Closures are not generated code.Nick Cameron-4/+1
2015-08-28Move ExpnInfo to NameManish Goregaokar-15/+15
2015-08-27Enumify CompilerExpansion in ExpnInfoManish Goregaokar-28/+20
2015-08-17feature gate `cfg(target_feature)`.Huon Wilson-6/+8
This is theoretically a breaking change, but GitHub search turns up no uses of it, and most non-built-in cfg's are passed via cargo features, which look like `feature = "..."`, and hence can't overlap.
2015-08-15Fix issue with for loop expansionw00ns-10/+1
2015-08-12Fix macro expansion in for loop patternJonas Schievink-1/+1
2015-08-06Auto merge of #27296 - jroesch:type-macros, r=huonwbors-0/+47
This pull request implements the functionality for [RFC 873](https://github.com/rust-lang/rfcs/blob/master/text/0873-type-macros.md). This is currently just an update of @freebroccolo's branch from January, the corresponding commits are linked in each commit message. @nikomatsakis and I had talked about updating the macro language to support a lifetime fragment specifier, and it is possible to do that work on this branch as well. If so we can (collectively) talk about it next week during the pre-RustCamp work week.
2015-08-04Fix last nitsJared Roesch-1/+2
2015-08-04Actually commit testsJared Roesch-1/+1
2015-08-04Address nitsJared Roesch-1/+0
2015-08-04Add feature gateJared Roesch-19/+29
2015-08-04Extend macro machinery to expand macros in typesJared Roesch-0/+37
Reapplied the changes from https://github.com/freebroccolo/rust/commit/7aafe24139abc2d1f302bbb166bcaa006f12cf4d to a clean branch of master
2015-08-03syntax: Implement #![no_core]Alex Crichton-15/+11
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-28remove `get_ident` and `get_name`, make `as_str` soundOliver Schneider-34/+26
2015-07-26Remove `ast::LocalSource` with only one used variantmitaa-2/+1
`LocalSource` indicated wether a let binding originated from for-loop desugaring to enable specialized error messages, but for-loop expansion has changed and this is now achieved through `MatchSource::ForLoopDesugar`.
2015-07-22Allow unstable code to be injected by placement-`in` expansion.Felix S. Klock II-3/+23
(Over time the stability checking has gotten more finicky; in particular one must attach the (whole) span of the original `in PLACE BLOCK` expression to the injected references to unstable paths, as noted in the comments.) call `push_compiler_expansion` during the placement-`in` expansion.
2015-07-22Add feature-gates for desugaring-based `box` and placement-`in`.Felix S. Klock II-0/+7
update test/compile-fail/feature-gate-box-expr.rs to reflect new feature gates. Part of what lands with Issue 22181.
2015-07-22Revise placement-in expansion to use `push/pop_unsafe` and `move_val_init`.Felix S. Klock II-24/+37
2015-07-22prototype Placer protocol for unstable overloaded-box and placement-in.Felix S. Klock II-0/+114