about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2014-03-15Tag derived impls with #[automatically_derived]Steven Fackler-8/+4
This will enable rustdoc to treat them specially.
2014-03-15rustc: Remove compiler support for __log_level()Alex Crichton-1/+1
This commit removes all internal support for the previously used __log_level() expression. The logging subsystem was previously modified to not rely on this magical expression. This also removes the only other function to use the module_data map in trans, decl_gc_metadata. It appears that this is an ancient function from a GC only used long ago. This does not remove the crate map entirely, as libgreen still uses it to hook in to the event loop provided by libgreen.
2014-03-15log: Introduce liblog, the old std::loggingAlex Crichton-1/+12
This commit moves all logging out of the standard library into an external crate. This crate is the new crate which is responsible for all logging macros and logging implementation. A few reasons for this change are: * The crate map has always been a bit of a code smell among rust programs. It has difficulty being loaded on almost all platforms, and it's used almost exclusively for logging and only logging. Removing the crate map is one of the end goals of this movement. * The compiler has a fair bit of special support for logging. It has the __log_level() expression as well as generating a global word per module specifying the log level. This is unfairly favoring the built-in logging system, and is much better done purely in libraries instead of the compiler itself. * Initialization of logging is much easier to do if there is no reliance on a magical crate map being available to set module log levels. * If the logging library can be written outside of the standard library, there's no reason that it shouldn't be. It's likely that we're not going to build the highest quality logging library of all time, so third-party libraries should be able to provide just as high-quality logging systems as the default one provided in the rust distribution. With a migration such as this, the change does not come for free. There are some subtle changes in the behavior of liblog vs the previous logging macros: * The core change of this migration is that there is no longer a physical log-level per module. This concept is still emulated (it is quite useful), but there is now only a global log level, not a local one. This global log level is a reflection of the maximum of all log levels specified. The previously generated logging code looked like: if specified_level <= __module_log_level() { println!(...) } The newly generated code looks like: if specified_level <= ::log::LOG_LEVEL { if ::log::module_enabled(module_path!()) { println!(...) } } Notably, the first layer of checking is still intended to be "super fast" in that it's just a load of a global word and a compare. The second layer of checking is executed to determine if the current module does indeed have logging turned on. This means that if any module has a debug log level turned on, all modules with debug log levels get a little bit slower (they all do more expensive dynamic checks to determine if they're turned on or not). Semantically, this migration brings no change in this respect, but runtime-wise, this will have a perf impact on some code. * A `RUST_LOG=::help` directive will no longer print out a list of all modules that can be logged. This is because the crate map will no longer specify the log levels of all modules, so the list of modules is not known. Additionally, warnings can no longer be provided if a malformed logging directive was supplied. The new "hello world" for logging looks like: #[phase(syntax, link)] extern crate log; fn main() { debug!("Hello, world!"); }
2014-03-13auto merge of #12798 : pczarn/rust/inline-asm, r=alexcrichtonbors-50/+69
## read+write modifier '+' This small sugar was left out in the original implementation (#5359). When an output operand with the '+' modifier is encountered, we store the index of that operand alongside the expression to create and append an input operand later. The following lines are equivalent: ``` asm!("" : "+m"(expr)); asm!("" : "=m"(expr) : "0"(expr)); ``` ## misplaced options and clobbers give a warning It's really annoying when a small typo might change behavior without any warning. ``` asm!("mov $1, $0" : "=r"(x) : "r"(8u) : "cc" , "volatile"); //~^ WARNING expected a clobber, but found an option ``` ## liveness Fixed incorrect order of propagation. Sometimes it caused spurious warnings in code: `warning: value assigned to `i` is never read, #[warn(dead_assignment)] on by default` ~~Note: Rebased on top of another PR. (uses other changes)~~ * [x] Implement read+write * [x] Warn about misplaced options * [x] Fix liveness (`dead_assignment` lint) * [x] Add all tests
2014-03-13Fix and improve inline assembly.Piotr Czarnecki-50/+69
Read+write modifier Some documentation in asm.rs rpass and cfail tests
2014-03-13Remove Rc's borrow method to avoid conflicts with RefCell's borrow in ↵Eduard Burtescu-2/+2
Rc<RefCell<T>>.
2014-03-12syntax: change the #[deriving(Hash)] typaram variable nameErick Tryzelaar-3/+3
2014-03-12Changed lists of lifetimes in ast and ty to use Vec instead of OptVec.Felix S. Klock II-20/+19
There is a broader revision (that does this across the board) pending in #12675, but that is awaiting the arrival of more data (to decide whether to keep OptVec alive by using a non-Vec internally). For this code, the representation of lifetime lists needs to be the same in both ScopeChain and in the ast and ty structures. So it seemed cleanest to just use `vec_ng::Vec`, now that it has a cheaper empty representation than the current `vec` code.
2014-03-12alpha-rename .ident to .name in Lifetime, including in rustdoc.Felix S. Klock II-2/+2
2014-03-12Update users for the std::rand -> librand move.Huon Wilson-1/+1
2014-03-12std: Move rand to librand.Huon Wilson-4/+3
This functionality is not super-core and so doesn't need to be included in std. It's possible that std may need rand (it does a little bit now, for io::test) in which case the functionality required could be moved to a secret hidden module and reexposed by librand. Unfortunately, using #[deprecated] here is hard: there's too much to mock to make it feasible, since we have to ensure that programs still typecheck to reach the linting phase.
2014-03-11Add an ItemModifier syntax extension typeSteven Fackler-11/+65
Where ItemDecorator creates new items given a single item, ItemModifier alters the tagged item in place. The expansion rules for this are a bit weird, but I think are the most reasonable option available. When an item is expanded, all ItemModifier attributes are stripped from it and the item is folded through all ItemModifiers. At that point, the process repeats until there are no ItemModifiers in the new item.
2014-03-08Removed DeepClone. Issue #12698.Michael Darakananda-31/+0
2014-03-07rename ast::ViewItemExternMod to ast::ViewItemExternCrate, and ↵Liigo Zhuang-2/+2
clean::ExternMod to clean::ExternCrate
2014-03-06syntax: Conditionally deriving(Hash) with WritersAlex Crichton-16/+49
If #[feature(default_type_parameters)] is enabled for a crate, then deriving(Hash) will expand with Hash<W: Writer> instead of Hash<SipState> so more hash algorithms can be used.
2014-03-05Refactor and fix FIXME's in mtwt hygiene codeEdward Wang-59/+541
- Moves mtwt hygiene code into its own file - Fixes FIXME's which leads to ~2x speed gain in expansion pass - It is now @-free
2014-03-04Expand nested items within a backtrace.Nick Cameron-6/+7
Fixes a regression from #4913 which causes items to be exanded with spans lacking expn_info from the context's current backtrace.
2014-03-03syntax: make match arms store the expr directly.Huon Wilson-3/+3
Previously `ast::Arm` was always storing a single `ast::Expr` wrapped in an `ast::Block` (for historical reasons, AIUI), so we might as just store that expr directly. Closes #3085.
2014-03-02auto merge of #12662 : sfackler/rust/unexported-type, r=cmrbors-2/+2
2014-03-02Make visible types public in rustcSteven Fackler-2/+2
2014-03-02Expand string literals and exprs inside of macrosSteven Fackler-22/+9
A couple of syntax extensions manually expanded expressions, but it wasn't done universally, most noticably inside of asm!(). There's also a bit of random cleanup.
2014-03-01libsyntax: Fix errors arising from the automated `~[T]` conversionPatrick Walton-133/+289
2014-03-01libsyntax: Mechanically change `~[T]` to `Vec<T>`Patrick Walton-600/+556
2014-02-28syntax: Expand format!() deterministicallyAlex Crichton-13/+26
Previously, format!("{a}{b}", a=foo(), b=bar()) has foo() and bar() run in a nondeterminisc order. This is clearly a non-desirable property, so this commit uses iteration over a list instead of iteration over a hash map to provide deterministic code generation of these format arguments.
2014-02-27Fix syntax::ext::deriving{,::*} docs formatting.Chris Morgan-15/+17
The most significant fix is for `syntax::ext::deriving::encodable`, where one of the blocks of code, auspiciously containing `<S>` (recall that Markdown allows arbitrary HTML to be contained inside it), was not formatted as a code block, with a fun but messy effect.
2014-02-26Replace callee_id with information stored in method_map.Eduard Burtescu-5/+4
2014-02-24Gate default type parameter overrides.Eduard Burtescu-16/+4
Fixes #12423.
2014-02-24Remove deriving(ToStr)Alex Crichton-134/+0
This has been superseded by deriving(Show). cc #9806
2014-02-23auto merge of #12510 : huonw/rust/fix-compiler-docs, r=alexcrichtonbors-12/+12
This includes blocks made by indentation, so they need to be changed to explicitly have ```notrust ... ``` fences..
2014-02-24Update rustc/syntax docs now that rustdoc lexes all non-`notrust` code blocks.Huon Wilson-12/+12
This includes blocks made by indentation, so they need to be changed to explicitly have ```notrust ... ``` fences..
2014-02-23auto merge of #12338 : edwardw/rust/hygienic-break-continue, r=cmrbors-4/+32
Makes labelled loops hygiene by performing renaming of the labels defined in e.g. `'x: loop { ... }` and then used in break and continue statements within loop body so that they act hygienically when used with macros. Closes #12262.
2014-02-24Transition to new `Hash`, removing IterBytes and std::to_bytes.Huon Wilson-102/+0
2014-02-23Make break and continue hygienicEdward Wang-4/+32
Makes labelled loops hygiene by performing renaming of the labels defined in e.g. `'x: loop { ... }` and then used in break and continue statements within loop body so that they act hygienically when used with macros. Closes #12262.
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-5/+6
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-22auto merge of #12451 : edwardw/rust/ident-2-name, r=cmrbors-8/+8
Closes #7743.
2014-02-21std: rewrite Hash to make it more genericErick Tryzelaar-6/+105
This patch merges IterBytes and Hash traits, which clears up the confusion of using `#[deriving(IterBytes)]` to support hashing. Instead, it now is much easier to use the new `#[deriving(Hash)]` for making a type hashable with a stream hash. Furthermore, it supports custom non-stream-based hashers, such as if a value's hash was cached in a database. This does not yet replace the old IterBytes-hash with this new version.
2014-02-21syntax: add syntax extension helper to make simple view itemsErick Tryzelaar-0/+17
2014-02-21syntax: Allow syntax extensions to have attributesErick Tryzelaar-8/+26
2014-02-22Represent lifetimes as Names instead of IdentsEdward Wang-8/+8
Closes #7743.
2014-02-19librustc: Remove unique vector patterns from the language.Patrick Walton-53/+56
Preparatory work for removing unique vectors from the language, which is itself preparatory work for dynamically sized types.
2014-02-19auto merge of #12349 : edwardw/rust/debug-expansion, r=huonwbors-6/+40
Currently, the format_args! macro and its downstream macros in turn expand to series of let statements, one for each of its arguments, and then the invocation of the macro function. If one or more of the arguments are RefCell's, the enclosing statement for the temporary of the let is the let itself, which leads to scope problem. This patch changes let's to a match expression. Closes #12239.
2014-02-19Change the format_args! macro expansion for temporariesEdward Wang-6/+40
Currently, the format_args! macro and its downstream macros in turn expand to series of let statements, one for each of its arguments, and then the invocation of the macro function. If one or more of the arguments are RefCell's, the enclosing statement for the temporary of the let is the let itself, which leads to scope problem. This patch changes let's to a match expression. Closes #12239.
2014-02-18Avoid returning original macro if expansion fails.Douglas Young-28/+34
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-14Fix all code examplesAlex Crichton-12/+20
2014-02-14Removed the obsolete ast::CallSugar (previously used by `do`).Eduard Burtescu-4/+3
2014-02-14Expand ItemDecorator extensions in all contextsSteven Fackler-52/+33
Now that fold_item can return multiple items, this is pretty trivial. It also recursively expands generated items so ItemDecorators can generate items that are tagged with ItemDecorators! Closes #4913
2014-02-14auto merge of #12234 : sfackler/rust/restructure-item-decorator, r=huonwbors-74/+76
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-111/+77
2014-02-13Tweak ItemDecorator APISteven Fackler-74/+76
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-13/+13
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.