Commit graph

37636 commits

Author SHA1 Message Date
Manish Goregaokar
78567f1244 Rollup merge of #21667 - nagisa:sbook-links, r=Gankro
Fixes #21665

r? @steveklabnik
2015-01-28 04:37:50 +05:30
Manish Goregaokar
1df030059b Rollup merge of #21676 - Victory:fix-deprication-in-random, r=alexcrichton
Cleanup mention of uint, use usize/us instead. This includes the example `println!("{}", 2u * x);`
2015-01-28 04:35:57 +05:30
Manish Goregaokar
2ac91a382d Rollup merge of #21686 - richo:python-fixes, r=alexcrichton
While waiting on some builds I started cleaning up the various python bits and pieces.

I'm going to keep poking, want to ping me before the next rollup?
2015-01-28 04:34:40 +05:30
Manish Goregaokar
28b0271f89 Rollup merge of #21658 - Manishearth:index_on_unimplemented, r=Gankro
Helps issues like [these](http://www.reddit.com/r/rust/comments/2tpefm/unable_to_access_array_elements/)

r? @Gankro

rollup-worthy
2015-01-28 04:32:20 +05:30
Manish Goregaokar
335e8af98a Rollup merge of #21625 - carols10cents:sliceext-examples, r=alexcrichton
Hi! I added some examples to some SliceExt methods that didn't have any.

I'm looking forward to feedback and I'm happy to change anything-- it looks like the doc conventions are still a bit in flux, based on the discussions going on in [rfc 505](https://github.com/rust-lang/rfcs/pull/505).

I was most unsure about examples for methods that return iterators over slices... I wanted to use asserts on the result of calling `.next()` like in [this permutations example](804c1446b3/src/libcollections/slice.rs (L608-L617)), but then it gets all cluttered up with lifetime stuff... so I went with iterating and printing and mentioning what the expected printed output is like in [this chunks example](804c1446b3/src/libcollections/slice.rs (L297-L304))... any ideas for the best ways to do this are appreciated.

Thank you! ❤️
2015-01-27 22:24:04 +05:30
Manish Goregaokar
4af4b377a0 Rollup merge of #21624 - emanueLczirai:vim_syntastic_fix, r=sanxiyn
when saving .rs files under vim
do not fail to run the syntax checker
error: Unrecognized option: 'parse-only'.

due to this commit
953f294ea3
which removed the deprecated flag --parse-only
2015-01-27 22:24:04 +05:30
Manish Goregaokar
36d0e90e6b Rollup merge of #21623 - dinfuehr:patch-1, r=alexcrichton 2015-01-27 22:24:03 +05:30
Manish Goregaokar
cb63bcb98c Rollup merge of #21618 - snowe2010:documentation, r=Gankro
Lifetime elision with two input references is not clear.
Closes #21284
2015-01-27 22:24:03 +05:30
Manish Goregaokar
54cdae693c Rollup merge of #21612 - bombless:patch-3, r=alexcrichton 2015-01-27 22:24:03 +05:30
Manish Goregaokar
3cda6afac4 Rollup merge of #21608 - JeffBelgum:collections-reform-issue-19986-add-append-and-split-off, r=Gankro
@brson @Gankro
2015-01-27 22:24:03 +05:30
Manish Goregaokar
51ff9e82ec Rollup merge of #21602 - japaric:derive-copy, r=alexcrichton 2015-01-27 22:24:02 +05:30
Manish Goregaokar
8418725b0d Rollup merge of #21597 - iKevinY:mobile-api-docs, r=cmr
This PR removes the `min-width` rule from `body` so that no horizontal scrolling is necessary on mobile, and also hides out-of-band information on mobile to create more room for the in-band information.
2015-01-27 22:24:02 +05:30
Manish Goregaokar
e7bcb27939 Rollup merge of #21591 - GuillaumeGomez:hash, r=alexcrichton
Fixes #21547 issue.
2015-01-27 22:24:02 +05:30
bors
777435990e Auto merge of #21586 - pyfisch:patch-1, r=alexcrichton
Spellfix for `Debug` trait documentation. Change "most all types should implement this" to "all types should implement this". Same fix for deprecated `Show` trait.
2015-01-27 14:03:06 +00:00
bors
d77f6d5366 Auto merge of #21657 - pnkfelix:block-remainder-extents, r=nikomatsakis
Add `CodeExtent::Remainder` variant; pre-req for new scoping/drop rules.

This new enum variant introduces finer-grain code extents, i.e. we now track that a binding lives only for a suffix of a block, and (importantly) will be dropped when it goes out of scope *before* the bindings that occurred earlier in the block.

Both of these notions are neatly captured by marking the block (and each suffix) as an enclosing scope of the next suffix beneath it.

This is work that is part of the foundation for issue #8861.

(It actually has been seen in earlier posted pull requests, in particular #21022; I have just factored it out into its own PR to ease my own near-future rebasing, and also get people used to the new rules.)

----

These finer grained scopes do mean that some code is newly rejected by `rustc`; for example:

```rust
let mut map : HashMap<u8, &u8> = HashMap::new();
let tmp = Box::new(2);
map.insert(43, &*tmp);
```

This will now fail to compile with a message that `*tmp` does not live long enough, because the scope of `tmp` is now strictly smaller than
that of `map`, and the use of `&u8` in map's type requires that the borrowed references are all to data that live at least as long as the map.

The usual fix for a case like this is to move the binding for `tmp` up above that of `map`; note that you can still leave the initialization in the original spot, like so:

```rust
let tmp;
let mut map : HashMap<u8, &u8> = HashMap::new();
tmp = box 2;
map.insert(43, &*tmp);
```

Similarly, one can encounter an analogous situation with `Vec`: one would need to rewrite:

```rust
let mut vec = Vec::new();
let tmp = 'c';
vec.push(&tmp);
```

as:

```rust
let tmp;
let mut vec = Vec::new();
tmp = 'c';
vec.push(&tmp);
```

----

In some corner cases, it does not suffice to reorder the bindings; in particular, when the types for both bindings need to reflect exactly the *same* code extent, and a parent/child relationship between them does not work.

In pnkfelix's experience this has arisen most often when mixing uses of cyclic data structures while also allowing a lifetime parameter `'a` to flow into a type parameter context where the type is *invariant* with respect to the type parameter. An important instance of this is `arena::TypedArena<T>`, which is invariant with respect to `T`.

(The reason that variance is relevant is this: *if* `TypedArena` were covariant with respect to its type parameter, then we could assign it
the longer lifetime when it is initialized, and then convert it to a subtype (via covariance) with a shorter lifetime when necessary.  But `TypedArena` is invariant with respect to its type parameter, and thus if `S` is a subtype of `T` (in particular, if `S` has a lifetime parameter that is shorter than that of `T`), then a `TypedArena<S>` is unrelated to `TypedArena<T>`.)

Concretely, consider code like this:

```rust
struct Node<'a> { sibling: Option<&'a Node<'a>> }
struct Context<'a> {
    // because of this field, `Context<'a>` is invariant with respect to `'a`.
    arena: &'a TypedArena<Node<'a>>,
    ...
}
fn new_ctxt<'a>(arena: &'a TypedArena<Node<'a>>) -> Context<'a> { ... }
fn use_ctxt<'a>(fcx: &'a Context<'a>) { ... }

let arena = TypedArena::new();
let ctxt = new_ctxt(&arena);

use_ctxt(&ctxt);
```

In these situations, if you try to introduce two bindings via two distinct `let` statements, each is (with this commit) assigned a distinct extent, and the region inference system cannot find a single region to assign to the lifetime `'a` that works for both of the bindings. So you get an error that `ctxt` does not live long enough; but moving its binding up above that of `arena` just shifts the error so now the compiler complains that `arena` does not live long enough.

 * SO: What to do? The easiest fix in this case is to ensure that the two bindings *do* get assigned the same static extent, by stuffing both
bindings into the same let statement, like so:

```rust
let (arena, ctxt): (TypedArena, Context);
arena = TypedArena::new();
ctxt = new_ctxt(&arena);

use_ctxt(&ctxt);
```

----

Due to the new code restrictions outlined above, this is a ...

[breaking-change]
2015-01-27 11:07:26 +00:00
Felix S. Klock II
d6bf04a22e Add CodeExtent::Remainder variant; pre-req for new scoping/drop rules.
This new variant introduces finer-grain code extents, i.e. we now
track that a binding lives only for a suffix of a block, and
(importantly) will be dropped when it goes out of scope *before* the
bindings that occurred earlier in the block.

Both of these notions are neatly captured by marking the block (and
each suffix) as an enclosing scope of the next suffix beneath it.

This is work that is part of the foundation for issue #8861.

(It actually has been seen in earlier posted pull requests; I have
just factored it out into its own PR to ease my own rebasing.)

----

These finer grained scopes do mean that some code is newly rejected by
`rustc`; for example:

```rust
let mut map : HashMap<u8, &u8> = HashMap::new();
let tmp = Box::new(2);
map.insert(43, &*tmp);
```

This will now fail to compile with a message that `*tmp` does not live
long enough, because the scope of `tmp` is now strictly smaller than
that of `map`, and the use of `&u8` in map's type requires that the
borrowed references are all to data that live at least as long as the
map.

The usual fix for a case like this is to move the binding for `tmp`
up above that of `map`; note that you can still leave the initialization
in the original spot, like so:

```rust
let tmp;
let mut map : HashMap<u8, &u8> = HashMap::new();
tmp = box 2;
map.insert(43, &*tmp);
```

Similarly, one can encounter an analogous situation with `Vec`: one
would need to rewrite:

```rust
let mut vec = Vec::new();
let tmp = 'c';
vec.push(&tmp);
```

as:

```
let tmp;
let mut vec = Vec::new();
tmp = 'c';
vec.push(&tmp);
```

----

In some corner cases, it does not suffice to reorder the bindings; in
particular, when the types for both bindings need to reflect exactly
the *same* code extent, and a parent/child relationship between them
does not work.

In pnkfelix's experience this has arisen most often when mixing uses
of cyclic data structures while also allowing a lifetime parameter
`'a` to flow into a type parameter context where the type is
*invariant* with respect to the type parameter. An important instance
of this is `arena::TypedArena<T>`, which is invariant with respect
to `T`.

(The reason that variance is relevant is this: *if* `TypedArena` were
covariant with respect to its type parameter, then we could assign it
the longer lifetime when it is initialized, and then convert it to a
subtype (via covariance) with a shorter lifetime when necessary.  But
`TypedArena` is invariant with respect to its type parameter, and thus
if `S` is a subtype of `T` (in particular, if `S` has a lifetime
parameter that is shorter than that of `T`), then a `TypedArena<S>` is
unrelated to `TypedArena<T>`.)

Concretely, consider code like this:

```rust
struct Node<'a> { sibling: Option<&'a Node<'a>> }
struct Context<'a> {
    // because of this field, `Context<'a>` is invariant with respect to `'a`.
    arena: &'a TypedArena<Node<'a>>,
    ...
}
fn new_ctxt<'a>(arena: &'a TypedArena<Node<'a>>) -> Context<'a> { ... }
fn use_ctxt<'a>(fcx: &'a Context<'a>) { ... }

let arena = TypedArena::new();
let ctxt = new_ctxt(&arena);

use_ctxt(&ctxt);
```

In these situations, if you try to introduce two bindings via two
distinct `let` statements, each is (with this commit) assigned a
distinct extent, and the region inference system cannot find a single
region to assign to the lifetime `'a` that works for both of the
bindings. So you get an error that `ctxt` does not live long enough;
but moving its binding up above that of `arena` just shifts the error
so now the compiler complains that `arena` does not live long enough.

SO: What to do? The easiest fix in this case is to ensure that the two
bindings *do* get assigned the same static extent, by stuffing both
bindings into the same let statement, like so:

```rust
let (arena, ctxt): (TypedArena, Context);
arena = TypedArena::new();
ctxt = new_ctxt(&arena);

use_ctxt(&ctxt);
```

Due to the new code rejections outlined above, this is a ...

[breaking-change]
2015-01-27 10:26:52 +01:00
Felix S. Klock II
43d08f861a accommodate new scoping rules in librustc_driver unit tests. 2015-01-27 10:26:52 +01:00
Felix S. Klock II
2c2f0f1216 accommodate new scoping rules in libstd unit tests. 2015-01-27 10:26:52 +01:00
Felix S. Klock II
70192ab779 accommodate new scoping rules in test/compile-fail. 2015-01-27 10:26:52 +01:00
Felix S. Klock II
9fe8d8602d accommodate new scoping rules in test/run-pass. 2015-01-27 10:26:52 +01:00
Felix S. Klock II
86bde933f8 accommodate new scoping rules in rustc and rustdoc source. 2015-01-27 10:26:52 +01:00
Richo Healey
7cabb2124e Fix PEP8 for tidy 2015-01-27 01:26:13 -08:00
Richo Healey
1db2039f52 Fix PEP8 in mirror-all-snapshots 2015-01-27 01:26:03 -08:00
Richo Healey
a4ab5e59a7 Fix PEP8 for latest-unix-snaps.py 2015-01-27 01:26:03 -08:00
Richo Healey
109a6bc86c Fix PEP8 for htmldocck 2015-01-27 01:26:03 -08:00
Richo Healey
bbb2871bfb Fix PEP8 for generate-keyword-tests 2015-01-27 01:26:03 -08:00
Richo Healey
888a149088 Fix PEP8 for extract_grammar 2015-01-27 01:26:03 -08:00
Richo Healey
7faffbef68 Fix PEP8 for errorck 2015-01-27 01:26:02 -08:00
Richo Healey
91928dd9e9 Fix PEP8 for check-summary.py 2015-01-27 01:26:02 -08:00
Richo Healey
f7509df8f9 Fix PEP8 in sugarise-doc-comments 2015-01-27 01:26:02 -08:00
Richo Healey
ab0081ae45 Fix PEP8 in snapshot.py 2015-01-27 01:26:02 -08:00
Richo Healey
58d03ad95d Fix PEP8 in maketest 2015-01-27 01:26:01 -08:00
Richo Healey
04408fadd3 Fix PEP8 in make-win-dist 2015-01-27 01:25:54 -08:00
Richo Healey
2822bc582c Fix PEP8 in lldb_rust_formatters.py 2015-01-27 01:25:54 -08:00
Richo Healey
f697a06da4 Fix PEP8 in lldb_batchmode.py 2015-01-27 01:25:54 -08:00
Richo Healey
958dea1745 make get-snapshot externally usable 2015-01-27 01:09:38 -08:00
Richo Healey
f230683b1a Fix PEP8 in get-snapshot 2015-01-27 01:09:38 -08:00
Richo Healey
6af36031e2 Fix PEP8 in gdb pretty printer 2015-01-27 01:09:38 -08:00
bors
e365e4c054 Auto merge of #21564 - steveklabnik:doc_cell, r=alexcrichton 2015-01-27 08:40:39 +00:00
bors
1c87af2eba Auto merge of #21646 - dotdash:default_target_cpu, r=Aatch
Using `generic` as the target cpu limits the generated code to the bare basics for the arch, while we can probably assume that we'll actually be running on somewhat modern hardware. This updates the default target CPUs for the x86 and x86_64 archs to match clang's behaviour.

Refs #20777
2015-01-27 05:15:04 +00:00
bors
a6a6fadbb9 Auto merge of #21543 - alexcrichton:old-io, r=aturon
In preparation for the I/O rejuvination of the standard library, this commit
renames the current `io` module to `old_io` in order to make room for the new
I/O modules. It is expected that the I/O RFCs will land incrementally over time
instead of all at once, and this provides a fresh clean path for new modules to
enter into as well as guaranteeing that all old infrastructure will remain in
place for some time.

As each `old_io` module is replaced it will be deprecated in-place for new
structures in `std::{io, fs, net}` (as appropriate).

This commit does *not* leave a reexport of `old_io as io` as the deprecation
lint does not currently warn on this form of use. This is quite a large breaking
change for all imports in existing code, but all functionality is retained
precisely as-is and path statements simply need to be renamed from `io` to
`old_io`.

[breaking-change]
2015-01-27 02:46:09 +00:00
Carol Nichols
ebd2d8db76 Correct a typo in a deprecation warning 2015-01-26 21:09:50 -05:00
Carol Nichols
b8b52d61f3 Add examples to documentation of SliceExt methods 2015-01-26 21:09:50 -05:00
Victory
ac285d5531 Don't use if we can avoid it 2015-01-26 20:18:24 -05:00
Victory
23fd8cad04 cleanup depricated uint in rand mod and rand os 2015-01-26 19:48:29 -05:00
Alex Crichton
5d836cdf86 std: Rename Writer::write to Writer::write_all
In preparation for upcoming changes to the `Writer` trait (soon to be called
`Write`) this commit renames the current `write` method to `write_all` to match
the semantics of the upcoming `write_all` method. The `write` method will be
repurposed to return a `usize` indicating how much data was written which
differs from the current `write` semantics. In order to head off as much
unintended breakage as possible, the method is being deprecated now in favor of
a new name.

[breaking-change]
2015-01-26 16:01:58 -08:00
Alex Crichton
3a07f859b8 Fallout of io => old_io 2015-01-26 16:01:16 -08:00
Alex Crichton
f72b164510 std: Rename io to old_io
In preparation for the I/O rejuvination of the standard library, this commit
renames the current `io` module to `old_io` in order to make room for the new
I/O modules. It is expected that the I/O RFCs will land incrementally over time
instead of all at once, and this provides a fresh clean path for new modules to
enter into as well as guaranteeing that all old infrastructure will remain in
place for some time.

As each `old_io` module is replaced it will be deprecated in-place for new
structures in `std::{io, fs, net}` (as appropriate).

This commit does *not* leave a reexport of `old_io as io` as the deprecation
lint does not currently warn on this form of use. This is quite a large breaking
change for all imports in existing code, but all functionality is retained
precisely as-is and path statements simply need to be renamed from `io` to
`old_io`.

[breaking-change]
2015-01-26 16:01:16 -08:00
bors
a637365b10 Auto merge of #21606 - arielb1:clean-cast, r=huonw
This also makes the cast error messages somewhat more uniform.
2015-01-26 22:19:44 +00:00
Jeff Belgum
b93843e1c9 add split_off method to vec with tests 2015-01-26 14:08:38 -08:00