Commit graph

30808 commits

Author SHA1 Message Date
Brian Anderson
5ee270a148 install: Run ldconfig when installing on Unix. Closes #15596.
If ldconfig fails it emits a warning. This is very possible when installing
to a non-system directory, so the warning tries to indicate that it may
not be a problem.
2014-07-10 18:27:21 -07:00
Brian Anderson
ad82cb5621 install: Make the LD_LIRARY_PATH warning more aesthetic 2014-07-10 18:16:48 -07:00
bors
b57d272e99 auto merge of #15564 : alexcrichton/rust/moar-hash, r=huonw
- semver::Version is now Eq, Ord, and Hash
- Path is now PartialOrd and Ord
2014-07-11 01:11:36 +00:00
Yuri Albuquerque
175d215eb6 Some documentation fixes and improvements 2014-07-10 19:51:11 -04:00
bors
0e80dbe59e auto merge of #15336 : jakub-/rust/diagnostics, r=brson
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-10 23:26:39 +00:00
Jakub Wieczorek
9b9cce2316 Add scaffolding for assigning alpha-numeric codes to rustc diagnostics 2014-07-11 00:32:00 +02:00
bors
a672456c40 auto merge of #15353 : aturon/rust/env-hashmap, r=alexcrichton
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-10 21:41:36 +00:00
Aaron Turon
bfa853f8ed io::process::Command: add fine-grained env builder
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-10 12:16:16 -07:00
bors
8bbf598d50 auto merge of #15559 : fhahn/rust/issue-15445-mut-cast, r=alexcrichton
I've added an error message for casts from raw pointers to floats #15445.
2014-07-10 19:06:59 +00:00
Alex Crichton
c26cd9f05d rustc: Exclude #[repr(C)] from non camel case
C structs predominately do not use camel case identifiers, and we have a clear
indicator for what's a C struct now, so excuse all of them from this stylistic
lint.
2014-07-10 10:19:38 -07:00
Alex Crichton
6bd79d32e9 rustc: Always mark #[crate_name] as used
It's just an annoying error if you use --crate-name on the command line and you
also have a #[crate_name] specified
2014-07-10 10:19:10 -07:00
Felix S. Klock II
59ab65b2d9 More robust install.sh: do runnability test in fresh subdirectory.
Fix #15558.
2014-07-10 19:18:46 +02:00
bors
345886cfdd auto merge of #14519 : hirschenberger/rust/issue-10934, r=alexcrichton
Issue #10934
2014-07-10 17:16:30 +00:00
Robert Clipsham
b5dd258884 Document event_loop_factory usage
Add a couple of lines mentioning event_loop_factory - no clear error message is
given if you attempt to perform I/O in tasks created in this fashion.
2014-07-10 16:52:34 +01:00
bors
7ab9bfab4e auto merge of #15578 : alexcrichton/rust/fix-dist-again, r=pnkfelix
This is already checked by the install script, no need to check it twice.
2014-07-10 15:34:02 +00:00
Alex Crichton
3e49647a49 mk: Don't run rustc manually during distcheck
This is already checked by the install script, no need to check it twice.
2014-07-10 08:09:43 -07:00
Alex Crichton
fe48c3b620 rustc: Forbid plugin_registrar in only rlib form
If a plugin registrar is available, the library must be found in dylib form, not
just in rlib form.

Closes #15475
2014-07-10 07:51:50 -07:00
Alex Crichton
8aa8ca7991 std: Add some implementation of common traits
- semver::Version is now Eq, Ord, and Hash
- Path is now PartialOrd and Ord
2014-07-10 07:50:58 -07:00
bors
f9fe251777 auto merge of #15569 : pcwalton/rust/reexport-intrinsics, r=cmr
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-10 12:46:30 +00:00
OGINO Masanori
7bed325254 Remove deprecated std::unstable module.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-10 20:01:57 +09:00
bors
a1bd5d359b auto merge of #15563 : luqmana/rust/nif, r=pcwalton 2014-07-10 11:01:32 +00:00
Florian Hahn
9bc7b6f437 typeck: check casts from pointers to floats, closes #15445 2014-07-10 12:28:46 +02:00
Mathijs van de Nes
c22b22d7b1 Mistake in AtomicBool spinlock example
The current example of a spinlock was not correct. The lock is actually acquired
when old == result. So we only need to deschedule when this is not the case.
2014-07-10 11:55:04 +02:00
bors
f865812451 auto merge of #15566 : japaric/rust/command-clone, r=alexcrichton
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-10 09:16:29 +00:00
Falco Hirschenberger
f8bc571df7 Add range lint for float literals, fixing #10934 2014-07-10 09:38:15 +02:00
OGINO Masanori
780a8291aa Use std::fmt::radix instead of to_str_radix.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-10 16:16:47 +09:00
Patrick Walton
6f96abf738 libcore: Reexport a couple of widely-used low-level intrinsics to reduce
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-09 22:28:23 -07:00
bors
6372915a78 auto merge of #15561 : huonw/rust/must-use-iterators, r=alexcrichton
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-10 05:16:28 +00:00
bors
898701cb35 auto merge of #15556 : alexcrichton/rust/snapshots, r=brson
Closes #15544
2014-07-10 03:21:30 +00:00
Luqman Aden
83122af6ca librustc: Translate input for transmute directly into dest. 2014-07-09 20:11:40 -07:00
bors
18520699f0 auto merge of #15554 : steveklabnik/rust/gh_15539, r=brson
This was super silly anyway.

Fixes #15539.
2014-07-10 01:36:28 +00:00
Jorge Aparicio
6d50828fdb Derive Clone for Command and StdioContainer 2014-07-09 20:18:26 -05:00
Luqman Aden
8fa30065aa librustc: Update to reflect changes to how intrinsics are codegened. 2014-07-09 17:51:05 -07:00
Luqman Aden
541c6391a7 librustc: Remove old codepaths for creating intrinsic functions. 2014-07-09 17:25:52 -07:00
bors
1b8e671d74 auto merge of #15514 : luqmana/rust/die-advance-die, r=cmr
Closes #15492.
2014-07-09 23:51:27 +00:00
Luqman Aden
5d39d0befa tests: Remove uses of advance. 2014-07-09 15:51:58 -07:00
Luqman Aden
f61472d743 librustc: Remove uses of advance. 2014-07-09 15:51:58 -07:00
Luqman Aden
9e123c4056 libsyntax: Remove uses of advance. 2014-07-09 15:51:58 -07:00
Luqman Aden
bb9552ef00 libgetopts: Use iterators instead of old-style loops. 2014-07-09 15:50:20 -07:00
Luqman Aden
a9d112b3e5 libcollections: Use iterators instead of old-style loops. 2014-07-09 15:50:20 -07:00
Luqman Aden
1eb4ce0297 libcore: Deprecate advance method on Iterators. 2014-07-09 15:50:20 -07:00
Luqman Aden
c6a148deab librustc: Don't emit call for intrinsics instead just trans at callsite. 2014-07-09 15:31:45 -07:00
bors
942c72e117 auto merge of #15550 : alexcrichton/rust/install-script, r=brson
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-09 22:06:27 +00:00
Huon Wilson
27d18fbe41 core: add #[must_use] attributes to iterator adaptor structs.
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-10 08:05:58 +10:00
Huon Wilson
b9e35a1644 lint: extend #[must_use] to handle a message.
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-10 08:05:58 +10:00
Alex Crichton
6f8b6c8c36 syntax: De-doc comment to fix nightlies
This reverts the promotion from line-comment to doc-comment in 4989a56 to fix
the compiler-docs target.

Closes #15553
2014-07-09 14:44:40 -07:00
bors
66e1f11ef4 auto merge of #15471 : erickt/rust/push_all, r=acrichto
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-09 20:21:29 +00:00
bors
fa7cbb5a46 auto merge of #15283 : kwantam/rust/master, r=alexcrichton
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-09 18:36:30 +00:00
Alex Crichton
0c71e0c596 Register new snapshots
Closes #15544
2014-07-09 10:57:58 -07:00
Steve Klabnik
6d9334d570 Remove car analogy.
This was super silly anyway.

Fixes #15539.
2014-07-09 13:04:52 -04:00