about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2014-07-10auto merge of #15336 : jakub-/rust/diagnostics, r=brsonbors-84/+466
This is a continuation of @brson's work from https://github.com/rust-lang/rust/pull/12144. This implements the minimal scaffolding that allows mapping diagnostic messages to alpha-numeric codes, which could improve the searchability of errors. In addition, there's a new compiler option, `--explain {code}` which takes an error code and prints out a somewhat detailed explanation of the error. Example: ```rust fn f(x: Option<bool>) { match x { Some(true) | Some(false) => (), None => (), Some(true) => () } } ``` ```shell [~/rust]$ ./build/x86_64-apple-darwin/stage2/bin/rustc ./diagnostics.rs --crate-type dylib diagnostics.rs:5:3: 5:13 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation) diagnostics.rs:5 Some(true) => () ^~~~~~~~~~ error: aborting due to previous error [~/rust]$ ./build/x86_64-apple-darwin/stage2/bin/rustc --explain E0001 This error suggests that the expression arm corresponding to the noted pattern will never be reached as for all possible values of the expression being matched, one of the preceeding patterns will match. This means that perhaps some of the preceeding patterns are too general, this one is too specific or the ordering is incorrect. ``` I've refrained from migrating many errors to actually use the new macros as it can be done in an incremental fashion but if we're happy with the approach, it'd be good to do all of them sooner rather than later. Originally, I was going to make libdiagnostics a separate crate but that's posing some interesting challenges with semi-circular dependencies. In particular, librustc would have a plugin-phase dependency on libdiagnostics, which itself depends on librustc. Per my conversation with @alexcrichton, it seems like the snapshotting process would also have to change. So for now the relevant modules from libdiagnostics are included using `#[path = ...] mod`.
2014-07-11Add scaffolding for assigning alpha-numeric codes to rustc diagnosticsJakub Wieczorek-84/+466
2014-07-10auto merge of #15353 : aturon/rust/env-hashmap, r=alexcrichtonbors-73/+138
This commit adds `env_insert` and `env_remove` methods to the `Command` builder, easing updates to the environment variables for the child process. The existing method, `env`, is still available for overriding the entire environment in one shot (after which the `env_insert` and `env_remove` methods can be used to make further adjustments). To support these new methods, the internal `env` representation for `Command` has been changed to an optional `HashMap` holding owned `CString`s (to support non-utf8 data). The `HashMap` is only materialized if the environment is updated. The implementation does not try hard to avoid allocation, since the cost of launching a process will dwarf any allocation cost. This patch also adds `PartialOrd`, `Eq`, and `Hash` implementations for `CString`.
2014-07-10io::process::Command: add fine-grained env builderAaron Turon-73/+138
This commit changes the `io::process::Command` API to provide fine-grained control over the environment: * The `env` method now inserts/updates a key/value pair. * The `env_remove` method removes a key from the environment. * The old `env` method, which sets the entire environment in one shot, is renamed to `env_set_all`. It can be used in conjunction with the finer-grained methods. This renaming is a breaking change. To support these new methods, the internal `env` representation for `Command` has been changed to an optional `HashMap` holding owned `CString`s (to support non-utf8 data). The `HashMap` is only materialized if the environment is updated. The implementation does not try hard to avoid allocation, since the cost of launching a process will dwarf any allocation cost. This patch also adds `PartialOrd`, `Eq`, and `Hash` implementations for `CString`. [breaking-change]
2014-07-10auto merge of #15559 : fhahn/rust/issue-15445-mut-cast, r=alexcrichtonbors-0/+22
I've added an error message for casts from raw pointers to floats #15445.
2014-07-10auto merge of #14519 : hirschenberger/rust/issue-10934, r=alexcrichtonbors-9/+32
Issue #10934
2014-07-10auto merge of #15569 : pcwalton/rust/reexport-intrinsics, r=cmrbors-89/+67
code bloat. This didn't make a difference in any compile times that I saw, but it fits what we're doing with `transmute` and seems prudent. r? @alexcrichton
2014-07-10auto merge of #15563 : luqmana/rust/nif, r=pcwaltonbors-513/+497
2014-07-10typeck: check casts from pointers to floats, closes #15445Florian Hahn-0/+22
2014-07-10auto merge of #15566 : japaric/rust/command-clone, r=alexcrichtonbors-0/+2
Allows use cases like this one: ``` rust use std::io::Command; fn main() { let mut cmd = Command::new("ls"); cmd.arg("-l"); for &dir in ["a", "b", "c"].iter() { println!("{}", cmd.clone().arg(dir)); } } ``` Output: ``` ls '-l' 'a' ls '-l' 'b' ls '-l' 'c' ``` Without the `clone()`, you'll end up with: ``` ls '-l' 'a' ls '-l' 'a' 'b' ls '-l' 'a' 'b' 'c' ``` cc #15294
2014-07-10Add range lint for float literals, fixing #10934Falco Hirschenberger-9/+32
2014-07-09libcore: Reexport a couple of widely-used low-level intrinsics to reducePatrick Walton-89/+67
code bloat. This didn't make a difference in any compile times that I saw, but it fits what we're doing with `transmute` and seems prudent.
2014-07-10auto merge of #15561 : huonw/rust/must-use-iterators, r=alexcrichtonbors-12/+47
Similar to the stability attributes, a type annotated with `#[must_use = "informative snippet"]` will print the normal warning message along with "informative snippet". This allows the type author to provide some guidance about why the type should be used. --- It can be a little unintuitive that something like `v.iter().map(|x| println!("{}", x));` does nothing: the majority of the iterator adaptors are lazy and do not execute anything until something calls `next`, e.g. a `for` loop, `collect`, `fold`, etc. The majority of such errors can be seen by someone writing something like the above, i.e. just calling an iterator adaptor and doing nothing with it (and doing this is certainly useless), so we can co-opt the `must_use` lint, using the message functionality to give a hint to the reason why. Fixes #14666.
2014-07-10auto merge of #15556 : alexcrichton/rust/snapshots, r=brsonbors-232/+12
Closes #15544
2014-07-09librustc: Translate input for transmute directly into dest.Luqman Aden-58/+42
2014-07-10auto merge of #15554 : steveklabnik/rust/gh_15539, r=brsonbors-10/+5
This was super silly anyway. Fixes #15539.
2014-07-09Derive Clone for Command and StdioContainerJorge Aparicio-0/+2
2014-07-09librustc: Update to reflect changes to how intrinsics are codegened.Luqman Aden-28/+16
2014-07-09librustc: Remove old codepaths for creating intrinsic functions.Luqman Aden-519/+4
2014-07-09auto merge of #15514 : luqmana/rust/die-advance-die, r=cmrbors-70/+32
Closes #15492.
2014-07-09tests: Remove uses of advance.Luqman Aden-4/+4
2014-07-09librustc: Remove uses of advance.Luqman Aden-5/+5
2014-07-09libsyntax: Remove uses of advance.Luqman Aden-21/+6
2014-07-09libgetopts: Use iterators instead of old-style loops.Luqman Aden-1/+1
2014-07-09libcollections: Use iterators instead of old-style loops.Luqman Aden-38/+14
2014-07-09libcore: Deprecate advance method on Iterators.Luqman Aden-1/+2
2014-07-09librustc: Don't emit call for intrinsics instead just trans at callsite.Luqman Aden-14/+541
2014-07-09auto merge of #15550 : alexcrichton/rust/install-script, r=brsonbors-56/+85
This adds detection of the relevant LD_LIBRARY_PATH-like environment variable and appropriately sets it when testing whether binaries can run or not. Additionally, the installation prints a recommended value if one is necessary. Closes #15545
2014-07-10core: add `#[must_use]` attributes to iterator adaptor structs.Huon Wilson-1/+18
It can be a little unintuitive that something like `v.iter().map(|x| println!("{}", x));` does nothing: the majority of the iterator adaptors are lazy and do not execute anything until something calls `next`, e.g. a `for` loop, `collect`, `fold`, etc. The majority of such errors can be seen by someone writing something like the above, i.e. just calling an iterator adaptor and doing nothing with it (and doing this is certainly useless), so we can co-opt the `must_use` lint, using the message functionality to give a hint to the reason why. Fixes #14666.
2014-07-10lint: extend `#[must_use]` to handle a message.Huon Wilson-11/+29
Similar to the stability attributes, a type annotated with `#[must_use = "informative snippet"]` will print the normal warning message along with "informative snippet". This allows the type author to provide some guidance about why the type should be used.
2014-07-09syntax: De-doc comment to fix nightliesAlex Crichton-50/+50
This reverts the promotion from line-comment to doc-comment in 4989a56 to fix the compiler-docs target. Closes #15553
2014-07-09auto merge of #15471 : erickt/rust/push_all, r=acrichtobors-82/+497
llvm is currently not able to conver `Vec::extend` into a memcpy for `Copy` types, which results in methods like `Vec::push_all` to run twice as slow as it should be running. This patch takes the unsafe `Vec::clone` optimization to speed up all the operations that are cloning a slice into a `Vec`. before: ``` test vec::tests::bench_clone_from_0000_0000 ... bench: 12 ns/iter (+/- 2) test vec::tests::bench_clone_from_0000_0010 ... bench: 125 ns/iter (+/- 4) = 80 MB/s test vec::tests::bench_clone_from_0000_0100 ... bench: 360 ns/iter (+/- 33) = 277 MB/s test vec::tests::bench_clone_from_0000_1000 ... bench: 2601 ns/iter (+/- 175) = 384 MB/s test vec::tests::bench_clone_from_0010_0000 ... bench: 12 ns/iter (+/- 2) test vec::tests::bench_clone_from_0010_0010 ... bench: 125 ns/iter (+/- 10) = 80 MB/s test vec::tests::bench_clone_from_0010_0100 ... bench: 361 ns/iter (+/- 28) = 277 MB/s test vec::tests::bench_clone_from_0100_0010 ... bench: 131 ns/iter (+/- 13) = 76 MB/s test vec::tests::bench_clone_from_0100_0100 ... bench: 360 ns/iter (+/- 9) = 277 MB/s test vec::tests::bench_clone_from_0100_1000 ... bench: 2575 ns/iter (+/- 168) = 388 MB/s test vec::tests::bench_clone_from_1000_0100 ... bench: 356 ns/iter (+/- 20) = 280 MB/s test vec::tests::bench_clone_from_1000_1000 ... bench: 2605 ns/iter (+/- 167) = 383 MB/s test vec::tests::bench_from_slice_0000 ... bench: 11 ns/iter (+/- 0) test vec::tests::bench_from_slice_0010 ... bench: 115 ns/iter (+/- 5) = 86 MB/s test vec::tests::bench_from_slice_0100 ... bench: 309 ns/iter (+/- 170) = 323 MB/s test vec::tests::bench_from_slice_1000 ... bench: 2065 ns/iter (+/- 198) = 484 MB/s test vec::tests::bench_push_all_0000_0000 ... bench: 7 ns/iter (+/- 0) test vec::tests::bench_push_all_0000_0010 ... bench: 79 ns/iter (+/- 7) = 126 MB/s test vec::tests::bench_push_all_0000_0100 ... bench: 342 ns/iter (+/- 18) = 292 MB/s test vec::tests::bench_push_all_0000_1000 ... bench: 2873 ns/iter (+/- 75) = 348 MB/s test vec::tests::bench_push_all_0010_0010 ... bench: 154 ns/iter (+/- 8) = 64 MB/s test vec::tests::bench_push_all_0100_0100 ... bench: 518 ns/iter (+/- 18) = 193 MB/s test vec::tests::bench_push_all_1000_1000 ... bench: 4490 ns/iter (+/- 223) = 222 MB/s ``` after: ``` test vec::tests::bench_clone_from_0000_0000 ... bench: 12 ns/iter (+/- 1) test vec::tests::bench_clone_from_0000_0010 ... bench: 123 ns/iter (+/- 5) = 81 MB/s test vec::tests::bench_clone_from_0000_0100 ... bench: 367 ns/iter (+/- 23) = 272 MB/s test vec::tests::bench_clone_from_0000_1000 ... bench: 2618 ns/iter (+/- 252) = 381 MB/s test vec::tests::bench_clone_from_0010_0000 ... bench: 12 ns/iter (+/- 1) test vec::tests::bench_clone_from_0010_0010 ... bench: 124 ns/iter (+/- 7) = 80 MB/s test vec::tests::bench_clone_from_0010_0100 ... bench: 369 ns/iter (+/- 34) = 271 MB/s test vec::tests::bench_clone_from_0100_0010 ... bench: 123 ns/iter (+/- 6) = 81 MB/s test vec::tests::bench_clone_from_0100_0100 ... bench: 371 ns/iter (+/- 25) = 269 MB/s test vec::tests::bench_clone_from_0100_1000 ... bench: 2713 ns/iter (+/- 532) = 368 MB/s test vec::tests::bench_clone_from_1000_0100 ... bench: 369 ns/iter (+/- 14) = 271 MB/s test vec::tests::bench_clone_from_1000_1000 ... bench: 2611 ns/iter (+/- 194) = 382 MB/s test vec::tests::bench_from_slice_0000 ... bench: 7 ns/iter (+/- 0) test vec::tests::bench_from_slice_0010 ... bench: 108 ns/iter (+/- 4) = 92 MB/s test vec::tests::bench_from_slice_0100 ... bench: 235 ns/iter (+/- 24) = 425 MB/s test vec::tests::bench_from_slice_1000 ... bench: 1318 ns/iter (+/- 96) = 758 MB/s test vec::tests::bench_push_all_0000_0000 ... bench: 7 ns/iter (+/- 0) test vec::tests::bench_push_all_0000_0010 ... bench: 70 ns/iter (+/- 4) = 142 MB/s test vec::tests::bench_push_all_0000_0100 ... bench: 176 ns/iter (+/- 16) = 568 MB/s test vec::tests::bench_push_all_0000_1000 ... bench: 1125 ns/iter (+/- 94) = 888 MB/s test vec::tests::bench_push_all_0010_0010 ... bench: 159 ns/iter (+/- 15) = 62 MB/s test vec::tests::bench_push_all_0100_0100 ... bench: 363 ns/iter (+/- 12) = 275 MB/s test vec::tests::bench_push_all_1000_1000 ... bench: 2860 ns/iter (+/- 415) = 349 MB/s ``` This also includes extra benchmarks for `Vec` and `MemWriter`.
2014-07-09auto merge of #15283 : kwantam/rust/master, r=alexcrichtonbors-11586/+7431
Add libunicode; move unicode functions from core - created new crate, libunicode, below libstd - split `Char` trait into `Char` (libcore) and `UnicodeChar` (libunicode) - Unicode-aware functions now live in libunicode - `is_alphabetic`, `is_XID_start`, `is_XID_continue`, `is_lowercase`, `is_uppercase`, `is_whitespace`, `is_alphanumeric`, `is_control`, `is_digit`, `to_uppercase`, `to_lowercase` - added `width` method in UnicodeChar trait - determines printed width of character in columns, or None if it is a non-NULL control character - takes a boolean argument indicating whether the present context is CJK or not (characters with 'A'mbiguous widths are double-wide in CJK contexts, single-wide otherwise) - split `StrSlice` into `StrSlice` (libcore) and `UnicodeStrSlice` (libunicode) - functionality formerly in `StrSlice` that relied upon Unicode functionality from `Char` is now in `UnicodeStrSlice` - `words`, `is_whitespace`, `is_alphanumeric`, `trim`, `trim_left`, `trim_right` - also moved `Words` type alias into libunicode because `words` method is in `UnicodeStrSlice` - unified Unicode tables from libcollections, libcore, and libregex into libunicode - updated `unicode.py` in `src/etc` to generate aforementioned tables - generated new tables based on latest Unicode data - added `UnicodeChar` and `UnicodeStrSlice` traits to prelude - libunicode is now the collection point for the `std::char` module, combining the libunicode functionality with the `Char` functionality from libcore - thus, moved doc comment for `char` from `core::char` to `unicode::char` - libcollections remains the collection point for `std::str` The Unicode-aware functions that previously lived in the `Char` and `StrSlice` traits are no longer available to programs that only use libcore. To regain use of these methods, include the libunicode crate and `use` the `UnicodeChar` and/or `UnicodeStrSlice` traits: extern crate unicode; use unicode::UnicodeChar; use unicode::UnicodeStrSlice; use unicode::Words; // if you want to use the words() method NOTE: this does *not* impact programs that use libstd, since UnicodeChar and UnicodeStrSlice have been added to the prelude. closes #15224 [breaking-change]
2014-07-09Register new snapshotsAlex Crichton-232/+12
Closes #15544
2014-07-09Remove car analogy.Steve Klabnik-10/+5
This was super silly anyway. Fixes #15539.
2014-07-09auto merge of #15220 : vhbit/rust/treemap-str-equiv, r=alexcrichtonbors-27/+136
- it allows to lookup using any str-equiv object, making TreeMaps finally usable (for example, it is much easier to work with JSON with lookup values being static strs) - actually provides pretty flexible solution which could be extended to other equivalent types (although it might be not that performant)
2014-07-09TreeMap: find enhancementsValerii Hiora-27/+136
find_with/find_mut_with which use provided closure for navigating tree and searching as flexible as possible
2014-07-09etc: Fix install script for rpath removalAlex Crichton-6/+35
This adds detection of the relevant LD_LIBRARY_PATH-like environment variable and appropriately sets it when testing whether binaries can run or not. Additionally, the installation prints a recommended value if one is necessary.
2014-07-09fix test failureskwantam-2/+4
- unicode tests live in coretest crate - libcollections str tests need UnicodeChar trait. - libregex perlw tests were checking a char in the Alphabetic category, \x2161. Confirmed perl 5.18 considers this a \w character. Changed to \x2961, which is not \w as the test expects.
2014-07-09auto merge of #15483 : AlisdairO/rust/master, r=alexcrichtonbors-6/+55
Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.
2014-07-09auto merge of #15540 : Gankro/rust/master, r=huonwbors-17/+15
Removing recursion from TreeMap implementation, because we don't have TCO. No need to add ```O(logn)``` extra stack frames to search in a tree. I find it curious that ```find_mut``` and ```find``` basically duplicated the same logic, but in different ways (iterative vs recursive), possibly to maneuvre around mutability rules, but that's a more fundamental issue to deal with elsewhere. Thanks to acrichto for the magic trick to appease borrowck (another issue to deal with elsewhere).
2014-07-09auto merge of #15530 : adrientetar/rust/proper-fonts, r=alexcrichtonbors-22/+426
- Treat WOFF as binary files so that git does not perform newline normalization. - Replace corrupt Heuristica files with Source Serif Pro &mdash; italics are [almost in production](https://github.com/adobe/source-serif-pro/issues/2) so I left Heuristica Italic which makes a good pair with SSP. Overall, Source Serif Pro is I think a better fit for rustdoc (cc @TheHydroImpulse). This ought to fix #15527. - Store Source Code Pro locally in order to make offline docs freestanding. Fixes #14778. Preview: http://adrientetar.legtux.org/cached/rust-docs/core.html r? @alexcrichton
2014-07-09Fix all the test falloutCorey Richardson-87/+100
2014-07-09ast: make Name its own typeCorey Richardson-106/+149
2014-07-09lexer: lex WS/COMMENT/SHEBANG rather than skippingCorey Richardson-87/+134
Now, the lexer will categorize every byte in its input according to the grammar. The parser skips over these while parsing, thus avoiding their presence in the input to syntax extensions.
2014-07-09syntax: don't parse numeric literals in the lexerCorey Richardson-266/+325
This removes a bunch of token types. Tokens now store the original, unaltered numeric literal (that is still checked for correctness), which is parsed into an actual number later, as needed, when creating the AST. This can change how syntax extensions work, but otherwise poses no visible changes. [breaking-change]
2014-07-09syntax: don't process string/char/byte/binary litsCorey Richardson-81/+327
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-09ast: add an `as_str` method to IdentCorey Richardson-0/+7
This is technically unsafe but interned strings are considered immortal.
2014-07-09lexer: add ident_from and ident_from_to methodsCorey Richardson-0/+14
2014-07-09lexer: shuffle around some functionsCorey Richardson-99/+100