about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2014-02-18Avoid returning original macro if expansion fails.Douglas Young-4/+10
Closes #11692. Instead of returning the original expression, a dummy expression (with identical span) is returned. This prevents infinite loops of failed expansions as well as odd double error messages in certain situations.
2014-02-14auto merge of #12234 : sfackler/rust/restructure-item-decorator, r=huonwbors-1/+1
The old method of building up a list of items and threading it through all of the decorators was unwieldy and not really scalable as non-deriving ItemDecorators become possible. The API is now that the decorator gets an immutable reference to the item it's attached to, and a callback that it can pass new items to. If we want to add syntax extensions that can modify the item they're attached to, we can add that later, but I think it'll have to be separate from ItemDecorator to avoid strange ordering issues. @huonw
2014-02-14Refactored ast_map and friends, mainly to have Paths without storing them.Eduard Burtescu-2/+1
2014-02-13Tweak ItemDecorator APISteven Fackler-1/+1
The old method of building up a list of items and threading it through all of the decorators was unwieldy and not really scalable as non-deriving ItemDecorators become possible. The API is now that the decorator gets an immutable reference to the item it's attached to, and a callback that it can pass new items to. If we want to add syntax extensions that can modify the item they're attached to, we can add that later, but I think it'll have to be separate from ItemDecorator to avoid strange ordering issues.
2014-02-13auto merge of #12017 : FlaPer87/rust/replace-mod-crate, r=alexcrichtonbors-1/+1
The first setp for #9880 is to add a new `crate` keyword. This PR does exactly that. I took a chance to refactor `parse_item_foreign_mod` and I broke it down into 2 separate methods to isolate each feature. The next step will be to push a new stage0 snapshot and then get rid of all `extern mod` around the code.
2014-02-13Stop unloading syntax librariesSteven Fackler-8/+0
Externally loaded libraries are able to do things that cause references to them to survive past the expansion phase (e.g. creating @-box cycles, launching a task or storing something in task local data). As such, the library has to stay loaded for the lifetime of the process.
2014-02-13Replace `crate` usage with `krate`Flavio Percoco-1/+1
This patch replaces all `crate` usage with `krate` before introducing the new keyword. This ensures that after introducing the keyword, there won't be any compilation errors. krate might not be the most expressive substitution for crate but it's a very close abbreviation for it. `module` was already used in several places already.
2014-02-08Converted fourcc! to loadable syntax extensionDerek Guenther-4/+1
2014-02-08Add new syntax extension fourcc!()Kevin Ballard-0/+3
fourcc!() allows you to embed FourCC (or OSType) values that are evaluated as u32 literals. It takes a 4-byte ASCII string and produces the u32 resulting in interpreting those 4 bytes as a u32, using either the platform-native endianness, or explicitly as big or little endian.
2014-02-08syntax: convert deriving to take &mut ExtCtxt.Huon Wilson-1/+1
2014-02-07Removed @self and @Trait.Eduard Burtescu-1/+1
2014-02-02libsyntax: De-`@str` `MacroDef`Patrick Walton-1/+1
2014-02-02librustc: De-`@str` `NameAndSpan`Patrick Walton-1/+2
2014-02-02librustc: Fix merge fallout.Patrick Walton-6/+4
2014-02-02libsyntax: De-`@str` `get_single_str_from_tts`Patrick Walton-2/+4
2014-02-02libsyntax: De-`@str` literal strings in the ASTPatrick Walton-5/+7
2014-01-25Simplify and rename macro APISteven Fackler-82/+52
Now that procedural macros can be implemented outside of the compiler, it's more important to have a reasonable API to work with. Here are the basic changes: * Rename SyntaxExpanderTTTrait to MacroExpander, SyntaxExpanderTT to BasicMacroExpander, etc. I think "procedural macro" is the right term for these now, right? The other option would be SynExtExpander or something like that. * Stop passing the SyntaxContext to extensions. This was only ever used by macro_rules, which doesn't even use it anymore. I can't think of a context in which an external extension would need it, and removal allows the API to be significantly simpler - no more SyntaxExpanderTTItemExpanderWithoutContext wrappers to worry about.
2014-01-24auto merge of #11720 : sfackler/rust/macro-export-source, r=alexcrichtonbors-1/+1
The old method of serializing the AST gives totally bogus spans if the expansion of an imported macro causes compilation errors. The best solution seems to be to serialize the actual textual macro definition and load it the same way the std-macros are. I'm not totally confident that getting the source from the CodeMap will always do the right thing, but it seems to work in simple cases.
2014-01-23Update flip() to be rev().Sean Chalmers-2/+2
Consensus leaned in favour of using rev instead of flip.
2014-01-23Rename Invert to Flip - Issue 10632Sean Chalmers-2/+2
Renamed the invert() function in iter.rs to flip(). Also renamed the Invert<T> type to Flip<T>. Some related code comments changed. Documentation that I could find has been updated, and all the instances I could locate where the function/type were called have been updated as well.
2014-01-23Redo exported macro serializationSteven Fackler-1/+1
The old method of serializing the AST gives totally bogus spans if the expansion of an imported macro causes compilation errors. The best solution seems to be to serialize the actual textual macro definition and load it the same way the std-macros are. I'm not totally confident that getting the source from the CodeMap will always do the right thing, but it seems to work in simple cases.
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-1/+1
2014-01-20auto merge of #11670 : sfackler/rust/extctxt-span-note, r=alexcrichtonbors-0/+4
It was the only span_* missing.
2014-01-19Add span_note to ExtCtxtSteven Fackler-0/+4
It was the only span_* missing.
2014-01-18syntax::ext: replace span_fatal with span_err in many places.Huon Wilson-16/+60
This means that compilation continues for longer, and so we can see more errors per compile. This is mildly more user-friendly because it stops users having to run rustc n times to see n macro errors: just run it once to see all of them.
2014-01-16Load macros from external modulesSteven Fackler-62/+49
2014-01-13librustc: Remove `@` pointer patterns from the languagePatrick Walton-5/+2
2014-01-09libsyntax: Renamed types, traits and enum variants to CamelCase.Eduard Burtescu-22/+22
2014-01-05Use ~-objects instead of @-objects for syntax extsSteven Fackler-6/+6
This is necessary for #11151 to make sure dtors run before the libraries are unloaded.
2014-01-03librustc: De-`@mut` the parse sessionPatrick Walton-3/+3
2014-01-03auto merge of #11228 : sfackler/rust/syntaxenv, r=pcwaltonbors-178/+88
I'd really like to be able to do something like ```rust struct MapChain<'next, K, V> { info: BlockInfo, map: HashMap<K, V>, next: Option<&'next mut MapChain<'next, K, V> } ``` but I can't get the lifetimes to work out.
2014-01-02libsyntax: De-`@mut` `token` in the parserPatrick Walton-1/+1
2014-01-02libsyntax: Make the parser mutablePatrick Walton-3/+3
2014-01-01syntax::diagnostic: Remove unnecessary traitsklutzy-1/+0
This removes trait `handler` and `span_handler`, and renames `HandlerT` to `Handler`, `CodemapT` to `SpanHandler`.
2013-12-30Rewrite SyntaxEnvSteven Fackler-178/+88
I'd really like to be able to do something like struct MapChain<'next, K, V> { info: BlockInfo, map: HashMap<K, V>, next: Option<&'next mut MapChain<'next, K, V> } but I can't get the lifetimes to work out.
2013-12-29Remove @muts from ExtCtxtSteven Fackler-20/+20
2013-12-29Start passing around &mut ExtCtxtSteven Fackler-8/+8
2013-12-29Make ast_fold take &mut selfSteven Fackler-2/+2
2013-12-28Stop passing duplicate parameters in expandSteven Fackler-3/+2
2013-12-28Remove unecessary extern "Rust" specifiersSteven Fackler-17/+8
2013-12-28Stop using @ExtCtxtSteven Fackler-15/+15
2013-12-11Make 'self lifetime illegal.Erik Price-1/+1
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-08Remove dead codesKiet Tran-9/+1
2013-11-28Register new snapshotsAlex Crichton-3/+3
2013-11-26Support multiple item macrosSteven Fackler-1/+2
Closes #4375
2013-11-26rustc: Add lint for obsolete attributesklutzy-7/+1
This also moves `#[auto_{en,de}code]` checker from syntax to lint.
2013-11-19libsyntax: Change all uses of `&fn` to `||`.Patrick Walton-8/+15
2013-10-31Implement a concat!() format extensionAlex Crichton-0/+20
This extension can be used to concatenate string literals at compile time. C has this useful ability when placing string literals lexically next to one another, but this needs to be handled at the syntax extension level to recursively expand macros. The major use case for this is something like: macro_rules! mylog( ($fmt:expr $($arg:tt)*) => { error2!(concat!(file!(), ":", line!(), " - ", $fmt) $($arg)*); }) Where the mylog macro will automatically prepend the filename/line number to the beginning of every log message.
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-3/+3
Who doesn't like a massive renaming?
2013-10-18Remove the fmt! syntax extensionAlex Crichton-1/+1
It lived a good life, but its time has come. The groundwork is set for the official transition after the next snapshot (removal of XXX2 macros)