about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
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
2014-02-08syntax: remove some dead code.Huon Wilson-15/+1
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-2/+2
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-08syntax: convert the lexer to use Option<char> over transmute(-1).Huon Wilson-116/+157
The transmute was unsound. There are many instances of .unwrap_or('\x00') for "ignoring" EOF which either do not make the situation worse than it was (well, actually make it better, since it's easy to grep for places that don't handle EOF) or can never ever be read. Fixes #8971.
2014-02-07Correct span for ExprFnBlock, ExprMethodCall, ExprParenSeo Sanghyeon-3/+3
2014-02-07moved collections from libextra into libcollectionsHeroesGrave-1/+2
2014-02-06auto merge of #12039 : alexcrichton/rust/no-conditions, r=brsonbors-11/+14
This has been a long time coming. Conditions in rust were initially envisioned as being a good alternative to error code return pattern. The idea is that all errors are fatal-by-default, and you can opt-in to handling the error by registering an error handler. While sounding nice, conditions ended up having some unforseen shortcomings: * Actually handling an error has some very awkward syntax: let mut result = None; let mut answer = None; io::io_error::cond.trap(|e| { result = Some(e) }).inside(|| { answer = Some(some_io_operation()); }); match result { Some(err) => { /* hit an I/O error */ } None => { let answer = answer.unwrap(); /* deal with the result of I/O */ } } This pattern can certainly use functions like io::result, but at its core actually handling conditions is fairly difficult * The "zero value" of a function is often confusing. One of the main ideas behind using conditions was to change the signature of I/O functions. Instead of read_be_u32() returning a result, it returned a u32. Errors were notified via a condition, and if you caught the condition you understood that the "zero value" returned is actually a garbage value. These zero values are often difficult to understand, however. One case of this is the read_bytes() function. The function takes an integer length of the amount of bytes to read, and returns an array of that size. The array may actually be shorter, however, if an error occurred. Another case is fs::stat(). The theoretical "zero value" is a blank stat struct, but it's a little awkward to create and return a zero'd out stat struct on a call to stat(). In general, the return value of functions that can raise error are much more natural when using a Result as opposed to an always-usable zero-value. * Conditions impose a necessary runtime requirement on *all* I/O. In theory I/O is as simple as calling read() and write(), but using conditions imposed the restriction that a rust local task was required if you wanted to catch errors with I/O. While certainly an surmountable difficulty, this was always a bit of a thorn in the side of conditions. * Functions raising conditions are not always clear that they are raising conditions. This suffers a similar problem to exceptions where you don't actually know whether a function raises a condition or not. The documentation likely explains, but if someone retroactively adds a condition to a function there's nothing forcing upstream users to acknowledge a new point of task failure. * Libaries using I/O are not guaranteed to correctly raise on conditions when an error occurs. In developing various I/O libraries, it's much easier to just return `None` from a read rather than raising an error. The silent contract of "don't raise on EOF" was a little difficult to understand and threw a wrench into the answer of the question "when do I raise a condition?" Many of these difficulties can be overcome through documentation, examples, and general practice. In the end, all of these difficulties added together ended up being too overwhelming and improving various aspects didn't end up helping that much. A result-based I/O error handling strategy also has shortcomings, but the cognitive burden is much smaller. The tooling necessary to make this strategy as usable as conditions were is much smaller than the tooling necessary for conditions. Perhaps conditions may manifest themselves as a future entity, but for now we're going to remove them from the standard library. Closes #9795 Closes #8968