about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2013-08-19auto merge of #8535 : nikomatsakis/rust/issue-3678-wrappers-be-gone-2, r=graydonbors-0/+79
Long-standing branch to remove foreign function wrappers altogether. Calls to C functions are done "in place" with no stack manipulation; the scheme relies entirely on the correct use of `#[fixed_stack_segment]` to guarantee adequate stack space. A linter is added to detect when `#[fixed_stack_segment]` annotations are missing. An `externfn!` macro is added to make it easier to declare foreign fns and wrappers in one go: this macro may need some refinement, though, for example it might be good to be able to declare a group of foreign fns. I leave that for future work (hopefully somebody else's work :) ). Fixes #3678.
2013-08-19Add externfn macro and correctly label fixed_stack_segmentsNiko Matsakis-0/+79
2013-08-19auto merge of #8564 : alexcrichton/rust/ifmt+++, r=graydonbors-23/+20
See discussion in #8489, but this selects option 3 by adding a `Default` trait to be implemented by various basic types. Once this makes it into a snapshot I think it's about time to start overhauling all current use-cases of `fmt!` to move towards `ifmt!`. The goal is to replace `%X` with `{}` in 90% of situations, and this commit should enable that.
2013-08-18quote_*! macros take an ExtCtxSteven Fackler-154/+114
They previously required one called "ext_cx" to be in scope. Fixes part of #7727
2013-08-16Delegate `{}` to Default instead of PolyAlex Crichton-23/+20
By using a separate trait this is overridable on a per-type basis and makes room for the possibility of even more arguments passed in for the future.
2013-08-16auto merge of #8534 : huonw/rust/tls-key-macro, r=alexcrichtonbors-0/+11
This allows the internal implementation details of the TLS keys to be changed without requiring the update of all the users. (Or, applying changes that *have* to be applied for the keys to work correctly, e.g. forcing LLVM to not merge these constants.)
2013-08-16syntax: add a local_data_key macro that creates a key for access to the TLS.Huon Wilson-0/+11
This allows the internal implementation details of the TLS keys to be changed without requiring the update of all the users. (Or, applying changes that have to be applied for the keys to work correctly, e.g. forcing LLVM to not merge these constants.)
2013-08-15Switch to new <V:Visitor> visitor (rather than @Visitor).Felix S. Klock II-37/+37
Alpha-renamed top-level visit_* functions to walk_*. (Motivation: Distinguish visit action and recursive traversal.) Abstract over `&mut self` rather than over `@mut self`. This required some acrobatics, notably the `impl<E> Visitor<E> for @mut Visitor<E>` and corresponding introduction of `@mut Visitor` and some local `let mut` bindings. Remove oldvisit reference. Added default implementations for all of the Visitor trait methods. Note that both `visit_expr_post` and `visit_ty` are no-op's by default, just like they are in `oldvisit::default_visitor`. Refactoring: extract logic to ease swapping visit for oldvisit (hopefully).
2013-08-14auto merge of #8440 : sfackler/rust/env-fix, r=pcwaltonbors-1/+1
The type of the result of option_env! was not fully specified in the None case, leading to type check failures in the case where the variable was not defined (e.g. option_env!("FOO").is_none()). Also cleaned up some compilation warnings.
2013-08-13auto merge of #8446 : alexcrichton/rust/ifmt++, r=graydonbors-14/+26
This includes a number of improvements to `ifmt!` * Implements formatting arguments -- `{:0.5x}` works now * Formatting now works on all integer widths, not just `int` and `uint` * Added a large doc block to `std::fmt` which should help explain what `ifmt!` is all about * Added floating point formatters, although they have the same pitfalls from before (they're just proof-of-concept now) Closed a couple of issues along the way, yay! Once this gets into a snapshot, I'll start looking into removing all of `fmt`
2013-08-13Add `f` formats to `ifmt!`Alex Crichton-5/+6
Currently the work just the same as the old `extfmt` versions
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-4/+4
Closes #5495
2013-08-12Correct the padding on integer types for formattingAlex Crichton-5/+13
2013-08-12Define integer formats for all widthsAlex Crichton-0/+1
Closes #1653
2013-08-12Implement formatting arguments for strings and integersAlex Crichton-5/+7
Closes #1651
2013-08-11Fixed option_env! typeSteven Fackler-1/+1
The type of the result of option_env! was not fully specified in the None case, leading to type check failures in the case where the variable was not defined (e.g. option_env!("FOO").is_none()).
2013-08-11auto merge of #8455 : nikomatsakis/rust/issue-5762-objects-dralston-d, r=graydonbors-28/+28
Fix #5762 and various other aspects of object invocation. r? @graydon
2013-08-11auto merge of #8420 : blake2-ppc/rust/shrink-token, r=cmrbors-5/+5
`enum Token` was 192 bytes (64-bit), as pointed out by pnkfelix; the only bloating variant being `INTERPOLATED(nonterminal)`. Updating `enum nonterminal` to use ~ where variants included big types, shrunk size_of(Token) to 32 bytes (64-bit). I am unsure if the `nt_ident` variant should have an indirection, with ast::ident being only 16 bytes (64-bit), but without this, enum Token would be 40 bytes. A dumb benchmark says that compilation time is unchanged, while peak memory usage for compiling std.rs is down 3% Before:: $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc --cfg stage1 src/libstd/std.rs 19.00user 0.39system 0:19.41elapsed 99%CPU (0avgtext+0avgdata 627820maxresident)k 0inputs+28896outputs (0major+228665minor)pagefaults 0swaps $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc -O --cfg stage1 src/libstd/std.rs 31.64user 0.34system 0:32.02elapsed 99%CPU (0avgtext+0avgdata 629876maxresident)k 0inputs+22432outputs (0major+229411minor)pagefaults 0swaps After:: $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc --cfg stage1 src/libstd/std.rs 19.07user 0.45system 0:19.55elapsed 99%CPU (0avgtext+0avgdata 609384maxresident)k 0inputs+28896outputs (0major+221997minor)pagefaults 0swaps $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc -O --cfg stage1 src/libstd/std.rs 31.90user 0.34system 0:32.28elapsed 99%CPU (0avgtext+0avgdata 612080maxresident)k 0inputs+22432outputs (0major+223726minor)pagefaults 0swaps
2013-08-11libsyntax: Update from `@Object` to `@mut Object` as requiredNiko Matsakis-28/+28
2013-08-11auto merge of #8421 : alexcrichton/rust/unnamed-addr, r=thestingerbors-2/+11
This can be applied to statics and it will indicate that LLVM will attempt to merge the constant in .data with other statics. I have preliminarily applied this to all of the statics generated by the new `ifmt!` syntax extension. I compiled a file with 1000 calls to `ifmt!` and a separate file with 1000 calls to `fmt!` to compare the sizes, and the results were: ``` fmt 310k ifmt (before) 529k ifmt (after) 202k ``` This now means that ifmt! is both faster and smaller than fmt!, yay!
2013-08-11syntax: Shrink enum Token and enum nonterminalblake2-ppc-5/+5
`enum Token` was 192 bytes (64-bit), as pointed out by pnkfelix; the only bloating variant being `INTERPOLATED(nonterminal)`. Updating `enum nonterminal` to use ~ where variants included big types, shrunk size_of(Token) to 32 bytes (64-bit). I am unsure if the `nt_ident` variant should have an indirection, with ast::ident being only 16 bytes (64-bit), but without this, enum Token would be 40 bytes. A dumb benchmark says that compilation time is unchanged, while peak memory usage for compiling std.rs is down 3% Before:: $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc --cfg stage1 src/libstd/std.rs 19.00user 0.39system 0:19.41elapsed 99%CPU (0avgtext+0avgdata 627820maxresident)k 0inputs+28896outputs (0major+228665minor)pagefaults 0swaps $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc -O --cfg stage1 src/libstd/std.rs 31.64user 0.34system 0:32.02elapsed 99%CPU (0avgtext+0avgdata 629876maxresident)k 0inputs+22432outputs (0major+229411minor)pagefaults 0swaps After:: $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc --cfg stage1 src/libstd/std.rs 19.07user 0.45system 0:19.55elapsed 99%CPU (0avgtext+0avgdata 609384maxresident)k 0inputs+28896outputs (0major+221997minor)pagefaults 0swaps $ time ./x86_64-unknown-linux-gnu/stage1/bin/rustc -O --cfg stage1 src/libstd/std.rs 31.90user 0.34system 0:32.28elapsed 99%CPU (0avgtext+0avgdata 612080maxresident)k 0inputs+22432outputs (0major+223726minor)pagefaults 0swaps
2013-08-10Merge branch 'issue-8393-attributes-in-macros' of ↵Erick Tryzelaar-0/+2
https://github.com/nikomatsakis/rust into rollup
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-10syntax and rustc: fix some warningsErick Tryzelaar-1/+1
2013-08-10std: Iterator.chain_ -> .chainErick Tryzelaar-1/+1
2013-08-10std: Rename Iterator.transform -> .mapErick Tryzelaar-15/+15
cc #5898
2013-08-10Clean up some unused imports in testsErick Tryzelaar-1/+0
2013-08-10Mass rename of .consume{,_iter}() to .move_iter()Erick Tryzelaar-4/+4
cc #7887
2013-08-09Implement an `address_insignificant` attributeAlex Crichton-3/+12
This can be applied to statics and it will indicate that LLVM will attempt to merge the constant in .data with other statics. I have preliminarily applied this to all of the statics generated by the new `ifmt!` syntax extension. I compiled a file with 1000 calls to `ifmt!` and a separate file with 1000 calls to `fmt!` to compare the sizes, and the results were: fmt 310k ifmt (before) 529k ifmt (after) 202k This now means that ifmt! is both faster and smaller than fmt!, yay!
2013-08-09auto merge of #8362 : sfackler/rust/env, r=alexcrichtonbors-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. Fixes #2248.
2013-08-08Allow attributes to appear as macro argumentsNiko Matsakis-0/+2
Fixes #8393
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