summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-03-06syntax: Conditionally deriving(Hash) with WritersAlex Crichton-92/+50
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-06rustc: Move to FNV hashing for node/def idsAlex Crichton-0/+75
This leverages the new hashing framework and hashmap implementation to provide a much speedier hashing algorithm for node ids and def ids. The hash algorithm used is currentl FNV hashing, but it's quite easy to swap out. I originally implemented hashing as the identity function, but this actually ended up in slowing down rustc compiling libstd from 8s to 13s. I would suspect that this is a result of a large number of collisions. With FNV hashing, we get these timings (compiling with --no-trans, in seconds): | | before | after | |-----------|---------:|--------:| | libstd | 8.324 | 6.703 | | stdtest | 47.674 | 46.857 | | libsyntax | 9.918 | 8.400 |
2014-03-05Refactor and fix FIXME's in mtwt hygiene codeEdward Wang-556/+551
- 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-04auto merge of #12300 : DaGenix/rust/uppercase-variable-lint, r=alexcrichtonbors-16/+16
I added a new lint for variables whose names contain uppercase characters, since, by convention, variable names should be all lowercase. What motivated me to work on this was when I ran into something like the following: ```rust use std::io::File; use std::io::IoError; fn main() { let mut f = File::open(&Path::new("/something.txt")); let mut buff = [0u8, ..16]; match f.read(buff) { Ok(cnt) => println!("read this many bytes: {}", cnt), Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_str()), } } ``` I then got compile errors when I tried to add a wildcard match pattern at the end which I found very confusing since I believed that the 2nd match arm was only matching the EndOfFile condition. The problem is that I hadn't imported io::EndOfFile into the local scope. So, I thought that I was using EndOfFile as a sub-pattern, however, what I was actually doing was creating a new local variable named EndOfFile. This lint makes this error easier to spot by providing a warning that the variable name EndOfFile contains a uppercase characters which provides a nice hint as to why the code isn't doing what is intended. The lint warns on local bindings as well: ```rust let Hi = 0; ``` And also struct fields: ```rust struct Something { X: uint } ```
2014-03-04auto merge of #12671 : nick29581/rust/expand, r=sfacklerbors-6/+15
Fixes a regression from #4913 which causes items to be exanded with spans lacking expn_info from the context's current backtrace.
2014-03-04Rename all variables that have uppercase characters in their names to use ↵Palmer Cox-16/+16
only lowercase characters
2014-03-04Expand nested items within a backtrace.Nick Cameron-6/+15
Fixes a regression from #4913 which causes items to be exanded with spans lacking expn_info from the context's current backtrace.
2014-03-04auto merge of #12697 : thestinger/rust/vec, r=huonwbors-0/+1
This exists for the sake of compatibility during the ~[T] -> Vec<T> transition. It will be removed in the future.
2014-03-04mark the `map` method on Vec<T> as deprecatedDaniel Micay-0/+1
This exists for the sake of compatibility during the ~[T] -> Vec<T> transition. It will be removed in the future.
2014-03-04doc: use the newer faviconAdrien Tétar-1/+1
2014-03-03syntax: make match arms store the expr directly.Huon Wilson-47/+21
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-7/+6
2014-03-02Make visible types public in rustcSteven Fackler-7/+6
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-306/+550
2014-03-01libsyntax: Mechanically change `~[T]` to `Vec<T>`Patrick Walton-979/+934
2014-03-01std: Switch stdout/stderr to buffered by defaultAlex Crichton-2/+2
Similarly to #12422 which made stdin buffered by default, this commit makes the output streams also buffered by default. Now that buffered writers will flush their contents when they are dropped, I don't believe that there's no reason why the output shouldn't be buffered by default, which is what you want in 90% of cases. As with stdin, there are new stdout_raw() and stderr_raw() functions to get unbuffered streams to stdout/stderr.
2014-03-01auto merge of #12627 : alexcrichton/rust/issue-12623, r=brsonbors-104/+116
This helps prevent the unfortunate interleavings found in #12623.
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-23/+49
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28rustdoc: Capture all output from rustc by defaultAlex Crichton-1/+5
This helps prevent interleaving of error messages when running rustdoc tests. This has an interesting bit of shuffling with I/O handles, but other than that this is just using the APIs laid out in the previous commit. Closes #12623
2014-02-28syntax: Refactor diagnostics to focus on WritersAlex Crichton-103/+111
This commit alters the diagnostic emission machinery to be focused around a Writer for emitting errors. This allows it to not hard-code emission of errors to stderr (useful for other applications).
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-28rustc: Simplify crate loading constraintsAlex Crichton-0/+9
The previous code passed around a {name,version} pair everywhere, but this is better expressed as a CrateId. This patch changes these paths to store and pass around crate ids instead of these pairs of name/version. This also prepares the code to change the type of hash that is stored in crates.
2014-03-01Publicise types/add #[allow(visible_private_types)] to a variety of places.Huon Wilson-2/+3
There's a lot of these types in the compiler libraries, and a few of the older or private stdlib ones. Some types are obviously meant to be public, others not so much.
2014-03-01rustc: implement a lint for publicly visible private types.Huon Wilson-5/+8
These are types that are in exported type signatures, but are not exported themselves, e.g. struct Foo { ... } pub fn bar() -> Foo { ... } will warn about the Foo. Such types are not listed in documentation, and cannot be named outside the crate in which they are declared, which is very user-unfriendly. cc #10573
2014-02-27Fix bytepos_to_file_charpos.Nick Cameron-10/+52
Make bytepos_to_charpos relative to the start of the filemap rather than its previous behaviour which was to be realtive to the start of the codemap, but ignoring multi-byte chars in earlier filemaps. Rename to bytepos_to_file_charpos. Add tests for multi-byte chars.
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-27Fix a pretty printer crash on `/***`.Chris Morgan-1/+1
The pretty printer was treating block comments with more than two asterisks after the first slash (e.g. `/***`) as doc comments (which are attributes), whereas in actual fact they are just regular comments.
2014-02-26Replace callee_id with information stored in method_map.Eduard Burtescu-72/+33
2014-02-25Use only the appropriate trait when looking up operator overloads.Eduard Burtescu-41/+19
2014-02-25auto merge of #12522 : erickt/rust/hash, r=alexcrichtonbors-32/+23
This patch series does a couple things: * replaces manual `Hash` implementations with `#[deriving(Hash)]` * adds `Hash` back to `std::prelude` * minor cleanup of whitespace and variable names.
2014-02-25auto merge of #12525 : eddyb/rust/gate-default-type-param-usage, r=alexcrichtonbors-16/+4
Also reverted `#[deriving(Hash)]` to implement `Hash` only for `SipState`, until we decide what to do about default type params.
2014-02-24syntax: allow stmt/expr macro invocations to be delimited by {}.Huon Wilson-3/+23
This makes using control-flow-y macros like `spawn! { ... }` more fluent and natural. cc #11892.
2014-02-24syntax: calculate positions of multibyte characters more correctly.Huon Wilson-3/+4
They are still are not completely correct, since it does not handle graphemes at all, just codepoints, but at least it handles the common case correctly. The calculation was previously very wrong (rather than just a little bit wrong): it wasn't accounting for the fact that every character is 1 byte, and so multibyte characters were pretending to be zero width. cc #8706
2014-02-24syntax: record multibyte chars' positions absolutely, not relative toHuon Wilson-2/+1
file. Previously multibyte UTF-8 chars were being recorded as byte offsets from the start of the file, and then later compared against global byte positions, resulting in the compiler possibly thinking it had a byte position pointing inside a multibyte character, if there were multibyte characters in any non-crate files. (Although, sometimes the byte offsets line up just right to not ICE, but that was a coincidence.) Fixes #11136. Fixes #11178.
2014-02-24Remove std::from_str::FromStr from the preludeBrendan Zabarauskas-0/+3
2014-02-24Remove std::default::Default from the preludeBrendan Zabarauskas-0/+1
2014-02-24replace manual Hash impls with `#[deriving(Hash)]`Erick Tryzelaar-8/+1
2014-02-24std: minor whitespace cleanupErick Tryzelaar-24/+22
2014-02-24Gate default type parameter overrides.Eduard Burtescu-16/+4
Fixes #12423.
2014-02-24Move extra::json to libserializeAlex Crichton-5/+2
This also inverts the dependency between libserialize and libcollections. cc #8784
2014-02-24auto merge of #12412 : alexcrichton/rust/deriving-show, r=huonwbors-183/+63
This commit removes deriving(ToStr) in favor of deriving(Show), migrating all impls of ToStr to fmt::Show. Most of the details can be found in the first commit message. Closes #12477
2014-02-24Remove deriving(ToStr)Alex Crichton-136/+2
This has been superseded by deriving(Show). cc #9806
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-49/+63
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-23auto merge of #12328 : nick29581/rust/abi, r=alexcrichtonbors-4/+5
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-24All uses of `extern fn` should mean `extern "C" fn`. Closes #9309.Nick Cameron-4/+5
2014-02-23auto merge of #12338 : edwardw/rust/hygienic-break-continue, r=cmrbors-17/+68
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-221/+104