Commit Graph

156 Commits

Author SHA1 Message Date
Mazdak Farrokhzad 379c380a60 libstd: deny(elided_lifetimes_in_paths) 2019-03-31 12:56:51 +02:00
Jethro Beekman f229422cc1 SGX target: fix std unit tests 2019-03-25 11:31:19 -07:00
Taiki Endo 93b6d9e086 libstd => 2018 2019-02-28 04:06:15 +09:00
bors b244f61b77 Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnik
Cosmetic improvements to doc comments

This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase).

r? @steveklabnik

Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-12 19:09:24 +00:00
Oliver Scherer a83e73dce4 Move out tests of a deprecated module to work around #[test] bugs
https://github.com/rust-lang/rust/issues/47238
2019-02-11 15:08:17 +01:00
Alexander Regueiro b87363e763 tests: doc comments 2019-02-10 23:42:32 +00:00
bors 96530344ef Auto merge of #56827 - faern:eliminate-recv-timeout-panic, r=KodrAus
Eliminate Receiver::recv_timeout panic

Fixes #54552.

This panic is because `recv_timeout` uses `Instant::now() + timeout` internally. This possible panic is not mentioned in the documentation for this method.

Very recently we merged (still unstable) support for checked addition (#56490) of `Instant + Duration`, so it's now finally possible to add these together without risking a panic.
2019-01-02 02:03:15 +00:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Linus Färnstrand 018f8a027d Use checked_add for adding time in recv_timeout 2018-12-14 21:43:52 +01:00
Stjepan Glavina d75dae3069 Deprecate channel selection 2018-11-08 22:51:46 +01:00
teresy eca11b99a7 refactor: use shorthand fields 2018-11-06 15:05:44 -05:00
Felix Rabe 025f41f4c0 "Panics" -> "Known Issues"; rm trailing WS 2018-08-07 17:34:34 +02:00
Felix Rabe 6e2051cd08 Less words better than moar words 2018-08-07 16:39:09 +02:00
Felix Rabe c574720d88 Rephrase 2018-08-07 16:38:02 +02:00
Felix Rabe b1f47aa838 Document panic in mpsc::Receiver::recv_timeout 2018-08-07 16:35:03 +02:00
Felix Rabe c3fdd19e43 Document #39364 (WIP) 2018-08-01 09:42:46 +02:00
Tatsuyuki Ishi 4f1d4e4db6 Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and 'ljedrz/dyn_libterm' into dyn-rollup 2018-07-25 10:25:02 +09:00
Matt Kraai e488cba678 Uncapitalize "If" 2018-07-11 17:19:41 -07:00
ljedrz 560d8079ec Deny bare trait objects in src/libstd. 2018-07-10 20:35:36 +02:00
kennytm 30f1853649 Rollup merge of #46323 - ia0:fix_mpsc_error_conv, r=kennytm
Fix since for mpsc_error_conversions

This is a followup of #45506.
2017-11-29 18:37:51 +08:00
kennytm 0ec3aee569 Rollup merge of #45969 - ia0:mpsc_recv_deadline, r=alexcrichton
Add std::sync::mpsc::Receiver::recv_deadline()

Essentially renames recv_max_until to recv_deadline (mostly copying recv_timeout
documentation). This function is useful to avoid the often unnecessary call to
Instant::now in recv_timeout (e.g. when the user already has a deadline). A
concrete example would be something along those lines:

```rust
use std::sync::mpsc::Receiver;
use std::time::{Duration, Instant};

/// Reads a batch of elements
///
/// Returns as soon as `max_size` elements have been received or `timeout` expires.
fn recv_batch_timeout<T>(receiver: &Receiver<T>, timeout: Duration, max_size: usize) -> Vec<T> {
    recv_batch_deadline(receiver, Instant::now() + timeout, max_size)
}

/// Reads a batch of elements
///
/// Returns as soon as `max_size` elements have been received or `deadline` is reached.
fn recv_batch_deadline<T>(receiver: &Receiver<T>, deadline: Instant, max_size: usize) -> Vec<T> {
    let mut result = Vec::new();
    while let Ok(x) = receiver.recv_deadline(deadline) {
        result.push(x);
        if result.len() == max_size {
            break;
        }
    }
    result
}
```
2017-11-29 18:37:43 +08:00
Julien Cretin 8e025d8009 Fix doc test of previous commit 2017-11-28 21:22:30 +01:00
Julien Cretin 43323b3194 Fix since for mpsc_error_conversions 2017-11-28 15:58:36 +01:00
Julien Cretin 8424cacff8 Use an unstable feature linked to #46316 2017-11-27 22:31:00 +01:00
Julien Cretin 428c875ac3 Add std::sync::mpsc::Receiver::recv_deadline()
Essentially renames recv_max_until to recv_deadline (mostly copying recv_timeout
documentation). This function is useful to avoid the often unnecessary call to
Instant::now in recv_timeout (e.g. when the user already has a deadline). A
concrete example would be something along those lines:

```rust
use std::sync::mpsc::Receiver;
use std::time::{Duration, Instant};

/// Reads a batch of elements
///
/// Returns as soon as `max_size` elements have been received or `timeout` expires.
fn recv_batch_timeout<T>(receiver: &Receiver<T>, timeout: Duration, max_size: usize) -> Vec<T> {
    recv_batch_deadline(receiver, Instant::now() + timeout, max_size)
}

/// Reads a batch of elements
///
/// Returns as soon as `max_size` elements have been received or `deadline` is reached.
fn recv_batch_deadline<T>(receiver: &Receiver<T>, deadline: Instant, max_size: usize) -> Vec<T> {
    let mut result = Vec::new();
    while let Ok(x) = receiver.recv_deadline(deadline) {
        result.push(x);
        if result.len() == max_size {
            break;
        }
    }
    result
}
```
2017-11-13 22:50:22 +01:00
Julien Cretin 448215d226 Implement From<SendError<T>> for TrySendError<T> 2017-10-31 00:18:53 +01:00
Julien Cretin 73ed6cf7fb Implement From<RecvError> for TryRecvError and RecvTimeoutError 2017-10-25 00:06:28 +02:00
bors a47c9f870f Auto merge of #44963 - JLockerman:fix_spsc, r=alexcrichton
Improve performance of spsc_queue and stream.

This PR makes two main changes:

1. It switches the `spsc_queue` node caching strategy from keeping a shared
counter of the number of nodes in the cache to keeping a consumer only counter
of the number of node eligible to be cached.
2. It separates the consumer and producers fields of `spsc_queue` and `stream` into
a producer cache line and consumer cache line.

Overall, it speeds up `mpsc` in `spsc` mode by 2-10x.
Variance is higher than I'd like (that 2-10x speedup is on one benchmark), I believe this is due to the drop check in `send` (`fn stream::Queue::send:107`). I think this check can be combined with the sleep detection code into a version which only uses 1 shared variable, and only one atomic access per `send`, but I haven't looked through the select implementation enough to be sure.

The code currently assumes a cache line size of 64 bytes. I added a CacheAligned newtype in `mpsc` which I expect to reuse for `shared`. It doesn't really belong there, it would probably be best put in `core::sync::atomic`, but putting it in `core` would involve making it public, which I thought would require an RFC.

Benchmark runner is [here](https://github.com/JLockerman/queues/tree/3eca46279c53eb75833c5ecd416de2ac220bd022/shootout), benchmarks [here](https://github.com/JLockerman/queues/blob/3eca46279c53eb75833c5ecd416de2ac220bd022/queue_bench/src/lib.rs#L170-L293).

Fixes #44512.
2017-10-11 19:32:19 +00:00
Malo Jaffré 679457ad2a Refactor to use debug_struct in several Debug impls
Fixes #44771.
2017-10-09 20:09:08 +02:00
Joshua Lockerman 68341a91ee Improve performance of spsc_queue and stream.
This commit makes two main changes.
1. It switches the spsc_queue node caching strategy from keeping a shared
counter of the number of nodes in the cache to keeping a consumer only counter
of the number of node eligible to be cached.
2. It separate the consumer and producers fields of spsc_queue and stream into
a producer cache line and consumer cache line.
2017-10-01 12:15:35 -04:00
Corey Farwell 292fcc880f Rollup merge of #42397 - sfackler:syncsender-sync, r=alexcrichton
Implement Sync for SyncSender

r? @alexcrichton
2017-06-21 10:40:14 -04:00
Steven Fackler 0f6c01ddb6 Implement Sync for SyncSender 2017-06-02 21:09:09 -07:00
Corey Farwell eb48ee72db Rewrite Receiver::try_iter doc example to show resulting values. 2017-06-02 00:21:32 -04:00
Corey Farwell d3f3e26db0 Rewrite Receiver::iter doc example to show resulting values. 2017-06-02 00:21:27 -04:00
bors 4ed2edaafe Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakis
Decompose Adjustment into smaller steps and remove the method map.

The method map held method callee information for:
* actual method calls (`x.f(...)`)
* overloaded unary, binary, indexing and call operators
* *every overloaded deref adjustment* (many can exist for each expression)

That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with:
* a desire to compose adjustments more freely
* containing the autoderef logic better to avoid mutation within an inference snapshot
* not creating `TyFnDef` types which are incompatible with the original one
  * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs`
* to fix #3548 by explicitly writing autorefs for the RHS of comparison operators

Individual commits tell their own story, of "atomic" changes avoiding breaking semantics.

Future work based on this PR could include:
* removing the signature from `TyFnDef`, now that it's always "canonical"
  * some questions of variance remain, as subtyping *still* treats the signature differently
* moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits`
* allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments
* transitive coercions (e.g. reify or unsize after multiple steps of autoderef)

r? @nikomatsakis
2017-06-01 11:34:13 +00:00
Eduard-Mihai Burtescu 58632f3c1c tests: fix fallout from empowering unused_allocation in comparisons. 2017-06-01 08:59:47 +03:00
Corey Farwell bcd1fe56c7 Rewrite doc examples for Receiver::recv_timeout. 2017-05-31 23:01:55 -04:00
bors 272e77f035 Auto merge of #42111 - ollie27:stab, r=Mark-Simulacrum
Correct some stability versions

These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
2017-05-20 15:42:43 +00:00
Oliver Middleton 2f703e4304 Correct some stability versions
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
2017-05-20 08:38:39 +01:00
Denis Andrejew f4e33a011e fix typo in libstd/sync/mpsc/mod.rs docs 2017-05-18 08:45:18 +02:00
projektir c59b188aae Adding links and examples for various mspc pages #29377 2017-04-26 23:11:57 -04:00
Guillaume Gomez d79b511f5c Fix invalid linkage 2017-04-22 13:25:14 +02:00
projektir 28a232a59a Adding links around Sender/SyncSender/Receiver errors; Adding more documentation to channel() and sync_channel(); adding more links #29377 2017-04-08 15:33:21 -04:00
Bryan Tan ab4f4428e7 Fix styling issues 2017-04-03 16:09:19 -07:00
Bryan Tan dab8e8121f Fix warnings in examples 2017-03-31 23:22:59 -07:00
Bryan Tan ae8ba78e9d Fix broken links to std::iter::Iterator::next 2017-03-31 18:51:37 -07:00
Bryan Tan 89c35ae764 Add links and examples to std::sync::mpsc docs (#29377)
This change adds links to to `Receiver`, `Iter`, `TryIter`, `IntoIter`,
`Sender`, `SyncSender`, `SendError`, `RecvError`, `TryRecvError`,
`RecvTimeoutError`, `TrySendError`, `Sender::send`, `SyncSender::send`,
`SyncSender::try_send`, `Receiver::recv`, `Receiver::recv_timeout`,
`Receiver::iter`, and `Receiver::try_iter`.

Examples added to `Receiver`, `Sender`, `Receiver::iter`.
2017-03-31 17:07:01 -07:00
Bryan Tan 5a6ebdfcda Add links to std::sync::mpsc docs #29377 2017-03-30 23:28:15 -07:00
Corey Farwell e7b0f2badf Remove function invokation parens from documentation links.
This was never established as a convention we should follow in the 'More
API Documentation Conventions' RFC:

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13 21:43:18 -04:00
Alex Crichton 68dd6fd964 Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichton
Implement `fmt::Debug` for all structures in libstd.

Part of https://github.com/rust-lang/rust/issues/31869.

Also turn on the `missing_debug_implementations` lint at the crate
level.
2016-12-20 11:16:17 -08:00