summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2013-09-23test: Fix rustdoc and tests.Patrick Walton-1/+2
2013-09-23libsyntax: Remove some more `@fn`s from the macro expanderPatrick Walton-79/+159
2013-09-15Reduce the amount of complexity in format!Alex Crichton-7/+1
This renames the syntax-extension file to format from ifmt, and it also reduces the amount of complexity inside by defining all other macros in terms of format_args!
2013-09-12Implement a format_args!() macroAlex Crichton-0/+2
The purpose of this macro is to further reduce the number of allocations which occur when dealing with formatting strings. This macro will perform all of the static analysis necessary to validate that a format string is safe, and then it will wrap up the "format string" into an opaque struct which can then be passed around. Two safe functions are added (write/format) which take this opaque argument structure, unwrap it, and then call the unsafe version of write/format (in an unsafe block). Other than these two functions, it is not intended for anyone to ever look inside this opaque struct. The macro looks a bit odd, but mostly because of rvalue lifetimes this is the only way for it to be safe that I know of. Example use-cases of this are: * third-party libraries can use the default formatting syntax without any forced allocations * the fail!() macro can avoid allocating the format string * the logging macros can avoid allocation any strings
2013-09-10Delay assignment of node ids until after expansion. Ensures that each AST nodeNiko Matsakis-3/+0
has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two representative tests. Fixes #7971 Fixes #6304 Fixes #8367 Fixes #8754 Fixes #8852 Fixes #2543 Fixes #7654
2013-09-06quote_* macros no longer need to be capturingJohn Clements-6/+7
This is actually almost a problem, because those were my poster-child macros for "here's how to implement a capturing macro." Following this change, there will be no macros that use capturing; this will probably make life unpleasant for the first person that wants to implement a capturing macro. I should probably create a dummy_capturing macro, just to show how it works.
2013-09-06WIP: adding mark-cancelling for macro_rulesJohn Clements-2/+1
2013-09-06remove unneeded imports, clean up unused var warningsJohn Clements-2/+2
2013-09-06capturing macros now implementedJohn Clements-32/+60
2013-09-06separate ItemDecorator from ItemDecoratorJohn Clements-2/+2
2013-09-06removed unneccessary SyntaxExpander structsJohn Clements-16/+5
2013-09-03Modernized a few more types in syntax::astMarvin Löbel-6/+6
2013-09-02Renamed syntax::ast::ident -> IdentMarvin Löbel-7/+7
2013-09-01Modernized a few type names in rustc and syntaxMarvin Löbel-17/+17
2013-08-27librustc: Add support for type parameters in the middle of paths.Patrick Walton-17/+3
For example, `foo::<T>::bar::<U>`. This doesn't enforce that the type parameters are in the right positions, however.
2013-08-24Settle on the format/write/print family of namesAlex Crichton-4/+6
2013-08-24Implement a wrapper macro around fprintf -- ifmtfAlex Crichton-1/+3
2013-08-10Merge branch 'enum-method-privacy' of ↵Erick Tryzelaar-10/+10
https://github.com/michaelwoerister/rust into rollup Conflicts: src/libsyntax/opt_vec.rs
2013-08-09auto merge of #8362 : sfackler/rust/env, r=alexcrichtonbors-6/+8
env! aborts compilation of the specified environment variable is not defined and takes an optional second argument containing a custom error message. option_env! creates an Option<&'static str> containing the value of the environment variable. There are no run-pass tests that check the behavior when the environment variable is defined since the test framework doesn't support setting environment variables at compile time as opposed to runtime. However, both env! and option_env! are used inside of rustc itself, which should act as a sufficient test. Fixes #2248.
2013-08-08env! syntax extension changesSteven Fackler-6/+8
env! aborts compilation of the specified environment variable is not defined and takes an optional second argument containing a custom error message. option_env! creates an Option<&'static str> containing the value of the environment variable. There are no run-pass tests that check the behavior when the environment variable is defined since the test framework doesn't support setting environment variables at compile time as opposed to runtime. However, both env! and option_env! are used inside of rustc itself, which should act as a sufficient test. Close #2248
2013-08-08auto merge of #8245 : alexcrichton/rust/fmt2, r=graydonbors-0/+2
This is a reopening of #8182, although this removes any abuse of the compiler internals. Now it's just a pure syntax extension (hard coded what the attribute names are).
2013-08-07Add initial support for a new formatting syntaxAlex Crichton-0/+2
The new macro is available under the name ifmt! (only an intermediate name)
2013-08-07core: option.map_consume -> option.map_moveErick Tryzelaar-1/+1
2013-08-07Enable privacy check for enum methods.Michael Woerister-10/+10
2013-08-05Updated std::Option, std::Either and std::ResultMarvin Löbel-8/+8
- Made naming schemes consistent between Option, Result and Either - Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None) - Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-02auto merge of #8188 : huonw/rust/cfg-macro, r=pcwaltonbors-0/+2
Example: if cfg!(test) { calculation_to_run_only_when_testing(); } Closes #8130.
2013-08-01Remove the pipes compilerBrian Anderson-4/+2
The pipes compiler produced data types that encoded efficient and safe bounded message passing protocols between two endpoints. It was also capable of producing unbounded protocols. It was useful research but was arguably done before its proper time. I am removing it for the following reasons: * In practice we used it only for producing the `oneshot` and `stream` unbounded protocols and all communication in Rust use those. * The interface between the proto! macro and the standard library has a large surface area and was difficult to maintain through language and library changes. * It is now written in an old dialect of Rust and generates code which would likely be considered non-idiomatic. * Both the compiler and the runtime are difficult to understand, and likewise the relationship between the generated code and the library is hard to understand. Debugging is difficult. * The new scheduler implements `stream` and `oneshot` by hand in a way that will be significantly easier to maintain. This shouldn't be taken as an indication that 'channel protocols' for Rust are not worth pursuing again in the future.
2013-08-01syntax: implement cfg!() which evaluates to true/false where #[cfg] would ↵Huon Wilson-0/+2
keep/remove. Example: if cfg!(test) { calculation_to_run_only_when_testing(); }
2013-07-29New naming convention for ast::{node_id, local_crate, crate_node_id, ↵Michael Woerister-1/+1
blk_check_mode, ty_field, ty_method}
2013-07-24Disallow non-comma-delimited arguments to fmt! and bytes!Birunthan Mohanathas-4/+5
Closes #4982.
2013-07-22Ast spanned<T> refactoring, renaming: crate, local, blk, crate_num, crate_cfg.Michael Woerister-3/+3
`crate => Crate` `local => Local` `blk => Block` `crate_num => CrateNum` `crate_cfg => CrateConfig` Also, Crate and Local are not wrapped in spanned<T> anymore.
2013-07-20auto merge of #7902 : huonw/rust/attr++, r=cmr,pcwaltonbors-1/+1
This does a number of things, but especially dramatically reduce the number of allocations performed for operations involving attributes/ meta items: - Converts ast::meta_item & ast::attribute and other associated enums to CamelCase. - Converts several standalone functions in syntax::attr into methods, defined on two traits AttrMetaMethods & AttributeMethods. The former is common to both MetaItem and Attribute since the latter is a thin wrapper around the former. - Deletes functions that are unnecessary due to iterators. - Converts other standalone functions to use iterators and the generic AttrMetaMethods rather than allocating a lot of new vectors (e.g. the old code would have to allocate a new vector to use functions that operated on &[meta_item] on &[attribute].) - Moves the core algorithm of the #[cfg] matching to syntax::attr, similar to find_inline_attr and find_linkage_metas. This doesn't have much of an effect on the speed of #[cfg] stripping, despite hugely reducing the number of allocations performed; presumably most of the time is spent in the ast folder rather than doing attribute checks. Also fixes the Eq instance of MetaItem_ to correctly ignore spans, so that `rustc --cfg 'foo(bar)'` now works.
2013-07-20syntax: modernise attribute handling in syntax::attr.Huon Wilson-1/+1
This does a number of things, but especially dramatically reduce the number of allocations performed for operations involving attributes/ meta items: - Converts ast::meta_item & ast::attribute and other associated enums to CamelCase. - Converts several standalone functions in syntax::attr into methods, defined on two traits AttrMetaMethods & AttributeMethods. The former is common to both MetaItem and Attribute since the latter is a thin wrapper around the former. - Deletes functions that are unnecessary due to iterators. - Converts other standalone functions to use iterators and the generic AttrMetaMethods rather than allocating a lot of new vectors (e.g. the old code would have to allocate a new vector to use functions that operated on &[meta_item] on &[attribute].) - Moves the core algorithm of the #[cfg] matching to syntax::attr, similar to find_inline_attr and find_linkage_metas. This doesn't have much of an effect on the speed of #[cfg] stripping, despite hugely reducing the number of allocations performed; presumably most of the time is spent in the ast folder rather than doing attribute checks. Also fixes the Eq instance of MetaItem_ to correctly ignore spaces, so that `rustc --cfg 'foo(bar)'` now works.
2013-07-18librustc: Forbid `&` pointers (other than `&'static`) inside `@` boxes.Patrick Walton-2/+1
This makes custom borrowing implementations for custom smart pointers sound.
2013-07-17librustc: Remove all uses of the `Copy` bound.Patrick Walton-1/+1
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-2/+2
2013-07-17librustc: Add a lint mode for unnecessary `copy` and remove a bunch of them.Patrick Walton-1/+1
2013-07-12Remove the global 'vec::to_owned' functionAlex Crichton-2/+1
2013-07-07De-managed ast::PathJames Miller-1/+1
2013-07-05Do not rely on newtype enum dereferenceSeo Sanghyeon-10/+7
2013-06-29'Borrow' stack closures rather than copying them (e.g., "|x|f(x)"), in prep ↵Ben Blum-1/+1
for making them noncopyable.
2013-06-25great renaming propagation: syntaxCorey Richardson-5/+3
2013-06-13Revert "std: convert {vec,str}::to_owned to methods."Brian Anderson-1/+2
This fixes the strange random crashes in compile-fail tests. This reverts commit 96cd61ad034cc9e88ab6a7845c3480dbc1ea62f3. Conflicts: src/librustc/driver/driver.rs src/libstd/str.rs src/libsyntax/ext/quote.rs
2013-06-13Use @str instead of @~str in libsyntax and librustc. Fixes #5048.Huon Wilson-21/+21
This almost removes the StringRef wrapper, since all strings are Equiv-alent now. Removes a lot of `/* bad */ copy *`'s, and converts several things to be &'static str (the lint table and the intrinsics table). There are many instances of .to_managed(), unfortunately.
2013-06-12std: unify the str -> [u8] functions as 3 methods: .as_bytes() and ↵Huon Wilson-1/+0
.as_bytes_with_null[_consume](). The first acts on &str and is not nul-terminated, the last two act on strings that are always null terminated (&'static str, ~str and @str).
2013-06-12std: convert {vec,str}::to_owned to methods.Huon Wilson-1/+1
2013-06-05add hygiene support functionsJohn Clements-0/+10
2013-06-05remove unused get_ident_interner'sJohn Clements-1/+1
2013-06-05token_to_ident takes argument by referenceJohn Clements-1/+1
2013-06-05interner just uses uints, not idents with syntax contextJohn Clements-3/+3