Commit Graph

55307 Commits

Author SHA1 Message Date
Guillaume Gomez
16699635bc Add DirEntry doc examples 2016-07-24 16:52:28 +02:00
Guillaume Gomez
dad29a6d03 Add missing links 2016-07-24 16:07:06 +02: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
Vadim Chugunov
6cef93d400 Implement ARM personality routine in Rust.
Remove the `eh_personality_catch` lang item.
Use a simplified version of `cfg_if!` in libunwind.
2016-07-24 01:53:27 -07:00
Alan Somers
1afb17ed5f Fix build of compiler-rt on FreeBSD
Broken since ee6011fc71 removed cmake from the
process.  There are likely other platforms still broken, but I didn't test on
them.
2016-07-24 04:48:26 +00:00
Robert Williamson
ccc955c84c Fix HashMap's values_mut example to use println! 2016-07-23 16:13:25 -06:00
Jeffrey Seyfried
41745f30f7 macros: Improve tt fragments 2016-07-23 12:49:01 -07:00
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
abhi
6ebe6e8f80 Update underscore usage (#34903) 2016-07-23 13:15:09 +05:30
Guillaume Gomez
90bb8d469c Add DirBuilder doc examples 2016-07-23 01:57:21 +02:00
Alex Crichton
8487666241 std: Ignore tests where threads outlive main
Long ago we discovered that threads which outlive main and then exit while the
rest of the program is exiting causes Windows to hang (#20704). That's what was
happening in this test so let's just not run this test any more.
2016-07-22 16:29:36 -07:00
Tobias Bucher
0685900fbd Fix run-pass/ifmt test 2016-07-23 00:18:44 +02:00
Tobias Bucher
34f766e341 Fix indentation in src/libcore/lib.rs 2016-07-23 00:18:44 +02:00
Tobias Bucher
e7d16580f5 Escape fewer Unicode codepoints in Debug impl of str
Use the same procedure as Python to determine whether a character is
printable, described in [PEP 3138]. In particular, this means that the
following character classes are escaped:

- Cc (Other, Control)
- Cf (Other, Format)
- Cs (Other, Surrogate), even though they can't appear in Rust strings
- Co (Other, Private Use)
- Cn (Other, Not Assigned)
- Zl (Separator, Line)
- Zp (Separator, Paragraph)
- Zs (Separator, Space), except for the ASCII space `' '` (`0x20`)

This allows for user-friendly inspection of strings that are not
English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`).

Fixes #34318.

[PEP 3138]: https://www.python.org/dev/peps/pep-3138/
2016-07-23 00:18:44 +02: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
Ariel Ben-Yehuda
717e39294f address review comments
I split the RFC1592 commit out
2016-07-23 00:03:19 +03:00
Niko Matsakis
8ffc04b032 Avoid writing a temporary closure kind
We used to write a temporary closure kind into the inference table, but
this could lead to obligations being incorrectled resolved before
inference had completed. This result could then be cached, leading to
further trouble. This patch avoids writing any closure kind until the
computation is complete.

Fixes #34349.
2016-07-22 16:57:08 -04:00
Jeffrey Seyfried
64d36ccf96 Add regression test. 2016-07-22 13:31:26 -07:00
ggomez
23bb1df1e5 Add E0559 error explanation 2016-07-22 22:47:38 +03:00
ggomez
0304850942 Add E0560 error explanation 2016-07-22 22:47:38 +03:00
ggomez
e76a46a10d Add new error codes in librustc_typeck 2016-07-22 22:47:38 +03:00
Ariel Ben-Yehuda
93a96835b0 use diagnostic-mutating style for note_type_err too
that is much cleaner than the `type_err!` style I used earlier.
2016-07-22 22:47:38 +03:00
Ariel Ben-Yehuda
1e4f6d5683 rustc_errors: fix a few bugs 2016-07-22 22:47:38 +03: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
ggomez
ec33dab062 Add HashMap Entry enums examples 2016-07-22 14:46:21 +02:00
abhi
0d192c3499 Update VecDeque documentation to specify direction of index 0 (#34920) 2016-07-22 17:50:54 +05:30
Ariel Ben-Yehuda
f3ee99bd4d try to recover the non-matching types in projection errors
The type equation in projection takes place under a binder and a snapshot, which
we can't easily take types out of. Instead, when encountering a projection error,
try to re-do the projection and find the type error then.

This fails to produce a sane type error when the failure was a "leak_check" failure.
I can't think of a sane way to show *these*, so I just left them use the old crappy
representation, and added a test to make sure we don't break them.
2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
712c5cadbb remove the now-unused multiline error code 2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
37c569627c refactor constant evaluation error reporting
Refactor constant evaluation to use a single error reporting function
that reports a type-error-like message.

Also, unify all error codes with the "constant evaluation error" message
to just E0080, and similarly for a few other duplicate codes. The old
situation was a total mess, and now that we have *something* we can
further iterate on the UX.
2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
fa4eda8935 switch projection errors to use the new type error messages
Unfortunately, projection errors do not come with a nice set of
mismatched types. This is because the type equality check occurs
within a higher-ranked context. Therefore, only the type error
is reported. This is ugly but was always the situation.

I will introduce better errors for the lower-ranked case in
another commit.

Fixes the last known occurence of #31173
2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
b7b2db4da7 switch compare_method to new-style trait error reporting 2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
cea88ebb39 refactor type error reporting 2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
8eb12d91aa remove rustc_typeck::same_type_err 2016-07-22 14:32:56 +03:00
Ariel Ben-Yehuda
b2422ab806 remove never-called type-error reporting functions 2016-07-22 14:32:56 +03: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