about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2014-07-09ast: make Name its own typeCorey Richardson-0/+3
2014-07-09syntax: don't process string/char/byte/binary litsCorey Richardson-3/+3
This shuffles things around a bit so that LIT_CHAR and co store an Ident which is the original, unaltered literal in the source. When creating the AST, unescape and postprocess them. This changes how syntax extensions can work, slightly, but otherwise poses no visible changes. To get a useful value out of one of these tokens, call `parse::{char_lit, byte_lit, bin_lit, str_lit}` [breaking-change]
2014-07-09syntax: doc comments all the thingsCorey Richardson-12/+11
2014-07-08introducing let-syntaxJohn Clements-2/+9
The let-syntax expander is different in that it doesn't apply a mark to its token trees before expansion. This is used for macro_rules, and it's because macro_rules is essentially MTWT's let-syntax. You don't want to mark before expand sees let-syntax, because there's no "after" syntax to mark again. In some sense, the cleaner approach might be to introduce a new AST node that macro_rules expands into; this would make it clearer that the expansion of a macro is distinct from the addition of a new macro binding. This should work for now, though...
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-1/+1
[breaking-change]
2014-07-05rustc: Remove CrateId and all related supportAlex Crichton-1/+1
This commit removes all support in the compiler for the #[crate_id] attribute and all of its derivative infrastructure. A list of the functionality removed is: * The #[crate_id] attribute no longer exists * There is no longer the concept of a version of a crate * Version numbers are no longer appended to symbol names * The --crate-id command line option has been removed To migrate forward, rename #[crate_id] to #[crate_name] and only the name of the crate itself should be mentioned. The version/path of the old crate id should be removed. For a transitionary state, the #[crate_id] attribute is still accepted if the #[crate_name] is not present, but it is warned about if it is the only identifier present. RFC: 0035-remove-crate-id [breaking-change]
2014-07-04move RenameList to mtwt, add new_renames abstractionJohn Clements-4/+2
2014-07-03Simplify creating a parser from a token treePiotr Jawniak-5/+7
Closes #15306
2014-07-03Fix spelling errors.Joseph Crail-1/+1
2014-06-23Allow trailing comma in `concat!`Stepan Koltsov-2/+5
(And in other extensions implemented with `get_exprs_from_tts` function).
2014-06-15Register new snapshotsAlex Crichton-2/+2
2014-06-14rustc: Obsolete the `@` syntax entirelyAlex Crichton-1/+1
This removes all remnants of `@` pointers from rustc. Additionally, this removes the `GC` structure from the prelude as it seems odd exporting an experimental type in the prelude by default. Closes #14193 [breaking-change]
2014-06-11rustc: Move the AST from @T to Gc<T>Alex Crichton-6/+6
2014-06-11syntax: Move the AST from @T to Gc<T>Alex Crichton-30/+31
2014-06-10Fix more misspelled comments and strings.Joseph Crail-1/+1
2014-06-09Implement #[plugin_registrar]Keegan McAllister-15/+4
See RFC 22. [breaking-change]
2014-06-05Fallout from the libcollections movementAlex Crichton-1/+1
2014-05-28Add patterns to MacResultKeegan McAllister-0/+30
2014-05-27std: Rename strbuf operations to stringRicho Healey-1/+1
[breaking-change]
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-4/+4
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-3/+6
2014-05-15syntax: Add a macro, format_args_method!()Alex Crichton-1/+4
Currently, the format_args!() macro takes as its first argument an expression which is the callee of an ExprCall. This means that if format_args!() is used with calling a method a closure must be used. Consider this code, however: format_args!(|args| { foo.writer.write_fmt(args) }, "{}", foo.field) The closure borrows the entire `foo` structure, disallowing the later borrow of `foo.field`. To preserve the semantics of the `write!` macro, it is also impossible to borrow specifically the `writer` field of the `foo` structure because it must be borrowed mutably, but the `foo` structure is not guaranteed to be mutable itself. This new macro is invoked like: format_args_method!(foo.writer, write_fmt, "{}", foo.field) This macro will generate an ExprMethodCall which allows the borrow checker to understand that `writer` and `field` should be borrowed separately. This macro is not strictly necessary, with DST or possibly UFCS other workarounds could be used. For now, though, it looks like this is required to implement the `write!` macro.
2014-05-08libsyntax: Remove uses of `~str` from libsyntax, and fix falloutPatrick Walton-6/+6
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-16/+16
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-6/+6
2014-04-30librustc: Remove `~"string"` and `&"string"` from the languagePatrick Walton-24/+24
2014-04-16syntax: unify all MacResult's into a single trait.Huon Wilson-38/+106
There's now one unified way to return things from a macro, instead of being able to choose the `AnyMacro` trait or the `MRItem`/`MRExpr` variants of the `MacResult` enum. This does simplify the logic handling the expansions, but the biggest value of this is it makes macros in (for example) type position easier to implement, as there's this single thing to modify. By my measurements (using `-Z time-passes` on libstd and librustc etc.), this appears to have little-to-no impact on expansion speed. There are presumably larger costs than the small number of extra allocations and virtual calls this adds (notably, all `macro_rules!`-defined macros have not changed in behaviour, since they had to use the `AnyMacro` trait anyway).
2014-04-08rustc: Never register syntax crates in CStoreAlex Crichton-3/+2
When linking, all crates in the local CStore are used to link the final product. With #[phase(syntax)], crates want to be omitted from this linkage phase, and this was achieved by dumping the entire CStore after loading crates. This causes crates like the standard library to get loaded twice. This loading process is a fairly expensive operation when dealing with decompressing metadata. This commit alters the loading process to never register syntax crates in CStore. Instead, only phase(link) crates ever make their way into the map of crates. The CrateLoader trait was altered to return everything in one method instead of having separate methods for finding information.
2014-03-31syntax: Switch field privacy as necessaryAlex Crichton-17/+17
2014-03-25Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by ↵Marvin Löbel-1/+1
value
2014-03-24auto merge of #12998 : huonw/rust/log_syntax, r=alexcrichtonbors-2/+20
syntax: allow `trace_macros!` and `log_syntax!` in item position. Previously trace_macros!(true) fn main() {} would complain about `trace_macros` being an expression macro in item position. This is a pointless limitation, because the macro is purely compile-time, with no runtime effect. (And similarly for log_syntax.) This also changes the behaviour of `trace_macros!` very slightly, it used to be equivalent to macro_rules! trace_macros { (true $($_x: tt)*) => { true }; (false $($_x: tt)*) => { false } } I.e. you could invoke it with arbitrary trailing arguments, which were ignored. It is changed to accept only exactly `true` or `false` (with no trailing arguments) and expands to `()`.
2014-03-22syntax: allow `trace_macros!` and `log_syntax!` in item position.Huon Wilson-2/+20
Previously trace_macros!(true) fn main() {} would complain about `trace_macros` being an expression macro in item position. This is a pointless limitation, because the macro is purely compile-time, with no runtime effect. (And similarly for log_syntax.) This also changes the behaviour of `trace_macros!` very slightly, it used to be equivalent to macro_rules! trace_macros { (true $($_x: tt)*) => { true }; (false $($_x: tt)*) => { false } } I.e. you could invoke it with arbitrary trailing arguments, which were ignored. It is changed to accept only exactly `true` or `false` (with no trailing arguments) and expands to `()`.
2014-03-20Removing imports of std::vec_ng::VecAlex Crichton-1/+0
It's now in the prelude.
2014-03-20rename std::vec_ng -> std::vecDaniel Micay-1/+1
Closes #12771
2014-03-17De-@ codemap and diagnostic.Eduard Burtescu-1/+1
2014-03-17De-@ ParseSess uses.Eduard Burtescu-3/+3
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/+6
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-11Add an ItemModifier syntax extension typeSteven Fackler-10/+19
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-06syntax: Conditionally deriving(Hash) with WritersAlex Crichton-3/+3
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-3/+3
- 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-02Expand string literals and exprs inside of macrosSteven Fackler-17/+8
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-2/+6
2014-03-01libsyntax: Mechanically change `~[T]` to `Vec<T>`Patrick Walton-13/+13
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-1/+1
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-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.