Commit Graph

37804 Commits

Author SHA1 Message Date
Alex Crichton
ebee4b4b37 rollup merge of #21736: sfackler/bufread-capacity-fix
We don't care about how much space the allocation has, but the actual
usable space in the buffer.

r? @alexcrichton
2015-01-30 12:03:24 -08:00
Alex Crichton
f8b3d5c2db rollup merge of #21733: mneumann/fix-io-rename-df 2015-01-30 12:03:23 -08:00
Alex Crichton
c0705c1f81 rollup merge of #21720: huonw/simd-cmp
Previously comparisons of SIMD types were always signed, even unsigned
comparisons, meaning 0xFFFF_FFFF_u32 < 0 inside a SIMD vector.

Fixes #21719.
2015-01-30 12:03:21 -08:00
Alex Crichton
ac1a03d742 rollup merge of #21718: alexcrichton/stabilize-from-str
This commits adds an associated type to the `FromStr` trait representing an
error payload for parses which do not succeed. The previous return value,
`Option<Self>` did not allow for this form of payload. After the associated type
was added, the following attributes were applied:

* `FromStr` is now stable
* `FromStr::Err` is now stable
* `FromStr::from_str` is now stable
* `StrExt::parse` is now stable
* `FromStr for bool` is now stable
* `FromStr for $float` is now stable
* `FromStr for $integral` is now stable
* Errors returned from stable `FromStr` implementations are stable
* Errors implement `Display` and `Error` (both impl blocks being `#[stable]`)

Closes #15138
2015-01-30 12:03:20 -08:00
Alex Crichton
0ba812fbf0 rollup merge of #21706: reem/missing-zeroable-impl-for-unique
This allows the use of `NonZero<Unique<T>>` for owned,
non-null raw pointers.

cc https://github.com/Gankro/collect-rs/pull/103
2015-01-30 12:03:19 -08:00
Alex Crichton
692a3661fb rollup merge of #21704: FlaPer87/macro-reexport
Conflicts:
	src/libstd/lib.rs
2015-01-30 12:03:16 -08:00
Alex Crichton
103f1459c0 rollup merge of #21702: nikomatsakis/issue-21636
Check and extract bindings from trait definitions.

Fixes #21636.

r? @nick29581
2015-01-30 12:02:56 -08:00
Alex Crichton
16120e9a1f rollup merge of #21693: tomjakubowski/rustdoc-fix-21442
Fix #21442
2015-01-30 12:02:55 -08:00
Alex Crichton
b70ec4d9f0 rollup merge of #21678: vojtechkral/threads-native-names
Fixes #10302

I really am not sure I'm doing this right, so here goes nothing...

Also testing this isn't easy. I don't have any other *nix boxes besides a Linux one.

Test code:

```rust
use std::thread;
use std::io::timer::sleep;
use std::time::duration::Duration;

fn make_thread<'a>(i: i64) -> thread::JoinGuard<'a, ()>
{
	thread::Builder::new().name(format!("MyThread{}", i).to_string()).scoped(move ||
	{
		println!("Start: {}", i);
		sleep(Duration::seconds(i));
		println!("End: {}", i);
	})
}

fn main()
{
	let mut guards = vec![make_thread(3)];

	for i in 4i64..16
	{
		guards.push(make_thread(i));
	}
}
```

GDB output on my machine:

```
(gdb) info threads
  Id   Target Id         Frame
  15   Thread 0x7fdfbb35f700 (LWP 23575) "MyThread3" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  14   Thread 0x7fdfba7ff700 (LWP 23576) "MyThread4" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  13   Thread 0x7fdfba5fe700 (LWP 23577) "MyThread5" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  12   Thread 0x7fdfba3fd700 (LWP 23578) "MyThread6" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  11   Thread 0x7fdfb8dfe700 (LWP 23580) "MyThread4" 0x00007fdfbb746193 in select () from /usr/lib/libc.so.6
  10   Thread 0x7fdfb8fff700 (LWP 23579) "MyThread7" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  9    Thread 0x7fdfb8bfd700 (LWP 23581) "MyThread8" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  8    Thread 0x7fdfb3fff700 (LWP 23582) "MyThread9" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  7    Thread 0x7fdfb3dfe700 (LWP 23583) "MyThread10" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  6    Thread 0x7fdfb3bfd700 (LWP 23584) "MyThread11" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  5    Thread 0x7fdfb2bff700 (LWP 23585) "MyThread12" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  4    Thread 0x7fdfb29fe700 (LWP 23586) "MyThread13" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  3    Thread 0x7fdfb27fd700 (LWP 23587) "MyThread14" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
  2    Thread 0x7fdfb1bff700 (LWP 23588) "MyThread15" 0x00007fdfbbe35a8d in nanosleep () from /usr/lib/libpthread.so.0
* 1    Thread 0x7fdfbc411800 (LWP 23574) "threads" 0x00007fdfbbe2e505 in pthread_join () from /usr/lib/libpthread.so.0
```
(I'm not sure why one of the threads is duplicated, but it does that without my patch too...)
2015-01-30 12:02:53 -08:00
Alex Crichton
b446c5b679 rollup merge of #21495: richo/unexported-unmangled-lint
The usecase is that functions made visible to systems outside of the
rust ecosystem require the symbol to be visible.

This adds a lint for functions that are not exported, but also not mangled.

It has some gotchas:

[ ]: There is fallout in core that needs taking care of
[ ]: I'm not convinced the error message is correct
[ ]: It has no tests

~~However, there's an underlying issue which I'd like feedback on- which is that my belief that that non-pub functions would not have their symbols exported, however that seems not to be the case in the first case that this lint turned up in rustc (`rust_fail`), which intuition suggests has been working.~~

This seems to be a separate bug in rust, wherein the symbols are exported in binaries, but not in rlibs or dylibs. This lint would catch that case.
2015-01-30 12:02:51 -08:00
Alex Crichton
9ff540ba37 rollup merge of #21494: jatinn/jsnav
Added javascript code to insert next/prev links in the rust book.
Related Issue - https://github.com/rust-lang/rust/issues/20835
2015-01-30 12:02:48 -08:00
Alex Crichton
15dd0a5acb rollup merge of #21385: nick29581/save-fix2
r? @huonw
2015-01-30 12:02:46 -08:00
Alex Crichton
341e858bd8 rollup merge of #20790: japaric/for-loops
As per [RFC #235][rfc], you can now do:

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#intoiterator-and-iterable

``` rust
let mut v = vec![1];

// iterate over immutable references
for x in &v {
    assert_eq!(x, &1);
}

// iterate over mutable references
for x in &mut v {
    assert_eq!(x, &mut 1);
}

// iterate over values, this consumes `v`
for x in v {
    assert_eq!(x, 1);
}
```

[breaking-change]s

For loops now "consume" (move) the iterator, this breaks iterating over mutable references to iterators, and also breaks multiple iterations over the same iterator:

``` rust
fn foo(mut it: &mut Iter) {  // `Iter` implements `Iterator`
    for x in it { .. }  //~ error: `&mut Iter` doesn't implement Iterator
}

fn bar() {
    for x in it { .. }  //~ note: `it` moved here
    for x in it { .. }  //~ error: `it` has been moved
}
```

Both cases can be fixed using the `by_ref()` adapter to create an iterator from the mutable reference:

``` rust
fn foo(mut it: &mut Iter) {
    for x in it.by_ref() { .. }
}

fn bar() {
    for x in it.by_ref() { .. }
    for x in it { .. }
}
```

This PR also makes iterator non-implicitly copyable, as this was source of subtle bugs in the libraries. You can still use `clone()` to explictly copy the iterator.

Finally, since the for loops are implemented in the frontend and use global paths to `IntoIterator`, `Iterator` and `Option` variants, users of the `core` crate will have to use add an `std` module to the root of their crate to be able to use for loops:

``` rust
#![no_std]

extern crate core;

fn main() {
    for x in 0..10 {}
}

#[doc(hidden)]
mod std {
    // these imports are needed to use for-loops
    pub use core::iter;
    pub use core::option;
}
```

---

r? @nikomatsakis @aturon
cc #18424
closes #18045
2015-01-30 12:02:44 -08:00
Alex Crichton
0cdde6e5e0 std: Stabilize FromStr and parse
This commits adds an associated type to the `FromStr` trait representing an
error payload for parses which do not succeed. The previous return value,
`Option<Self>` did not allow for this form of payload. After the associated type
was added, the following attributes were applied:

* `FromStr` is now stable
* `FromStr::Err` is now stable
* `FromStr::from_str` is now stable
* `StrExt::parse` is now stable
* `FromStr for bool` is now stable
* `FromStr for $float` is now stable
* `FromStr for $integral` is now stable
* Errors returned from stable `FromStr` implementations are stable
* Errors implement `Display` and `Error` (both impl blocks being `#[stable]`)

Closes #15138
2015-01-30 08:52:44 -08:00
Jorge Aparicio
b9a9030ed6 fix some cfail tests 2015-01-30 10:56:02 -05:00
Jorge Aparicio
60abb3bef2 fixes after rebase 2015-01-30 10:37:45 -05:00
Jorge Aparicio
2d76c94dd0 s/while let/for/g now that #21245 has been fixed 2015-01-30 10:37:45 -05:00
Jorge Aparicio
c013a018b8 add test for #21655
closes #21655
2015-01-30 10:37:44 -05:00
Jorge Aparicio
3a62590be2 add test for #20605
closes #20605
closes #20989 (duplicate)
closes #21379 (duplicate)
2015-01-30 10:37:44 -05:00
Jorge Aparicio
cb896a6e5f fix recursive call 2015-01-30 10:37:44 -05:00
Jorge Aparicio
d4b3e7f09c remove the Iterator lang item 2015-01-30 10:37:44 -05:00
Jorge Aparicio
bfaf4227b8 smoke out remaining bugs 2015-01-30 10:37:44 -05:00
Jorge Aparicio
ed82b5a70e remove Copy impls from iterators 2015-01-30 10:37:44 -05:00
Jorge Aparicio
9070345c0e add tests 2015-01-30 10:37:44 -05:00
Jorge Aparicio
a873316277 remove dead code 2015-01-30 10:37:44 -05:00
Jorge Aparicio
acb8c1aaa6 remove more ExprForLoops 2015-01-30 10:37:44 -05:00
Jorge Aparicio
76362f0a0e custom message for refutable patterns in for loops 2015-01-30 10:37:44 -05:00
Jorge Aparicio
5e1820f346 fix tests 2015-01-30 10:37:44 -05:00
Jorge Aparicio
f9865eac18 fix fallout 2015-01-30 10:37:44 -05:00
Jorge Aparicio
9fdc0effd2 implement for loop desugaring 2015-01-30 10:36:31 -05:00
Jorge Aparicio
a65d3f5b98 core: add the IntoIterator trait 2015-01-30 10:36:31 -05:00
bors
1a51eb9cca Auto merge of #21717 - nick29581:prelude-fullrange, r=acrichto
r? @alexcrichton
2015-01-30 12:43:41 +00:00
Richo Healey
ff25fd660a lint: Add test for no_mangle 2015-01-30 02:57:45 -08:00
bors
e0f5980ead Auto merge of #21351 - eddyb:x-coerce--a-new-hope, r=nikomatsakis
Coercions will now attempt to autoderef as needed before reborrowing.
This includes overloaded `Deref`, e.g. `&Rc<T>` coerces to `&T`, and
`DerefMut`, e.g. `&mut Vec<T>` coerces to `&mut [T]` (in addition to `&[T]`).
Closes #21432.
2015-01-30 07:57:14 +00:00
Richo Healey
d2ab7d3ea8 rt: allow unexported functions
rust_panic is unexported, however the metadata exported will usually
include it for attaching breakpoints.
2015-01-29 21:32:01 -08:00
Richo Healey
44ff72195e lint: warn about #[no_mangle] fns that aren't exported
The usecase is that functions made visible to systems outside of the
rust ecosystem require the symbol to be visible.
2015-01-29 21:32:00 -08:00
Nick Cameron
023d49e347 Change from core::ops::RangeFull to std::ops 2015-01-30 12:01:08 +13:00
Nick Cameron
bf2b473816 Rename FullRange to RangeFull 2015-01-30 12:01:08 +13:00
Nick Cameron
c64a96d385 Remove FullRange from the prelude etc. 2015-01-30 12:00:20 +13:00
Nick Cameron
a9d465fec9 Use absolute path to FullRange, rather than assuming it is in the prelude
Closes #21263

[breaking-change]

If you are using `core::ops::FullRange` you should change to using `core::ops::RangeFull`
2015-01-30 12:00:20 +13:00
Nick Cameron
9ba99666f3 Review changes 2015-01-30 11:58:10 +13:00
Nick Cameron
b159d9cde5 Make the save-analysis smoke test more thorough 2015-01-30 11:58:10 +13:00
Nick Cameron
78f617800f save-anlaysis: misc bug fixes
In particular, handling of struct literals where the struct name is a type alias, and tuple indexing.

Plus some other stuff.
2015-01-30 11:58:10 +13:00
Nick Cameron
dcbd418b1c save-analysis: handle absolute paths properly 2015-01-30 11:57:33 +13:00
Nick Cameron
1174550191 save-analysis: Use the correct span for extern crate 2015-01-30 11:57:33 +13:00
Nick Cameron
127c253d40 save-analysis: don't include the crate name in fully qualified paths 2015-01-30 11:57:33 +13:00
bors
52c74e63da Auto merge of #21692 - pnkfelix:fsk-fix-coerce-match-20055, r=eddyb
trans: When coercing to `Box<Trait>` or `Box<[T]>`, leave datum in it's original L-/R-value state.

This fixes a subtle issue where temporaries were being allocated (but not necessarily initialized) to the (parent) terminating scope of a match expression; in particular, the code to zero out the temporary emitted by `datum.store_to` is only attached to the particular match-arm for that temporary, but when going down other arms of the match expression, the temporary may falsely appear to have been initialized, depending on what the stack held at that location, and thus may have its destructor erroneously run at the end of the terminating scope.

FIx #20055.

(There may be a latent bug still remaining in `fn into_fat_ptr`, but I am so annoyed by the test/run-pass/coerce_match.rs failures that I want to land this now.)
2015-01-29 22:54:19 +00:00
Eduard Burtescu
ae076e1e3b Implement deref coercions (rust-lang/rfcs#241). 2015-01-30 00:30:12 +02:00
Eduard Burtescu
b48c4c8cf4 rustc_typeck: cleanup coercion logic that has been obsolete/unused for a while now. 2015-01-30 00:27:12 +02:00
Eduard Burtescu
6a478bdfd2 rustc_typeck: use FnCtxt in coercion, instead of mimicking a combiner. 2015-01-30 00:27:12 +02:00