about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-01-31Fix minor doc typosVirgile Andreani-4/+4
2014-01-30Make mut_last return Option instead of failing on empty vector (and add a ↵Nathaniel Herman-2/+2
test for mut_last)
2014-01-30Implement default type parameters in generics.Eduard Burtescu-12/+57
2014-01-30auto merge of #11911 : kballard/rust/empty-functional-update, r=pcwaltonbors-13/+10
Fixes #8972
2014-01-30Remove Times traitBrendan Zabarauskas-5/+6
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-29Allow empty functional updating of structsKevin Ballard-13/+10
Fixes #8972
2014-01-29Removing support for the do syntax from libsyntax and librustc.Scott Lawrence-141/+44
Fixes #10815.
2014-01-27auto merge of #11826 : huonw/rust/7621-deriving-errors, r=alexcrichtonbors-9/+7
cc #7621. See the commit message. I'm not sure if we should merge this now, or wait until we can write `Clone::clone(x)` which will directly solve the above issue with perfect error messages.
2014-01-28syntax: make deriving have slightly less cryptic error messages.Huon Wilson-9/+7
This unfortunately changes an error like error: mismatched types: expected `&&NotClone` but found `&NotClone` into error: type `NotClone` does not implement any method in scope named `clone`
2014-01-27Demote self to an (almost) regular argument and remove the env param.Eduard Burtescu-148/+135
Fixes #10667 and closes #10259.
2014-01-27auto merge of #11834 : huonw/rust/deriving-spans, r=alexcrichtonbors-137/+139
I'd forgotten to update them when I changed this a while ago; it now displays error messages linked to the struct/variant field, rather than the `#[deriving(Trait)]` line, for all traits. This also adds a very large number of autogenerated tests. I can easily remove/tone down that commit if necessary.
2014-01-27syntax: improve the spans of some #[deriving] traits.Huon Wilson-137/+138
This makes error messages about (e.g.) `#[deriving(Clone)] struct Foo { x: Type }` point at `x: Type` rather than `Clone` in the header (while still referring to the `#[deriving(Clone)]` in the expansion info).
2014-01-26auto merge of #11817 : salemtalha/rust/master, r=brsonbors-15/+15
Fixes Issue #11815
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-15/+15
2014-01-26Fix privacy fallout from previous changeAlex Crichton-1/+1
2014-01-26syntax: Fix a missing closing code tag in docs.Huon Wilson-0/+1
2014-01-25auto merge of #11803 : sfackler/rust/simple-mac, r=brsonbors-139/+70
Now that procedural macros can be implemented outside of the compiler, it's more important to have a reasonable API to work with. Here are the basic changes: * Rename SyntaxExpanderTTTrait to MacroExpander, SyntaxExpanderTT to BasicMacroExpander, etc. I think "procedural macro" is the right term for these now, right? The other option would be SynExtExpander or something like that. * Stop passing the SyntaxContext to extensions. This was only ever used by macro_rules, which doesn't even use it anymore. I can't think of a context in which an external extension would need it, and removal allows the API to be significantly simpler - no more SyntaxExpanderTTItemExpanderWithoutContext wrappers to worry about.
2014-01-25Simplify and rename macro APISteven Fackler-139/+70
Now that procedural macros can be implemented outside of the compiler, it's more important to have a reasonable API to work with. Here are the basic changes: * Rename SyntaxExpanderTTTrait to MacroExpander, SyntaxExpanderTT to BasicMacroExpander, etc. I think "procedural macro" is the right term for these now, right? The other option would be SynExtExpander or something like that. * Stop passing the SyntaxContext to extensions. This was only ever used by macro_rules, which doesn't even use it anymore. I can't think of a context in which an external extension would need it, and removal allows the API to be significantly simpler - no more SyntaxExpanderTTItemExpanderWithoutContext wrappers to worry about.
2014-01-25Uppercase numeric constantsChris Wong-4/+4
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-24Move macro_rules! macros to libstdSteven Fackler-241/+0
They all have to go into a single module at the moment unfortunately. Ideally, the logging macros would live in std::logging, condition! would live in std::condition, format! in std::fmt, etc. However, this introduces cyclic dependencies between those modules and the macros they use which the current expansion system can't deal with. We may be able to get around this by changing the expansion phase to a two-pass system but that's for a later PR. Closes #2247 cc #11763
2014-01-24auto merge of #11720 : sfackler/rust/macro-export-source, r=alexcrichtonbors-8/+17
The old method of serializing the AST gives totally bogus spans if the expansion of an imported macro causes compilation errors. The best solution seems to be to serialize the actual textual macro definition and load it the same way the std-macros are. I'm not totally confident that getting the source from the CodeMap will always do the right thing, but it seems to work in simple cases.
2014-01-23auto merge of #11718 : ktt3ja/rust/borrowck-error-msg, r=brsonbors-16/+76
A mutable and immutable borrow place some restrictions on what you can with the variable until the borrow ends. This commit attempts to convey to the user what those restrictions are. Also, if the original borrow is a mutable borrow, the error message has been changed (more specifically, i. "cannot borrow `x` as immutable because it is also borrowed as mutable" and ii. "cannot borrow `x` as mutable more than once" have been changed to "cannot borrow `x` because it is already borrowed as mutable"). In addition, this adds a (custom) span note to communicate where the original borrow ends. ```rust fn main() { match true { true => { let mut x = 1; let y = &x; let z = &mut x; } false => () } } test.rs:6:21: 6:27 error: cannot borrow `x` as mutable because it is already borrowed as immutable test.rs:6 let z = &mut x; ^~~~~~ test.rs:5:21: 5:23 note: previous borrow of `x` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `x` until the borrow ends test.rs:5 let y = &x; ^~ test.rs:7:10: 7:10 note: previous borrow ends here test.rs:3 true => { test.rs:4 let mut x = 1; test.rs:5 let y = &x; test.rs:6 let z = &mut x; test.rs:7 } ^ ``` ```rust fn foo3(t0: &mut &mut int) { let t1 = &mut *t0; let p: &int = &**t0; } fn main() {} test.rs:3:19: 3:24 error: cannot borrow `**t0` because it is already borrowed as mutable test.rs:3 let p: &int = &**t0; ^~~~~ test.rs:2:14: 2:22 note: previous borrow of `**t0` as mutable occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `**t0` until the borrow ends test.rs:2 let t1 = &mut *t0; ^~~~~~~~ test.rs:4:2: 4:2 note: previous borrow ends here test.rs:1 fn foo3(t0: &mut &mut int) { test.rs:2 let t1 = &mut *t0; test.rs:3 let p: &int = &**t0; test.rs:4 } ^ ``` For the "previous borrow ends here" note, if the span is too long (has too many lines), then only the first and last lines are printed, and the middle is replaced with dot dot dot: ```rust fn foo3(t0: &mut &mut int) { let t1 = &mut *t0; let p: &int = &**t0; } fn main() {} test.rs:3:19: 3:24 error: cannot borrow `**t0` because it is already borrowed as mutable test.rs:3 let p: &int = &**t0; ^~~~~ test.rs:2:14: 2:22 note: previous borrow of `**t0` as mutable occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `**t0` until the borrow ends test.rs:2 let t1 = &mut *t0; ^~~~~~~~ test.rs:7:2: 7:2 note: previous borrow ends here test.rs:1 fn foo3(t0: &mut &mut int) { ... test.rs:7 } ^ ``` (Sidenote: the `span_end_note` currently also has issue #11715)
2014-01-23auto merge of #11686 : mankyKitty/rust/rename-invert-to-flip-issue-10632, ↵bors-2/+2
r=alexcrichton Renamed the ```invert()``` function in ```iter.rs``` to ```flip()```, from #10632 Also renamed the ```Invert<T>``` type to ```Flip<T>```. Some related code comments changed. Documentation that I could find has been updated, and all the instances I could locate where the function/type were called have been updated as well. This is my first contribution to Rust! Apologies in advance if I've snarfed the PR process, I'm not used to rebase. I initially had issues with the ```codegen``` section of the tests failing, however the ```make check``` process is not reporting any failures at this time. I think that was a local env issue more than me facerolling my changes. :)
2014-01-23auto merge of #11478 : klutzy/rust/rustpkg-crate-id, r=cmrbors-1/+9
This patchset consists of three parts: - rustpkg doesn't guess crate version if it is not given by user. - `rustpkg::version::Version` is replaced by `Option<~str>`. It removes some semantic versioning portions which is not currently used. (cc #8405 and #11396) `rustpkg::crate_id::CrateId` is also replaced by `syntax::crateid::CrateId`. - rustpkg now computes hash to find crate, instead of manual filename parse. cc @metajack
2014-01-23Update flip() to be rev().Sean Chalmers-2/+2
Consensus leaned in favour of using rev instead of flip.
2014-01-23Rename Invert to Flip - Issue 10632Sean Chalmers-2/+2
Renamed the invert() function in iter.rs to flip(). Also renamed the Invert<T> type to Flip<T>. Some related code comments changed. Documentation that I could find has been updated, and all the instances I could locate where the function/type were called have been updated as well.
2014-01-23Make some borrow checker errors more user friendlyKiet Tran-16/+76
A mutable and immutable borrow place some restrictions on what you can with the variable until the borrow ends. This commit attempts to convey to the user what those restrictions are. Also, if the original borrow is a mutable borrow, the error message has been changed (more specifically, i. "cannot borrow `x` as immutable because it is also borrowed as mutable" and ii. "cannot borrow `x` as mutable more than once" have been changed to "cannot borrow `x` because it is already borrowed as mutable"). In addition, this adds a (custom) span note to communicate where the original borrow ends.
2014-01-23Redo exported macro serializationSteven Fackler-8/+17
The old method of serializing the AST gives totally bogus spans if the expansion of an imported macro causes compilation errors. The best solution seems to be to serialize the actual textual macro definition and load it the same way the std-macros are. I'm not totally confident that getting the source from the CodeMap will always do the right thing, but it seems to work in simple cases.
2014-01-22Add LowerExp 'e' and UpperExp 'E' format traits/specifiersSiegeLord-0/+2
2014-01-23rustpkg::crate_id: Remove CrateIdklutzy-1/+9
There is no significant difference between `rustpkg::crate_id::CrateId` and `syntax::crateid::CrateId`. rustpkg's one is replaced by syntax's one.
2014-01-23Allow trailing commas in argument lists and tuple patternsSeo Sanghyeon-2/+3
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-5/+5
from_utf8_owned() behavior
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-23/+26
2014-01-21[std::vec] Rename .last_opt() to .last(), drop the old .last() behaviorSimon Sapin-21/+20
2014-01-21Remove unnecessary parentheses.Huon Wilson-21/+21
2014-01-20auto merge of #11670 : sfackler/rust/extctxt-span-note, r=alexcrichtonbors-0/+4
It was the only span_* missing.
2014-01-20auto merge of #11660 : sfackler/rust/quote-unused-sp, r=huonwbors-2/+2
The provided span isn't used in all cases (namely primitives).
2014-01-19auto merge of #11644 : huonw/rust/less-fatality, r=cmrbors-84/+197
This means that compilation continues for longer, and so we can see more errors per compile. This is mildly more user-friendly because it stops users having to run rustc n times to see n macro errors: just run it once to see all of them.
2014-01-19Add span_note to ExtCtxtSteven Fackler-0/+4
It was the only span_* missing.
2014-01-19auto merge of #11639 : sfackler/rust/macro-crate-path, r=alexcrichtonbors-2/+2
If the library is in the working directory, its path won't have a "/" which will cause dlopen to search /usr/lib etc. It turns out that Path auto-normalizes during joins so Path::new(".").join(path) is actually a no-op.
2014-01-18Avoid unused variable warning in quote_*!Steven Fackler-2/+2
The provided span isn't used in all cases (namely primitives).
2014-01-19syntax: convert ast_map to use a SmallIntMap.Huon Wilson-37/+79
NodeIds are sequential integers starting at zero, so we can achieve some memory savings by just storing the items all in a line in a vector. The occupancy for typical crates seems to be 75-80%, so we're already more efficient than a HashMap (maximum occupancy 75%), not even counting the extra book-keeping that HashMap does.
2014-01-18auto merge of #11620 : alexcrichton/rust/rustc-silent, r=brsonbors-2/+7
This commit re-works how the monitor() function works and how it both receives and transmits errors. There are a few cases in which the compiler can abort: 1. A normal compiler error. In this case, the compiler raises a FatalError as the failure value of the task. If this happens, then the monitor task does nothing. It ignores all stderr output of the child task and it also suppresses the failure message of the main task itself. This means that on a normal compiler error just the error message itself is printed. 2. A normal internal compiler error. These are invoked from sess.span_bug() and friends. In these cases, they follow the same path (raising a FatalError), but they will also print an ICE message which has a URL to go report a bug. 3. An actual compiler bug. This happens whenever anything calls fail!() instead of going through the session itself. In this case, we print out stuff about RUST_LOG=2 and we by default capture all stderr and print via warn!() so it's only printed out with the RUST_LOG var set.
2014-01-18auto merge of #11607 : alexcrichton/rust/issue-9957, r=cmrbors-1/+1
For `use` statements, this means disallowing qualifiers when in functions and disallowing `priv` outside of functions. For `extern mod` statements, this means disallowing everything everywhere. It may have been envisioned for `pub extern mod foo` to be a thing, but it currently doesn't do anything (resolve doesn't pick it up), so better to err on the side of forwards-compatibility and forbid it entirely for now. Closes #9957
2014-01-18rustc: Clean up error reportingAlex Crichton-2/+7
This commit re-works how the monitor() function works and how it both receives and transmits errors. There are a few cases in which the compiler can abort: 1. A normal compiler error. In this case, the compiler raises a FatalError as the failure value of the task. If this happens, then the monitor task does nothing. It ignores all stderr output of the child task and it also suppresses the failure message of the main task itself. This means that on a normal compiler error just the error message itself is printed. 2. A normal internal compiler error. These are invoked from sess.span_bug() and friends. In these cases, they follow the same path (raising a FatalError), but they will also print an ICE message which has a URL to go report a bug. 3. An actual compiler bug. This happens whenever anything calls fail!() instead of going through the session itself. In this case, we print out stuff about RUST_LOG=2 and we by default capture all stderr and print via warn!() so it's only printed out with the RUST_LOG var set.
2014-01-18Forbid unnecessary visibility on view itemsAlex Crichton-1/+1
For `use` statements, this means disallowing qualifiers when in functions and disallowing `priv` outside of functions. For `extern mod` statements, this means disallowing everything everywhere. It may have been envisioned for `pub extern mod foo` to be a thing, but it currently doesn't do anything (resolve doesn't pick it up), so better to err on the side of forwards-compatibility and forbid it entirely for now. Closes #9957
2014-01-18Rename iterators for consistencyPalmer Cox-13/+13
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-17Actually force a / in the path for ext cratesSteven Fackler-2/+2
If the library is in the working directory, its path won't have a "/" which will cause dlopen to search /usr/lib etc. It turns out that Path auto-normalizes during joins so Path::new(".").join(path) is actually a no-op.
2014-01-17auto merge of #11598 : alexcrichton/rust/io-export, r=brsonbors-2/+2
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered) cc #11119
2014-01-17Tweak the interface of std::ioAlex Crichton-2/+2
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)