Commit graph

35342 commits

Author SHA1 Message Date
Clark Gaebel
d57f25907b [collections] Adds drain: a way to sneak out the elements while clearing.
It is useful to move all the elements out of some collections without
deallocating the underlying buffer. It came up in IRC, and this patch
implements it as `drain`. This has been discussed as part of RFC 509.

r? @Gankro
cc: @frankmcsherry
2014-12-18 22:16:51 -05:00
bors
f9a48492a8 auto merge of #19984 : japaric/rust/macro-expressions, r=alexcrichton
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]

---

Rebased version of #18958
r? @alexcrichton 
cc @pcwalton
2014-12-18 17:32:07 +00:00
Patrick Walton
ddb2466f6a librustc: Always parse macro!()/macro![] as expressions if not
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
2014-12-18 12:09:07 -05:00
bors
c4d58ce15b auto merge of #19819 : vadimcn/rust/fix-demangle, r=alexcrichton
Windows dbghelp strips leading underscores from symbols, and I could not find a way to turn this off.  So let's accept  "ZN...E" form too.
Also, print PC displacement from symbols.  This is helpful in gauging whether the PC was indeed within the function displayed in the backtrace, or whether it just happened to be the closest public symbol in the module.
2014-12-18 14:42:06 +00:00
bors
2a231594c4 auto merge of #19780 : jakub-/rust/e-needstest, r=alexcrichton
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
2014-12-18 12:21:57 +00:00
bors
c0b2885ee1 auto merge of #19769 : nick29581/rust/coerce-if, r=nikomatsakis
r? @nikomatsakis 

We discussed coercions for `if` and `match` expressions. `if` seems to work already, was there some specific behaviour which wasn't working?
2014-12-18 06:41:59 +00:00
Nick Cameron
46eb72453f Propagate coercions through match expressions. 2014-12-18 13:48:05 +13:00
Jakub Bukaj
62d80df0c9 Add tests for E-needstest issues 2014-12-17 23:00:32 +01:00
bors
22a9f250b5 auto merge of #19958 : alexcrichton/rust/rollup, r=alexcrichton 2014-12-17 21:33:15 +00:00
Alex Crichton
5c98952409 Test fixes and rebase conflicts 2014-12-17 11:50:32 -08:00
Alex Crichton
76fbb5d527 rollup merge of #19947: csouth3/arc-borrowfrom
Closes #19937.
2014-12-17 11:50:31 -08:00
Alex Crichton
7ffbd8bad5 rollup merge of #19943: steveklabnik/doc_std_vec
Random improvements to the `std::vec` docs.
2014-12-17 11:50:31 -08:00
Alex Crichton
cbc3cf7a9e rollup merge of #19942: steveklabnik/doc_std_mem 2014-12-17 11:50:31 -08:00
Alex Crichton
1b9b647b07 rollup merge of #19940: phi-gamma/canonical-master
Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
2014-12-17 11:50:31 -08:00
Alex Crichton
a7bb4795d3 rollup merge of #19935: cgaebel/hashmap-tuple-indexing
r? @Gankro @pczarn
2014-12-17 11:50:31 -08:00
Alex Crichton
42dbee098b rollup merge of #19930: cllns/lowercase-if
On the [guide site](http://doc.rust-lang.org/guide.html#if) I was confused when I got to "5 If". It looked like "5 LF" in lowercase.

Changing the if to lowercase solves this problem. I know titles are all capitalized, but I think it makes sense in this case to keep it lowercase, since `if` is a reserved word. I'd also be open to making it ```    `if`   ``` but I'm not sure how that would look on the site.

Before:
![screen shot 2014-12-16 at 12 58 01](https://cloud.githubusercontent.com/assets/632942/5458866/cb34c006-8523-11e4-89ef-3a3964bcedfc.png)
After:
![screen shot 2014-12-16 at 12 58 14](https://cloud.githubusercontent.com/assets/632942/5458865/cb33c444-8523-11e4-8d95-d377ed583ed6.png)
2014-12-17 11:50:30 -08:00
Alex Crichton
b56d4bf916 rollup merge of #19923: pnkfelix/fix-make-tags.emacs
Fix `make TAGS.emacs`.

@nikomatsakis has been complaining to me about this.  (I had not noticed since I drive `ctags` with a separate script.)

(Suitable for a rollup build.)
2014-12-17 11:50:30 -08:00
Alex Crichton
a02885e167 rollup merge of #19918: pnkfelix/ast-refactor-make-place-in-exprbox-an-option
This is to allow us to migrate away from UnUniq in a followup commit,
and thus unify the code paths related to all forms of `box`.
2014-12-17 11:50:30 -08:00
Alex Crichton
b496adaefb rollup merge of #19912: P1start/fn-formatting
This is to encourage the use of the sugary syntax instead of the `<>` syntax, which will not be usable post-1.0. Rustdoc [still uses the `<>` syntax](https://github.com/rust-lang/rust/issues/19909), so if a rustdoc wizard is looking for something to do, it would be nice to use the parenthetical syntax there as well. (I tried to patch rustdoc as well, but failed…)
2014-12-17 11:50:30 -08:00
Alex Crichton
1b929090ac rollup merge of #19911: mdinger/tuple_tests2
Fixes some tuple indexing deprecation warnings. Didn't test. Don't see how it could fail unless I need to modify a makefile somewhere...

r? @alexcrichton
2014-12-17 11:50:30 -08:00
Alex Crichton
cce3fc043e rollup merge of #19905: AaronFriel/patch-1
Was testing rustup on a very minimal Debian installation and got errors during the install process (error occurred in `install.sh` of the Rust nightly.)

Noticed that Rustup was downloading the i686 nightly instead of x86-64. Installing `file` fixed the problem, and this patch adds the probe to ensure file is installed before attempting to use it.

There may still be an issue with the i686 installation, I did not investigate further.
2014-12-17 11:50:30 -08:00
Alex Crichton
3369b33a20 rollup merge of #19902: alexcrichton/second-pass-mem
This commit stabilizes the `mem` and `default` modules of std.
2014-12-17 11:50:29 -08:00
Alex Crichton
cada943f14 rollup merge of #19895: jbranchaud/add-string-add-doctest 2014-12-17 11:50:29 -08:00
Alex Crichton
1f2a18c7a6 rollup merge of #19893: JacobEdelman/patch-1
FIxed the spelling of the word "specific".
2014-12-17 11:50:29 -08:00
Alex Crichton
4a7757038a rollup merge of #19892: pnkfelix/region-graphviz
Added -Z print-region-graph debugging option; produces graphviz visualization of region inference constraint graph.

Optionally uses environment variables `RUST_REGION_GRAPH=<path_template>` and `RUST_REGION_GRAPH_NODE=<node-id>` to select which file to output to and which AST node to print.
2014-12-17 11:50:29 -08:00
Alex Crichton
56fb9bc7ac rollup merge of #19889: FlaPer87/unboxed-closure
The fix just checks if the bound is `Copy` and returns an `Err` if so.

Closes: #19817

@nikomatsakis r?
2014-12-17 11:50:29 -08:00
Alex Crichton
1a05f956f8 rollup merge of #19887: alexcrichton/serialize-fn-mut
Relax some of the bounds on the decoder methods back to FnMut to help accomodate
some more flavorful variants of decoders which may need to run the closure more
than once when it, for example, attempts to find the first successful enum to
decode.
2014-12-17 11:50:28 -08:00
Alex Crichton
31e21613ee rollup merge of #19885: alexcrichton/char-escape
This changes the `escape_unicode` method on a `char` to use the new style of
unicode escapes in the language.

Closes #19811
Closes #19879
2014-12-17 11:50:28 -08:00
Alex Crichton
3315a3bf42 rollup merge of #19881: larroy/master
Now they trigger warnings.
2014-12-17 11:50:28 -08:00
Alex Crichton
c4c892d467 rollup merge of #19880: sanxiyn/assoc-resolve-lifetime
Fix #18790.
Fix #19862.
2014-12-17 11:50:28 -08:00
Alex Crichton
cd07efd264 rollup merge of #19873: drewm1980/master
In US english, "that" is used in restrictive clauses in place of
"which", and often affects the meaning of sentences.

In UK english and many dialects, no distinction is
made.

While Rust devs want to avoid unproductive pedanticism, it is worth at
least being uniform in documentation such as:

http://doc.rust-lang.org/std/iter/index.html

and also in cases where correct usage of US english clarifies the
sentence.
2014-12-17 11:50:28 -08:00
Alex Crichton
272f20394c rollup merge of #19871: pczarn/ring_buf-remove
Includes a fix for a small mistake in `fn insert` which is caught by test_insert for len=15, but not len=7.

Part of #18424

r? @Gankro @csherratt @huonw
2014-12-17 11:50:27 -08:00
Alex Crichton
64faa74d08 rollup merge of #19869: sfackler/free-stdin
r? @aturon
2014-12-17 11:50:27 -08:00
Alex Crichton
03e970f043 rollup merge of #19868: sourcefrog/master
The rendered form in http://doc.rust-lang.org/nightly/std/rand/struct.OsRng.html looks wrong.
2014-12-17 11:50:27 -08:00
Alex Crichton
67237a7917 rollup merge of #19860: japaric/copy-markers
Necessary to implement `Copy` on structs like this one:

``` rust
struct Slice<'a, T> {
    _contravariant: marker::ContravariantLifetime<'a>,
    _nosend: marker::NoSend,
    data: *const T,
    length: uint,
}
```

r? @alexcrichton
2014-12-17 11:50:27 -08:00
Alex Crichton
de0570de21 rollup merge of #19859: alexcrichton/flaky-test
This test would read with a timeout and then send a UDP message, expecting the
message to be received. The receiving port, however, was bound in the child
thread so it could be the case that the timeout and send happens before the
child thread runs. To remedy this we just bind the port before the child thread
runs, moving it into the child later on.

cc #19120
2014-12-17 11:50:27 -08:00
Alex Crichton
75a84f9a3e rollup merge of #19857: japaric/test-19129
Closes #19129
2014-12-17 11:50:27 -08:00
Alex Crichton
991bd049c9 rollup merge of #19856: iKevinY/faq-fixes
- Change long inline code to code block
- Replace double-hyphens with en dash
- Miscellaneous rephrasings for clarity

**Edit**: Trivial `commit --amend` to change the commit message slightly.
2014-12-17 11:50:26 -08:00
Alex Crichton
137a3dbffd rollup merge of #19849: alexcrichton/second-pass-option
This commit takes a second pass through the `std::option` module to fully
stabilize any lingering methods inside of it.

These items were made stable as-is

* Some
* None
* as_mut
* expect
* unwrap
* unwrap_or
* unwrap_or_else
* map
* map_or
* map_or_else
* and_then
* or_else
* unwrap_or_default
* Default implementation
* FromIterator implementation
* Copy implementation

These items were made stable with modifications

* iter - now returns a struct called Iter
* iter_mut - now returns a struct called IterMut
* into_iter - now returns a struct called IntoIter, Clone is never implemented

This is a breaking change due to the modifications to the names of the iterator
types returned. Code referencing the old names should updated to referencing the
newer names instead. This is also a breaking change due to the fact that
`IntoIter` no longer implements the `Clone` trait.

These items were explicitly not stabilized

* as_slice - waiting on indexing conventions
* as_mut_slice - waiting on conventions with as_slice as well
* cloned - the API was still just recently added
* ok_or - API remains experimental
* ok_or_else - API remains experimental

[breaking-change]
2014-12-17 11:50:26 -08:00
Alex Crichton
dea69e66b8 rollup merge of #19846: nicholasbishop/bishops_magical_intuition 2014-12-17 11:50:26 -08:00
Alex Crichton
f7cb5b6c20 rollup merge of #19845: jbranchaud/fix-indentation-in-ownership-guide
For reference, this is what the code example looks like before the change:

![screen shot 2014-12-14 at 12 12 58 pm](https://cloud.githubusercontent.com/assets/694063/5428475/ade24176-838a-11e4-870b-c7d4f55bc8d7.png)
2014-12-17 11:50:26 -08:00
Alex Crichton
924cd5a6d6 rollup merge of #19838: shepmaster/invariant-lifetime-copy
Both ContravariantLifetime and CovariantLifetime are marked as Copy,
so it makes sense for InvariantLifetime to be as well.
2014-12-17 11:50:26 -08:00
Alex Crichton
dbd68c70cd rollup merge of #19832: japaric/no-nocopy
r? @aturon / @alexcrichton
2014-12-17 11:50:25 -08:00
Alex Crichton
bdb1146181 rollup merge of #19831: luqmana/deriving-where
Fixes #19358.
2014-12-17 11:50:25 -08:00
Alex Crichton
823cd7a8d5 rollup merge of #19830: mchaput/patch-1
Error message has wrong spelling ("radix is to high").
2014-12-17 11:50:25 -08:00
Alex Crichton
f9ff55e4d0 rollup merge of #19827: japaric/clone-uc
closes #12677 (cc @Valloric)
cc #15294

r? @aturon / @alexcrichton

(Because of #19358 I had to move the struct bounds from the `where` clause into the parameter list)
2014-12-17 11:50:25 -08:00
Alex Crichton
b5302217f0 rollup merge of #19821: bkoropoff/issue-19791
Normalize late-bound regions in bare functions, stack closures, and traits and include them in the generated hash.

Closes #19791

r? @nikomatsakis (does my normalization make sense?)
cc @alexcrichton
2014-12-17 11:50:25 -08:00
Alex Crichton
be0c8fb507 rollup merge of #19820: alexcrichton/deprecate-some-more-libs
This commit deprecates a few more in-tree libs for their crates.io counterparts.
Note that this commit does not make use of the #[deprecated] tag to prevent
warnings from being generated for in-tree usage. Once #[unstable] warnings are
turned on then all external users will be warned to move.

These crates have all been duplicated in rust-lang/$crate repositories so
development can happen independently of the in-tree copies. We can explore at a
later date replacing the in-tree copies with the external copies, but at this
time the libraries have changed very little over the past few months so it's
unlikely for changes to be sent to both repos.

cc #19260
2014-12-17 11:50:24 -08:00
Alex Crichton
5294ceb312 rollup merge of #19818: emk/regex_at_name_opt
Hello! This is my first Rust patch, and I fear that I've probably skipped at least 7 critical steps. I'd appreciate your feedback and advice about how to contribute to Rust.

This patch is based on a discussion with @BurntSushi in #14602 a while back. I'm happy to revise it as needed to fit into the modern world. :-)

As discussed in that issue, the existing `at` and `name` functions represent two different results with the empty string:

1. Matched the empty string.
2. Did not match anything.

Consider the following example.  This regex has two named matched groups, `key` and `value`. `value` is optional:

```rust
// Matches "foo", "foo;v=bar" and "foo;v=".
regex!(r"(?P<key>[a-z]+)(;v=(?P<value>[a-z]*))?");
```

We can access `value` using `caps.name("value")`, but there's no way for us to distinguish between the `"foo"` and `"foo;v="` cases.

Early this year, @BurntSushi recommended modifying the existing `at` and `name` functions to return `Option`, instead of adding new functions to the API.

This is a [breaking-change], but the fix is easy:

- `refs.at(1)` becomes `refs.at(1).unwrap_or("")`.
- `refs.name(name)` becomes `refs.name(name).unwrap_or("")`.
2014-12-17 11:50:24 -08:00
Alex Crichton
974e17b9ea rollup merge of #19770: csouth3/iterator-wrapperstructs
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code.

This PR changes the iterators of `BTreeMap`, `BTreeSet`, `HashMap`, and `HashSet` to use proper new types, rather than type aliases.  However, since it is fair-game to treat a type-alias as the aliased type, this is a:

[breaking-change].
2014-12-17 11:50:24 -08:00