about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2014-07-10auto merge of #15336 : jakub-/rust/diagnostics, r=brsonbors-3/+71
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-3/+71
2014-07-10auto merge of #15353 : aturon/rust/env-hashmap, r=alexcrichtonbors-14/+4
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-14/+4
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/+15
I've added an error message for casts from raw pointers to floats #15445.
2014-07-10typeck: check casts from pointers to floats, closes #15445Florian Hahn-0/+15
2014-07-10Add range lint for float literals, fixing #10934Falco Hirschenberger-0/+5
2014-07-10auto merge of #15561 : huonw/rust/must-use-iterators, r=alexcrichtonbors-0/+8
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-09tests: Remove uses of advance.Luqman Aden-4/+4
2014-07-10lint: extend `#[must_use]` to handle a message.Huon Wilson-0/+8
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: don't process string/char/byte/binary litsCorey Richardson-0/+15
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-09test: simplify numeric literal cfail testsCorey Richardson-53/+14
2014-07-09testsuite: merge some lexer testcasesCorey Richardson-238/+73
Now that the lexer is more robust, these tests don't need to be in separate files. Yay!
2014-07-08fix hygiene for test caseJohn Clements-4/+4
2014-07-08auto merge of #15493 : brson/rust/tostr, r=pcwaltonbors-112/+115
This updates https://github.com/rust-lang/rust/pull/15075. Rename `ToStr::to_str` to `ToString::to_string`. The naive renaming ends up with two `to_string` functions defined on strings in the prelude (the other defined via `collections::str::StrAllocating`). To remedy this I removed `StrAllocating::to_string`, making all conversions from `&str` to `String` go through `Show`. This has a measurable impact on the speed of this conversion, but the sense I get from others is that it's best to go ahead and unify `to_string` and address performance for all `to_string` conversions in `core::fmt`. `String::from_str(...)` still works as a manual fast-path. Note that the patch was done with a script, and ended up renaming a number of other `*_to_str` functions, particularly inside of rustc. All the ones I saw looked correct, and I didn't notice any additional API breakage. Closes #15046.
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-112/+115
[breaking-change]
2014-07-08auto merge of #15521 : nick29581/rust/type, r=pcwaltonbors-55/+55
closes #13367 [breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g., ``` trait Tr for Sized? {} fn foo<Sized? X: Share>(x: X) {} ```
2014-07-08auto merge of #15518 : alexcrichton/rust/fix-some-crate-names, r=sfacklerbors-0/+38
The output file was only being renamed based off #[crate_name], not #[crate_id] or --crate-name. Both of these behaviors have been restored now.
2014-07-08rustc: Fix naming output files with --crate-nameAlex Crichton-0/+38
The output file was only being renamed based off #[crate_name], not #[crate_id] or --crate-name. Both of these behaviors have been restored now.
2014-07-08Change DST syntax: type -> Sized?Nick Cameron-55/+55
closes #13367 [breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g., ``` trait Tr for Sized? {} fn foo<Sized? X: Share>(x: X) {} ```
2014-07-08auto merge of #15508 : jakub-/rust/struct-pattern-witness, r=alexcrichtonbors-4/+4
2014-07-08auto merge of #15443 : pcwalton/rust/module-and-type-with-same-name, r=nick29581bors-4/+23
This will break code that looks like: struct Foo { ... } mod Foo { ... } Change this code to: struct Foo { ... } impl Foo { ... } Or rename the module. Closes #15205. [breaking-change] r? @nick29581
2014-07-08auto merge of #15406 : luqmana/rust/nop, r=pcwaltonbors-0/+40
Extend the null ptr optimization to work with slices, closures, procs, & trait objects by using the internal pointers as the discriminant. This decreases the size of `Option<&[int]>` (and similar) by one word.
2014-07-07auto merge of #15394 : pcwalton/rust/new-index-traits, r=nick29581bors-74/+127
This will break code that used the old `Index` trait. Change this code to use the new `Index` traits. For reference, here are their signatures: pub trait Index<Index,Result> { fn index<'a>(&'a self, index: &Index) -> &'a Result; } pub trait IndexMut<Index,Result> { fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result; } Closes #6515. [breaking-change] r? @nick29581
2014-07-07auto merge of #15440 : pcwalton/rust/struct-aliases, r=brsonbors-2/+83
Closes #4508. r? @nick29581
2014-07-07Improve non-exhaustive pattern witnesses for structs with multiple fieldsJakub Wieczorek-4/+4
2014-07-07librustc (RFC #34): Implement the new `Index` and `IndexMut` traits.Patrick Walton-74/+127
This will break code that used the old `Index` trait. Change this code to use the new `Index` traits. For reference, here are their signatures: pub trait Index<Index,Result> { fn index<'a>(&'a self, index: &Index) -> &'a Result; } pub trait IndexMut<Index,Result> { fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result; } Closes #6515. [breaking-change]
2014-07-07librustc: Disallow modules and types from having the same name.Patrick Walton-4/+23
This will break code that looks like: struct Foo { ... } mod Foo { ... } Change this code to: struct Foo { ... } impl Foo { ... } Or rename the module. Closes #15205. [breaking-change]
2014-07-07Strip empty strings from link argsSteven Fackler-0/+20
Closes #15487
2014-07-07auto merge of #15489 : jakub-/rust/issue-15488, r=pcwaltonbors-0/+38
Fixes #15488.
2014-07-07auto merge of #15411 : mitchmindtree/rust/master, r=alexcrichtonbors-0/+55
I ran `make check` and everything went smoothly. I also tested `#[deriving(Decodable, Encodable)]` on a struct containing both Cell<T> and RefCell<T> and everything now seems to work fine.
2014-07-07Implemented Decodable/Encodable for Cell and RefCell. Fixes #15395mitchmindtree-0/+55
Updated PR with fixme and test Updated PR with fixme and test
2014-07-07Properly bind nested pattern bindings when there's more than oneJakub Wieczorek-0/+38
Fixes #15488.
2014-07-06Add a test case for #12187, which appears to have been fixedJakub Wieczorek-0/+36
Closes #12187.
2014-07-06auto merge of #15454 : jakub-/rust/15453, r=huonwbors-0/+7
I forget we now have byte string literals.
2014-07-05rustc: Default #[crate_name] on input, not outputAlex Crichton-7/+10
2014-07-05Test fixes and rebase conflictsAlex Crichton-2/+4
2014-07-05rustc: Repurpose the --crate-name CLI flagAlex Crichton-6/+22
In a cargo-driven world the primary location for the name of a crate will be in its manifest, not in the source file itself. The purpose of this flag is to reduce required duplication for new cargo projects. This is a breaking change because the existing --crate-name flag actually printed the crate name. This flag was renamed to --print-crate-name, and to maintain consistence, the --crate-file-name flag was renamed to --print-file-name. To maintain backwards compatibility, the --crate-file-name flag is still recognized, but it is deprecated. [breaking-change]
2014-07-05test: Fix tests for crate_id removalAlex Crichton-311/+144
This involved removing some tests whose functionality was removed such as many of the crateresolve tests
2014-07-05rustc: Add a flag for specifying dependenciesAlex Crichton-0/+102
This comit implements a new flag, --extern, which is used to specify where a crate is located. The purpose of this flag is to bypass the normal crate loading/matching of the compiler to point it directly at the right file. This flag takes the form `--extern foo=bar` where `foo` is the name of a crate and `bar` is the location at which to find the crate. Multiple `--extern` directives are allowed with the same crate name to specify the rlib/dylib pair for a crate. It is invalid to specify more than one rlib or more than one dylib, and it's required that the crates are valid rust crates. I have also added some extensive documentation to metadata::loader about how crate loading should work. RFC: 0035-remove-crate-id
2014-07-05Fix #15453Jakub Wieczorek-0/+7
2014-07-05auto merge of #15442 : luqmana/rust/odp, r=pnkfelixbors-0/+64
Inadvertently changed the order in which destructors ran in certain cases with #15076. Fixes #15438.
2014-07-05auto merge of #15284 : apoelstra/rust/bitv-methods, r=cmrbors-3/+3
The types `Bitv` and `BitvSet` are badly out of date. This PR: - cleans up the code (primarily, simplifies `Bitv` and implements `BitvSet` in terms of `Bitv`) - implements several new traits for `Bitv` - adds new functionality to `Bitv` and `BitvSet` - replaces internal iterators with external ones - updates documentation - minor bug fixes This is a significantly souped-up version of PR #15139 and is the result of the discussion there.
2014-07-04librustc: Make sure to run destructors in the right order when matching on ↵Luqman Aden-0/+64
moved value.
2014-07-04librustc: Accept type aliases for structures in structure literals andPatrick Walton-2/+83
structure patterns. Closes #4508.
2014-07-04Add tests for null pointer opt.Luqman Aden-0/+40
2014-07-04auto merge of #15405 : pcwalton/rust/delifetime, r=nick29581bors-8/+8
This was parsed by the parser but completely ignored; not even stored in the AST! This breaks code that looks like: static X: &'static [u8] = &'static [1, 2, 3]; Change this code to the shorter: static X: &'static [u8] = &[1, 2, 3]; Closes #15312. [breaking-change] r? @nick29581
2014-07-04auto merge of #15388 : jakub-/rust/issue-12285, r=pcwaltonbors-0/+22
Unit-like struct patterns are irrefutable, no need for a branch. And some cleanup while I'm at it.
2014-07-04librustc: Remove the `&LIFETIME EXPR` production from the language.Patrick Walton-8/+8
This was parsed by the parser but completely ignored; not even stored in the AST! This breaks code that looks like: static X: &'static [u8] = &'static [1, 2, 3]; Change this code to the shorter: static X: &'static [u8] = &[1, 2, 3]; Closes #15312. [breaking-change]
2014-07-04auto merge of #15356 : pcwalton/rust/wrong-implementor, r=alexcrichtonbors-0/+78
parameters. This can break code that mistakenly used type parameters in place of `Self`. For example, this will break: trait Foo { fn bar<X>(u: X) -> Self { u } } Change this code to not contain a type error. For example: trait Foo { fn bar<X>(_: X) -> Self { self } } Closes #15172. [breaking-change] r? @alexcrichton