Commit Graph

55000 Commits

Author SHA1 Message Date
Knight
6ac83de691 Add test for string AddAssign 2016-07-28 06:08:56 +08:00
bors
9316ae515e Auto merge of #35006 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests

- Successful merges: #34965, #34972, #34975, #34976, #34977, #34988, #34989
- Failed merges:
2016-07-24 11:42:06 -07:00
Manish Goregaokar
52c293c2bb Rollup merge of #34989 - frewsxcv:fix-set-len-doc-example, r=nagisa
Fix incorrect 'memory leak' example for `Vec::set_len`.

Example was written in https://github.com/rust-lang/rust/pull/34911

Issue was brought up in this comment:

a005b2cd2a (commitcomment-18346958)
2016-07-24 15:18:48 +05:30
Manish Goregaokar
89b9ddd0dd Rollup merge of #34988 - frewsxcv:vec-windows, r=GuillaumeGomez
Doc example improvements for `slice::windows`.

* Modify existing example to not rely on printing to see results
* Add an example demonstrating when slice is shorter than `size`
2016-07-24 15:18:48 +05:30
Manish Goregaokar
f7df83d115 Rollup merge of #34977 - wettowelreactor:patch-3, r=steveklabnik
Fixed to spelling errors in char.rs

Fixed two small spelling mistakes (interator -> iterator) in the documentation for encode_utf8 and encode_utf16
2016-07-24 15:18:48 +05:30
Manish Goregaokar
10be6e6c9e Rollup merge of #34976 - GuillaumeGomez:build_hasher_doc, r=steveklabnik
Add BuildHasher example

r? @steveklabnik
2016-07-24 15:18:48 +05:30
Manish Goregaokar
33ad70521b Rollup merge of #34975 - GuillaumeGomez:random_state_doc, r=steveklabnik
Add Random state doc

Last part of #29348.

r? @steveklabnik
2016-07-24 15:18:47 +05:30
Manish Goregaokar
87cc1b9330 Rollup merge of #34972 - oli-obk:cant_cast_str_to_const_ptr, r=eddyb
improve const eval error reporting on "" and b"" casts

r? @eddyb

cc @ubsan
2016-07-24 15:18:47 +05:30
Manish Goregaokar
cc620d8819 Rollup merge of #34965 - jonathandturner:multispan_cleanup, r=sanxiyn
Remove unused methods from MultiSpan

Removed a couple of unused methods from MultiSpan.  I thought about batching this with some other changes but wasn't sure when I'd get around to them, so PR for a tiny fix instead.

This can be rollup'd.
2016-07-24 15:18:47 +05:30
bors
2c50f4e484 Auto merge of #34832 - vadimcn:rusty-personality, r=alexcrichton
Implement rust_eh_personality in Rust, remove rust_eh_personality_catch.

Well, not quite: ARM EHABI platforms still use the old scheme -- for now.

r? @alexcrichton
2016-07-23 09:35:34 -07:00
Corey Farwell
c77f8ce7c3 Doc example improvements for slice::windows.
* Modify existing example to not rely on printing to see results
* Add an example demonstrating when slice is shorter than `size`
2016-07-23 11:59:31 -04:00
Corey Farwell
1e0043eb6c Fix incorrect 'memory leak' example for Vec::set_len.
Example was written in https://github.com/rust-lang/rust/pull/34911

Issue was brought up in this comment:

a005b2cd2a (commitcomment-18346958)
2016-07-23 09:08:45 -04:00
bors
fd1d3603d4 Auto merge of #34925 - jseyfried:nested_macros, r=eddyb
Support nested `macro_rules!`

Fixes #6994.
r? @eddyb
2016-07-23 04:01:05 -07:00
Vadim Chugunov
051c2d14fb Implement rust_eh_personality in Rust, remove rust_eh_personality_catch.
Well, not quite: ARM EHABI platforms still use the old scheme -- for now.
2016-07-22 14:58:35 -07:00
bors
ad264f7f39 Auto merge of #34924 - cgswords:empty_delim, r=nrc
Added empty CloseDelim to tokens for future use.

Description says it all. I added a new DelimToken type, Empty, to indicate a Delimited tokenstream with no actual delimiters (which are variously useful for constructing macro output).

r? @nrc
2016-07-22 11:30:29 -07:00
Camille Roussel
f2f8bbc49f Fixed to spelling errors in char.rs
Fixed two small spelling mistakes (interator -> iterator) in the documentation for encode_utf8 and encode_utf16
2016-07-22 10:48:19 -04:00
ggomez
890706070d Add BuildHasher example 2016-07-22 16:38:16 +02:00
bors
af87681ed2 Auto merge of #34917 - michaelwoerister:fix-internalize-symbols, r=eddyb
Fix wrong condition in base::internalize_symbols().

Fix a typo that snuck into https://github.com/rust-lang/rust/pull/34899 (and completely broke `internalize_symbols()`).
2016-07-22 07:25:06 -07:00
ggomez
3c8fae369f Add Random state doc 2016-07-22 14:57:52 +02:00
bors
d15e2656e5 Auto merge of #34771 - murarth:string-insert-str, r=alexcrichton
Add method `String::insert_str`
2016-07-22 01:36:22 -07:00
Oliver Schneider
e8ac07941c
improve const eval error reporting on "" and b"" casts 2016-07-22 09:34:44 +02:00
bors
0d7597588d Auto merge of #34724 - mitchmindtree:mpsc_receiver_try_recv, r=alexcrichton
Add a method to the mpsc::Receiver for producing a non-blocking iterator

Currently, the `mpsc::Receiver` offers methods for receiving values in both blocking (`recv`) and non-blocking (`try_recv`) flavours. However only blocking iteration over values is supported. This PR adds a non-blocking iterator to complement the `try_recv` method, just as the blocking iterator complements the `recv` method.

Use-case
-------------

I predominantly use rust in my work on real-time systems and in particular real-time audio generation/processing. I use `mpsc::channel`s to communicate between threads in a purely non-blocking manner. I.e. I might send messages from the GUI thread to the audio thread to update the state of the dsp-graph, or from the audio thread to the GUI thread to display the RMS of each node. These are just a couple examples (I'm probably using 30+ channels across my various projects). I almost exclusively use the `mpsc::Receiver::try_recv` method to avoid blocking any of the real-time threads and causing unwanted glitching/stuttering. Now that I mention it, I can't think of a single time that I personally have used the `recv` method (though I can of course see why it would be useful, and perhaps the common case for many people).

As a result of this experience, I can't help but feel there is a large hole in the `Receiver` API.

| blocking | non-blocking |
|------------|--------------------|
| `recv` | `try_recv` |
| `iter` | 🙀   |

For the most part, I've been working around this using `while let Ok(v) = r.try_recv() { ... }`, however as nice as this is, it is clearly no match for the Iterator API.

As an example, in the majority of my channel use cases I only want to check for *n* number of messages before breaking from the loop so that I don't miss the audio IO callback or hog the GUI thread for too long when an unexpectedly large number of messages are sent. Currently, I have to write something like this:

```rust
let mut take = 100;
while let Ok(msg) = rx.try_recv() {
    // Do stuff with msg
    if take == 0 {
        break;
    }
    take -= 1;
}
```

or wrap the `try_recv` call in a `Range<usize>`/`FilterMap` iterator combo.

On the other hand, this PR would allow for the following:

```rust
for msg in rx.try_iter().take(100) {
    // Do stuff with msg
}
```

I imagine this might also be useful to game devs, embedded or anyone doing message passing across real-time threads.
2016-07-21 22:39:48 -07:00
bors
d46ed83e2e Auto merge of #34715 - scottcarr:mir-test, r=nikomatsakis
Add MIR Optimization Tests

I've starting working on the infrastructure for testing MIR optimizations.

The plan now is to have a set of test cases (written in Rust), compile them with -Z dump-mir, and check the MIR before and after each pass.
2016-07-21 19:44:59 -07:00
bors
62690b3c3f Auto merge of #34544 - 3Hren:issue/xx/reinterpret-format-precision-for-strings, r=alexcrichton
feat: reinterpret `precision` field for strings

This commit changes the behavior of formatting string arguments with both width and precision fields set.

Documentation says that the `width` field is the "minimum width" that the format should take up. If the value's string does not fill up this many characters, then the padding specified by fill/alignment will be used to take up the required space.

This is true for all formatted types except string, which is truncated down to `precision` number of chars and then all of `fill`, `align` and `width` fields are completely ignored.

For example: `format!("{:/^10.8}", "1234567890);` emits "12345678". In the contrast Python version works as the expected:
```python
>>> '{:/^10.8}'.format('1234567890')
'/12345678/'
```

This commit gives back the `Python` behavior by changing the `precision` field meaning to the truncation and nothing more. The result string *will* be prepended/appended up to the `width` field with the proper `fill` char.

__However, this is the breaking change, I admit.__ Feel free to close it, but otherwise it should be mentioned in the `std::fmt` documentation somewhere near of `fill/align/width` fields description.
2016-07-21 16:19:54 -07:00
Jonathan Turner
f7019a4e2f Remove unused methods from MultiSpan 2016-07-21 12:38:15 -07:00
bors
7588653785 Auto merge of #34939 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests

- Successful merges: #34854, #34855, #34880, #34895, #34911, #34921, #34930
- Failed merges: #33951, #34850
2016-07-21 04:05:34 -07:00
mitchmindtree
05af033b7f Fix issue in receiver_try_iter test where response sender would panic instead of break from the loop 2016-07-21 19:32:24 +10:00
Guillaume Gomez
22a14a8389 Rollup merge of #34937 - GuillaumeGomez:hash_map_entry_debug, r=apasel422
Add debug for hash_map::{Entry, VacantEntry, OccupiedEntry}

r? @alexcrichton
2016-07-21 11:27:01 +02:00
Guillaume Gomez
1006f794cd Rollup merge of #34930 - frewsxcv:vec-as-slice, r=steveklabnik
Add doc examples for `Vec::{as_slice,as_mut_slice}`.

None
2016-07-21 11:27:01 +02:00
Guillaume Gomez
3f3dabb008 Rollup merge of #34921 - GuillaumeGomez:css_fix, r=steveklabnik
[CSS] Fix unwanted top margin for toggle wrapper

Fixes top margin.

Before:

![before](https://cloud.githubusercontent.com/assets/3050060/16950833/72b2b956-4dc2-11e6-9d27-24507871b5a8.png)

After (check "A view into a single entry in map" toggle wrapper more precisely):

![after](https://cloud.githubusercontent.com/assets/3050060/16950839/7835c6fc-4dc2-11e6-901a-ae8c4191baca.png)

r? @steveklabnik
2016-07-21 11:27:01 +02:00
Guillaume Gomez
d62f8dde76 Rollup merge of #34919 - GuillaumeGomez:btree_map_doc, r=steveklabnik
Add doc for btree_map types

Part of #29348.

r? @steveklabnik
2016-07-21 11:27:01 +02:00
Guillaume Gomez
27876c0a1c Rollup merge of #34911 - frewsxcv:vec-set-len, r=steveklabnik
Rewrite/expand doc examples for `Vec::set_len`.

None
2016-07-21 11:27:00 +02:00
Guillaume Gomez
91fd8380db Rollup merge of #34910 - alexcrichton:hard-float-mips, r=brson
rustc: Remove soft-float from MIPS targets

Right now two MIPS targets in the compiler, `mips-unknown-linux-{gnu,musl}` both
generate object files using the soft-float ABI through LLVM by default. This is
also expressed as the `-C soft-float` codegen option and otherwise isn't used
for any other target in the compiler. This option was added quite some time ago
(back in #9617), and nowadays it's more appropriate to be done through a codegen
option.

This is motivated by #34743 which necessitated an upgrade in the CMake
installation on our bots which necessitated an upgrade in the Ubuntu version
which invalidated the MIPS compilers we were using. The new MIPS compilers
(coming from Debian I believe) all have hard float enabled by default and soft
float support not built in. This meant that we couldn't upgrade the bots
until #34841 landed because otherwise we would fail to compile C code as the
`-msoft-float` option wouldn't work.

Unfortunately, though, this means that once we upgrade the bots the C code we're
compiling will be compiled for hard float and the Rust code will be compiled
for soft float, a bad mismatch! This PR remedies the situation such that Rust
will compile with hard float as well.

If this lands it will likely produce broken nightlies for a day or two while we
get around to upgrading the bots because the current C toolchain only produces
soft-float binaries, and now rust will be hard-float. Hopefully, though, the
upgrade can go smoothly!
2016-07-21 11:27:00 +02:00
Guillaume Gomez
271230f347 Rollup merge of #34895 - mark-buer:patch-1, r=steveklabnik
Remove rustdoc reference to `walk_dir`
2016-07-21 11:27:00 +02:00
Guillaume Gomez
4817c5e53d Rollup merge of #34890 - oconnor663:addassign, r=brson
implement AddAssign for String

Currently `String` implements `Add` but not `AddAssign`. This PR fills in that gap.

I played around with having `AddAssign` (and `Add` and `push_str`) take `AsRef<str>` instead of `&str`, but it looks like that breaks arguments that implement `Deref<Target=str>` and not `AsRef<str>`. Comments in [`libcore/convert.rs`](https://github.com/rust-lang/rust/blob/master/src/libcore/convert.rs#L207-L213) make it sound like we could fix this with a blanket impl eventually. Does anyone know what's blocking that?
2016-07-21 11:27:00 +02:00
Guillaume Gomez
9ba1792aac Rollup merge of #34880 - xitep:master, r=steveklabnik
Make .enumerate() example self-explanatory

Should resolve #34624
2016-07-21 11:27:00 +02:00
Guillaume Gomez
705d92d42d Rollup merge of #34855 - GuillaumeGomez:vec_deque_doc, r=steveklabnik
Add examples for VecDeque

Part of #29348.

r? @steveklabnik
2016-07-21 11:26:59 +02:00
Guillaume Gomez
a168e30bb1 Rollup merge of #34854 - GuillaumeGomez:linked_list_doc, r=steveklabnik
Add examples for LinkedList

Part of #29348.

r? @steveklabnik
2016-07-21 11:26:58 +02:00
Guillaume Gomez
bcbe27cbf9 Rollup merge of #34828 - seanmonstar:into-opton, r=alexcrichton
core: impl From<T> for Option<T>

First, the semantics of this `impl` seem spot on. If I have a value `T`, and I wish to make a `Option<T>`, then `Option::from(val)` should always give `Some(val)`.

Second, this allows improvement for several APIs that currently take `Option<T>` as arguments. Consider:

```rust
fn set_read_timeout(&mut self, timeout: Option<u32>) {
    // ...
}

x.set_read_timeout(Some(30));
x.set_read_timeout(Some(10));
x.set_read_timeout(None);
```

With this `impl`:

```rust
fn set_read_timeout<T: Into<Option<u32>>>(&mut self, timeout: T) {
    let timeout = timeout.into();
    // ...
}

x.set_read_timeout(30);
x.set_read_timeout(10);
x.set_read_timeout(Some(10)); // backwards compatible
x.set_read_timeout(None);
```

The change to those methods aren't included, but could be modified later.

r? @sfackler
2016-07-21 11:26:57 +02:00
Scott A Carr
8f9844dd5c add mir optimization tests, dump-mir-dir option 2016-07-20 19:41:39 -07:00
bors
e7c822cee2 Auto merge of #34873 - alexcrichton:down-with-compiler-rt-for-good, r=brson
mk: Stop using cmake for compiler-rt

The compiler-rt build system has been a never ending cause of pain for Rust
unfortunately:

* The build system is very difficult to invoke and configure to only build
  compiler-rt, especially across platforms.
* The standard build system doesn't actually do what we want, not working for
  some of our platforms and requiring a significant number of patches on our end
  which are difficult to apply when updating compiler-rt.
* Compiling compiler-rt requires LLVM to be compiled, which... is a big
  dependency! This also means that over time compiler-rt is not guaranteed to
  build against older versions of LLVM (or newer versions), and we often want to
  work with multiple versions of LLVM simultaneously.

The makefiles and rustbuild already know how to compile C code, the code here is
far from the *only* C code we're compiling. This patch jettisons all logic to
work with compiler-rt's build system and just goes straight to the source. We
just list all files manually (copied from compiler-rt's
lib/builtins/CMakeLists.txt) and compile them into an archive.

It's likely that this means we'll fail to pick up new files when we upgrade
compiler-rt, but that seems like a much less significant cost to pay than what
we're currently paying.

cc #34400, first steps towards that
2016-07-20 19:02:00 -07:00
Sean McArthur
fbfee42a2f core: impl From<T> for Option<T> 2016-07-20 15:54:54 -07:00
Alex Crichton
ee6011fc71 mk: Stop using cmake for compiler-rt
The compiler-rt build system has been a never ending cause of pain for Rust
unfortunately:

* The build system is very difficult to invoke and configure to only build
  compiler-rt, especially across platforms.
* The standard build system doesn't actually do what we want, not working for
  some of our platforms and requiring a significant number of patches on our end
  which are difficult to apply when updating compiler-rt.
* Compiling compiler-rt requires LLVM to be compiled, which... is a big
  dependency! This also means that over time compiler-rt is not guaranteed to
  build against older versions of LLVM (or newer versions), and we often want to
  work with multiple versions of LLVM simultaneously.

The makefiles and rustbuild already know how to compile C code, the code here is
far from the *only* C code we're compiling. This patch jettisons all logic to
work with compiler-rt's build system and just goes straight to the source. We
just list all files manually (copied from compiler-rt's
lib/builtins/CMakeLists.txt) and compile them into an archive.

It's likely that this means we'll fail to pick up new files when we upgrade
compiler-rt, but that seems like a much less significant cost to pay than what
we're currently paying.

cc #34400, first steps towards that
2016-07-20 13:22:20 -07:00
bors
936bfea94b Auto merge of #34113 - srinivasreddy:deriving_rustfmt, r=brson
run rustfmt on libsyntax_ext/deriving folder
2016-07-20 11:24:12 -07:00
Michael Woerister
ecc12953db trans: Make base::internalize_symbols() respect explicit linkage directives. 2016-07-20 10:26:25 -04:00
bors
9d5965a5e8 Auto merge of #34694 - mathphreak:master, r=alexcrichton
Add IpAddr common methods

Per https://github.com/rust-lang/rfcs/pull/1668#issuecomment-230867962 no RFC is needed here.

The generated documentation for these methods is being weird. It shows a deprecation message referencing #27709 for each of them even though two of the referenced methods were stabilized as part of that issue. I don't know how best to address that.
2016-07-20 07:10:09 -07:00
ggomez
9b5db220c8 Add doc for btree_map types 2016-07-20 14:06:25 +02:00
bors
a63e3fac8f Auto merge of #33526 - steveklabnik:gh21889, r=alexcrichton
Add some warnings to std::env::current_exe

/cc #21889 @rust-lang/libs @semarie

I started writing this up. I'm not sure if we want to go into other things and in what depth; we don't currently have a lot of security-specific documentation to model after.

Thoughts?
2016-07-20 00:48:21 -07:00
mitchmindtree
aed2e5c1e5 Add the missing tracking issue field for #34931 to the receiver_try_iter stability attributes 2016-07-20 14:49:40 +10:00
Corey Farwell
00e3149ded Add doc examples for Vec::{as_slice,as_mut_slice}. 2016-07-19 21:34:45 -04:00