about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2013-08-08env! syntax extension changesSteven Fackler-17/+37
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-1/+725
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-1/+725
The new macro is available under the name ifmt! (only an intermediate name)
2013-08-07core: option.map_consume -> option.map_moveErick Tryzelaar-2/+2
2013-08-07Enable privacy check for enum methods.Michael Woerister-10/+10
2013-08-07auto merge of #8285 : huonw/rust/deriving+++, r=alexcrichtonbors-16/+47
Some general clean-up relating to deriving: - `TotalOrd` was too eager, and evaluated the `.cmp` call for every field, even if it could short-circuit earlier. - the pointer types didn't have impls for `TotalOrd` or `TotalEq`. - the Makefiles didn't reach deep enough into libsyntax for dependencies. (Split out from https://github.com/mozilla/rust/pull/8258.)
2013-08-05Updated std::Option, std::Either and std::ResultMarvin Löbel-14/+14
- 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-04syntax: make #[deriving(TotalOrd)] lazy.Huon Wilson-16/+47
Previously it would call: f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...)) (where s/of1 = 'self/other field 1', and f was std::cmp::lexical_ordering) This meant that every .cmp subcall got evaluated when calling a derived TotalOrd.cmp. This corrects this to use let test = sf1.cmp(&of1); if test == Equal { let test = sf2.cmp(&of2); if test == Equal { // ... } else { test } } else { test } This gives a lexical ordering by short-circuiting on the first comparison that is not Equal.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-37/+37
this has been replaced by `for`
2013-08-03auto merge of #8206 : omasanori/rust/blk-to-block, r=graydonbors-35/+35
Just for consistency.
2013-08-02librustc: Introduce a new visitor type based on traits and port syntax to it.Patrick Walton-31/+149
This is preparation for removing `@fn`. This does *not* use default methods yet, because I don't know whether they work. If they do, a forthcoming PR will use them. This also changes the precedence of `as`.
2013-08-02auto merge of #8188 : huonw/rust/cfg-macro, r=pcwaltonbors-0/+47
Example: if cfg!(test) { calculation_to_run_only_when_testing(); } Closes #8130.
2013-08-02replace `range` with an external iteratorDaniel Micay-10/+7
2013-08-02Replace 'blk' -> 'block' in AstBuilder.OGINO Masanori-35/+35
I didn't rename variables because they are local and are not parts of the public interfaces. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-01auto merge of #8170 : brson/rust/nopipes, r=pcwaltonbors-1158/+3
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` protcol and the unbounded `stream` protocol 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. Concerned parties may include: @graydon, @pcwalton, @eholk, @bblum The most likely candidates for closing are #7666, #3018, #3020, #7021, #7667, #7303, #3658, #3295.
2013-08-01Remove the pipes compilerBrian Anderson-1158/+3
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-01std: Change `Times` trait to use `do` instead of `for`blake2-ppc-1/+1
Change the former repetition:: for 5.times { } to:: do 5.times { } .times() cannot be broken with `break` or `return` anymore; for those cases, use a numerical range loop instead.
2013-08-01syntax: implement cfg!() which evaluates to true/false where #[cfg] would ↵Huon Wilson-0/+47
keep/remove. Example: if cfg!(test) { calculation_to_run_only_when_testing(); }
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-40/+40
2013-07-31auto merge of #8162 : thestinger/rust/no-copy, r=brsonbors-8/+8
2013-08-01make `in` and `foreach` get treated as keywordsDaniel Micay-8/+8
2013-07-31auto merge of #8150 : dotdash/rust/assert_bloat, r=huonwbors-1/+1
Assertions without a message get a generated message that consists of a prefix plus the stringified expression that is being asserted. That prefix is currently a unique string, while a static string would be sufficient and needs less code.
2013-07-31Reduce code bloat from assert!()Björn Steinbrink-1/+1
Assertions without a message get a generated message that consists of a prefix plus the stringified expression that is being asserted. That prefix is currently a unique string, while a static string would be sufficient and needs less code.
2013-07-30syntax: implement foreach .. in .. { .. } via desugaring.Graydon Hoare-1/+155
2013-07-30Added str::char_offset_iter() and str::rev_char_offset_iter()Marvin Löbel-1/+1
Renamed bytes_iter to byte_iter to match other iterators Refactored str Iterators to use DoubleEnded Iterators and typedefs instead of wrapper structs Reordered the Iterator section Whitespace fixup Moved clunky `each_split_within` function to the one place in the tree where it's actually needed Replaced all block doccomments in str with line doccomments
2013-07-30auto merge of #8107 : michaelwoerister/rust/end_of_spanned, r=cmrbors-9/+9
Contiunation of naming cleanup in `libsyntax::ast`: ```rust ast::node_id => ast::NodeId ast::local_crate => ast::LOCAL_CRATE ast::crate_node_id => ast::CRATE_NODE_ID ast::blk_check_mode => ast::BlockCheckMode ast::ty_field => ast::TypeField ast::ty_method => ast::TypeMethod ``` Also moved span field directly into `TypeField` struct and cleaned up overlooked `ast::CrateConfig` renamings from last pull request. Cheers, Michael
2013-07-29New naming convention for ast::{node_id, local_crate, crate_node_id, ↵Michael Woerister-9/+9
blk_check_mode, ty_field, ty_method}
2013-07-29Added %p directive to fmt!, which expects *T as argumentDo Nhat Minh-0/+2
2013-07-24Disallow non-comma-delimited arguments to fmt! and bytes!Birunthan Mohanathas-6/+7
Closes #4982.
2013-07-24Change 'print(fmt!(...))' to printf!/printfln! in src/lib*Birunthan Mohanathas-7/+5
2013-07-22De-spanned<T> and renamed ast::field (now ast::Field)Michael Woerister-7/+7
2013-07-22Ast spanned<T> refactoring, renaming: crate, local, blk, crate_num, crate_cfg.Michael Woerister-42/+42
`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-73/+72
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-73/+72
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-17libsyntax: Remove some multi-gigabyte clones that were preventing ↵Patrick Walton-6/+6
bootstrapping on Windows.
2013-07-17librustc: Remove all uses of the `Copy` bound.Patrick Walton-3/+3
2013-07-17librustc: Remove `copy` expressions from the language.Patrick Walton-4/+0
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-81/+104
2013-07-17librustc: Add a lint mode for unnecessary `copy` and remove a bunch of them.Patrick Walton-33/+30
2013-07-17Made ast::blk not use spanned<T> anymore.Michael Woerister-16/+15
2013-07-17Clean-up tests after debug!/std-macros change.Huon Wilson-1/+2
The entire testsuite is converted to using info! rather than debug! because some depend on the code within the debug! being trans'd.
2013-07-16syntax: make a macros-injection pass; conditionally define debug! to a noop ↵Huon Wilson-42/+59
based on cfg(debug). Macros can be conditionally defined because stripping occurs before macro expansion, but, the built-in macros were only added as part of the actual expansion process and so couldn't be stripped to have definitions conditional on cfg flags. debug! is defined conditionally in terms of the debug config, expanding to nothing unless the --cfg debug flag is passed (to be precise it expands to `if false { normal_debug!(...) }` so that they are still type checked, and to avoid unused variable lints).
2013-07-14Make TLS keys actually take up spaceAlex Crichton-2/+6
If the TLS key is 0-sized, then the linux linker is apparently smart enough to put everything at the same pointer. OSX on the other hand, will reserve some space for all of them. To get around this, the TLS key now actuall consumes space to ensure that it gets a unique pointer
2013-07-14Purge the last remnants of the old TLS apiAlex Crichton-6/+6
Closes #3273
2013-07-14Clean up various warnings throughout the codebaseAlex Crichton-1/+2
2013-07-13Rename print!()/println!() to printf!()/printfln!()Kevin Ballard-8/+14
The new names make it obvious that these generate formatted output. Add a one-argument case that uses %? to format, just like the other format-using macros (e.g. info!()).
2013-07-13Add print! and println! macros. Closes #7653.Birunthan Mohanathas-0/+12
2013-07-12auto merge of #7736 : thestinger/rust/doc, r=thestingerbors-16/+7
2b96408 r=sanxiyn documents conversion, size hints and double-ended iterators and adds more of the traits to the prelude
2013-07-12Remove the global 'vec::to_owned' functionAlex Crichton-16/+7