about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-02-20Mass rename if_ok! to try!Alex Crichton-734/+734
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20move extra::test to libtestLiigo Zhuang-6/+7
2014-02-19librustc: Remove unique vector patterns from the language.Patrick Walton-79/+96
Preparatory work for removing unique vectors from the language, which is itself preparatory work for dynamically sized types.
2014-02-19auto merge of #11904 : nick29581/rust/0filemap, r=alexcrichtonbors-8/+78
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-19Fix bug with zero-length filemaps and rename bytepos_to_local_charpos to ↵Nick Cameron-8/+78
bytepos_to_charpos.
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-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-12/+20
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-14Fix all code examplesAlex Crichton-12/+20
2014-02-14extern mod => extern crateAlex Crichton-16/+16
This was previously implemented, and it just needed a snapshot to go through
2014-02-14Register new snapshotsAlex Crichton-7/+6
This enables the parser error for `extern mod` => `extern crate` transitions.
2014-02-14Removed the obsolete ast::CallSugar (previously used by `do`).Eduard Burtescu-74/+34
2014-02-14Expand ItemDecorator extensions in all contextsSteven Fackler-53/+40
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-14Removed libextra dependency from libsyntax.HeroesGrave-1/+1
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-688/+743
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 #12061 : pongad/rust/delorderable, r=cmrbors-3/+3
#12057
2014-02-13Removed num::OrderableMichael Darakananda-3/+3
2014-02-13auto merge of #12017 : FlaPer87/rust/replace-mod-crate, r=alexcrichtonbors-143/+134
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.
2014-02-13Stop unloading syntax librariesSteven Fackler-11/+7
Externally loaded libraries are able to do things that cause references to them to survive past the expansion phase (e.g. creating @-box cycles, launching a task or storing something in task local data). As such, the library has to stay loaded for the lifetime of the process.
2014-02-13Remove obsolete warnings for `extern mod`Flavio Percoco-12/+0
This patch gets rid of ObsoleteExternModAttributesInParens and ObsoleteNamedExternModule since the replacement of `extern mod` with `extern crate` avoids those cases and raises different errors. Both have been around for at least a version which makes this a good moment to get rid of them.
2014-02-13Replace `extern mod` with `extern crate`Flavio Percoco-105/+108
This patch adds a new keyword `crate` which is intended to replace mod in the context of `extern mod` as part of the issue #9880. The patch doesn't replace all `extern mod` cases since it is necessary to first push a new snapshot 0. The implementation could've been less invasive than this. However I preferred to take this chance to split the `parse_item_foreign_mod` method and pull the `extern crate` part out of there, hence the new method `parse_item_foreign_crate`.
2014-02-13Replace `crate` usage with `krate`Flavio Percoco-26/+26
This patch replaces all `crate` usage with `krate` before introducing the new keyword. This ensures that after introducing the keyword, there won't be any compilation errors. krate might not be the most expressive substitution for crate but it's a very close abbreviation for it. `module` was already used in several places already.
2014-02-11libsyntax -- fix unsafe sharing in closuresNiko Matsakis-10/+12
2014-02-11libsyntax -- combine two iter ops into one so that `fld` does not need to be ↵Niko Matsakis-5/+6
mutably shared between them both
2014-02-11syntax/fold -- remove conflicting (and rather pointless) closuresNiko Matsakis-18/+7
2014-02-11syntax/ext/format -- rewrite conflicting closures into methodsNiko Matsakis-116/+127
2014-02-11to_str -- update to contain scope of closureNiko Matsakis-20/+21
2014-02-11Correct span for self and ExprStructSeo Sanghyeon-2/+2
2014-02-11auto merge of #12175 : sfackler/rust/phase-use-ignored, r=alexcrichtonbors-8/+13
It could throw an error but I think it's best to not since `#[phase(..)]` syntax in other places would be silently ignored. Closes #11806
2014-02-11auto merge of #12170 : aepsil0n/rust/feature/reserve_do_keyword, r=brsonbors-0/+1
This resolves issue #12157. Does that do it already or is there something else that needs taking care of? As a side note, there seems to be some documentation, in which the old existence of the do keyword is explained. The list of keywords is not up-to-date either. But these are certainly separate issues.
2014-02-10Ignore #[phase] on use view itemsSteven Fackler-8/+13
Closes #11806
2014-02-11Reserve `do` as a keywordEduard Bopp-0/+1
Resolves issue #12157. `do` is hereby reinstated as a keyword; no syntax is associated with it though. Along the way, a unit test had to be adapted, since it was using `do` as a method identifier. Breaking changes: - Any code using `do` as an identifier will no longer work.
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-11/+11
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-09auto merge of #12117 : ↵bors-132/+157
nikomatsakis/rust/issue-11913-borrow-in-aliasable-loc, r=pcwalton Repair a rather embarassingly obvious hole that I created as part of #9629. In particular, prevent `&mut` borrows of data in an aliasable location. This used to be prevented through the restrictions mechanism, but in #9629 I modified those rules incorrectly. r? @pcwalton Fixes #11913
2014-02-08Converted fourcc! to loadable syntax extensionDerek Guenther-111/+1
2014-02-08Add new syntax extension fourcc!()Kevin Ballard-0/+110
fourcc!() allows you to embed FourCC (or OSType) values that are evaluated as u32 literals. It takes a 4-byte ASCII string and produces the u32 resulting in interpreting those 4 bytes as a u32, using either the platform-native endianness, or explicitly as big or little endian.
2014-02-08Update deriving to pass around the `cx` linearlyNiko Matsakis-132/+157
2014-02-08Fixed error starting with uppercasemr.Shu-38/+38
Error messages cleaned in librustc/middle Error messages cleaned in libsyntax Error messages cleaned in libsyntax more agressively Error messages cleaned in librustc more aggressively Fixed affected tests Fixed other failing tests Last failing tests fixed
2014-02-08auto merge of #12109 : omasanori/rust/small-fixes, r=sfacklerbors-6/+4
Most of them are to reduce warnings in testing builds.
2014-02-08auto merge of #12098 : kballard/rust/from_utf8_lossy_tweak, r=huonwbors-2/+2
MaybeOwned allows from_utf8_lossy to avoid allocation if there are no invalid bytes in the input. Before: ``` test str::bench::from_utf8_lossy_100_ascii ... bench: 183 ns/iter (+/- 5) test str::bench::from_utf8_lossy_100_invalid ... bench: 341 ns/iter (+/- 15) test str::bench::from_utf8_lossy_100_multibyte ... bench: 227 ns/iter (+/- 13) test str::bench::from_utf8_lossy_invalid ... bench: 102 ns/iter (+/- 4) test str::bench::is_utf8_100_ascii ... bench: 2 ns/iter (+/- 0) test str::bench::is_utf8_100_multibyte ... bench: 2 ns/iter (+/- 0) ``` Now: ``` test str::bench::from_utf8_lossy_100_ascii ... bench: 96 ns/iter (+/- 4) test str::bench::from_utf8_lossy_100_invalid ... bench: 318 ns/iter (+/- 10) test str::bench::from_utf8_lossy_100_multibyte ... bench: 105 ns/iter (+/- 2) test str::bench::from_utf8_lossy_invalid ... bench: 105 ns/iter (+/- 2) test str::bench::is_utf8_100_ascii ... bench: 2 ns/iter (+/- 0) test str::bench::is_utf8_100_multibyte ... bench: 2 ns/iter (+/- 0) ```
2014-02-08auto merge of #12086 : huonw/rust/safe-json, r=kballardbors-116/+157
The lexer and json were using `transmute(-1): char` as a sentinel value for EOF, which is invalid since `char` is strictly a unicode codepoint. Fixing this allows for range asserts on chars since they always lie between 0 and 0x10FFFF.
2014-02-07Rewrite path::Display to reduce unnecessary allocationKevin Ballard-2/+2
2014-02-08Remove unnecessary parentheses.OGINO Masanori-1/+1
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-02-08Fix unused import warnings.OGINO Masanori-5/+3
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-02-08Implement `#[deriving(Show)]`.Huon Wilson-0/+140
2014-02-08syntax: split out the parsing and the formatting part of format_args!().Huon Wilson-74/+92
2014-02-08syntax: convert deriving to take &mut ExtCtxt.Huon Wilson-63/+63