Skip to content

Rollup of 8 pull requests #58446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d9a4b22
Update the future/task API
Matthias247 Jan 30, 2019
01a704c
Apply suggestions from code review
Centril Feb 3, 2019
9e6bc3c
Apply review suggestions and fix tests
Matthias247 Feb 3, 2019
f005e1c
Fix test
Matthias247 Feb 3, 2019
e1ec814
Apply more review suggestions
Matthias247 Feb 5, 2019
363e992
review suggestions
Matthias247 Feb 5, 2019
8e7ef03
Move ArcWake in common test file.
Matthias247 Feb 6, 2019
a1c4cf6
Change RawWaker constructor to const fn
Matthias247 Feb 7, 2019
9e934e2
Reweork incompatible match arms error
estebank Feb 7, 2019
7eb6a2a
Add test for type mismatch on first match arm
estebank Feb 8, 2019
802c897
review comments: (marginally) reduce memory consumtion
estebank Feb 8, 2019
7d6bfc5
Extract block to insert an intrinsic into its own function
gnzlbg Feb 8, 2019
1ef34a5
Remove rustdoc test which referenced unstable API
Matthias247 Feb 9, 2019
05b4e7c
Add way to hide suggestion snippet window from cli output
estebank Feb 8, 2019
6ea159e
Expose hidden snippet suggestions
estebank Feb 8, 2019
7cfba1c
Never inline HideCodeAlways suggestions
estebank Feb 8, 2019
235523c
Add way to completely hide suggestion from cli output
estebank Feb 9, 2019
87dd2e1
Use hidden suggestions for unused imports lint
estebank Feb 11, 2019
871338c
Merging master
Matthias247 Feb 13, 2019
e73f96a
make OpTy.op private, and ImmTy.imm public instead
RalfJung Feb 8, 2019
b376ae6
make bin_op and unary_op APIs consistently work on ImmTy
RalfJung Feb 8, 2019
1a5304a
fix whitespace
RalfJung Feb 8, 2019
22d5e6a
fix rebase fallout
RalfJung Feb 13, 2019
e7f8e63
Convert old doc links to current edition
tesuji Jan 23, 2019
285d4a7
suggestion-diagnostics: as_ref improve snippet
dlrobertson Feb 13, 2019
5d65e8c
Reduce the size of `hir::Expr`.
nnethercote Feb 7, 2019
93ecae6
Rollup merge of #57451 - dlrobertson:can_use_as_ref_nit, r=estebank
Centril Feb 14, 2019
aa896f3
Rollup merge of #57856 - lzutao:fix-old-first-edition, r=steveklabnik
Centril Feb 14, 2019
919cf42
Rollup merge of #57992 - Matthias247:waker4, r=cramertj
Centril Feb 14, 2019
b6ed206
Rollup merge of #58258 - nnethercote:shrink-hir-Expr, r=michaelwoerister
Centril Feb 14, 2019
4ad3cf2
Rollup merge of #58267 - estebank:match-arms, r=matthewjasper
Centril Feb 14, 2019
56e1916
Rollup merge of #58296 - estebank:hidden-suggestion, r=oli-obk
Centril Feb 14, 2019
fab0f9b
Rollup merge of #58301 - RalfJung:fat-ptr-eq, r=oli-obk
Centril Feb 14, 2019
a0767d6
Rollup merge of #58308 - gnzlbg:context_insert_intr, r=eddyb
Centril Feb 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/guide-error-handling.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Error Handling in Rust

This content has moved into
[the Rust Programming Language book](book/error-handling.html).
[the Rust Programming Language book](book/ch09-00-error-handling.html).
2 changes: 1 addition & 1 deletion src/doc/guide-ownership.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% The (old) Rust Ownership Guide

This content has moved into
[the Rust Programming Language book](book/ownership.html).
[the Rust Programming Language book](book/ch04-00-understanding-ownership.html).
2 changes: 1 addition & 1 deletion src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

This content has been removed, with no direct replacement. Rust only
has two built-in pointer types now,
[references](book/references-and-borrowing.html) and [raw
[references](book/ch04-02-references-and-borrowing.html) and [raw
pointers](book/raw-pointers.html). Older Rusts had many more pointer
types, they’re gone now.
2 changes: 1 addition & 1 deletion src/doc/guide-testing.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% The (old) Rust Testing Guide

This content has moved into
[the Rust Programming Language book](book/testing.html).
[the Rust Programming Language book](book/ch11-00-testing.html).
6 changes: 3 additions & 3 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use core::ops::{
CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Receiver, Generator, GeneratorState
};
use core::ptr::{self, NonNull, Unique};
use core::task::{LocalWaker, Poll};
use core::task::{Waker, Poll};

use crate::vec::Vec;
use crate::raw_vec::RawVec;
Expand Down Expand Up @@ -896,7 +896,7 @@ impl<G: ?Sized + Generator> Generator for Pin<Box<G>> {
impl<F: ?Sized + Future + Unpin> Future for Box<F> {
type Output = F::Output;

fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
F::poll(Pin::new(&mut *self), lw)
fn poll(mut self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
F::poll(Pin::new(&mut *self), waker)
}
}
4 changes: 0 additions & 4 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ mod macros;

pub mod alloc;

#[unstable(feature = "futures_api",
reason = "futures in libcore are unstable",
issue = "50547")]
pub mod task;
// Primitive types using the heaps above

// Need to conditionally define the mod from `boxed.rs` to avoid
Expand Down
130 changes: 0 additions & 130 deletions src/liballoc/task.rs

This file was deleted.

5 changes: 1 addition & 4 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ pub const fn identity<T>(x: T) -> T { x }
/// - Use `Borrow` when the goal is related to writing code that is agnostic to
/// the type of borrow and whether it is a reference or value
///
/// See [the book][book] for a more detailed comparison.
///
/// [book]: ../../book/first-edition/borrow-and-asref.html
/// [`Borrow`]: ../../std/borrow/trait.Borrow.html
///
/// **Note: this trait must not fail**. If the conversion can fail, use a
Expand Down Expand Up @@ -351,7 +348,7 @@ pub trait Into<T>: Sized {
/// [`String`]: ../../std/string/struct.String.html
/// [`Into<U>`]: trait.Into.html
/// [`from`]: trait.From.html#tymethod.from
/// [book]: ../../book/first-edition/error-handling.html
/// [book]: ../../book/ch09-00-error-handling.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait From<T>: Sized {
/// Performs the conversion.
Expand Down
48 changes: 20 additions & 28 deletions src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use marker::Unpin;
use ops;
use pin::Pin;
use task::{Poll, LocalWaker};
use task::{Poll, Waker};

/// A future represents an asynchronous computation.
///
Expand All @@ -19,13 +19,14 @@ use task::{Poll, LocalWaker};
/// final value. This method does not block if the value is not ready. Instead,
/// the current task is scheduled to be woken up when it's possible to make
/// further progress by `poll`ing again. The wake up is performed using
/// `cx.waker()`, a handle for waking up the current task.
/// the `waker` argument of the `poll()` method, which is a handle for waking
/// up the current task.
///
/// When using a future, you generally won't call `poll` directly, but instead
/// `await!` the value.
#[must_use = "futures do nothing unless polled"]
pub trait Future {
/// The result of the `Future`.
/// The type of value produced on completion.
type Output;

/// Attempt to resolve the future to a final value, registering
Expand All @@ -42,16 +43,16 @@ pub trait Future {
/// Once a future has finished, clients should not `poll` it again.
///
/// When a future is not ready yet, `poll` returns `Poll::Pending` and
/// stores a clone of the [`LocalWaker`] to be woken once the future can
/// stores a clone of the [`Waker`] to be woken once the future can
/// make progress. For example, a future waiting for a socket to become
/// readable would call `.clone()` on the [`LocalWaker`] and store it.
/// readable would call `.clone()` on the [`Waker`] and store it.
/// When a signal arrives elsewhere indicating that the socket is readable,
/// `[LocalWaker::wake]` is called and the socket future's task is awoken.
/// `[Waker::wake]` is called and the socket future's task is awoken.
/// Once a task has been woken up, it should attempt to `poll` the future
/// again, which may or may not produce a final value.
///
/// Note that on multiple calls to `poll`, only the most recent
/// [`LocalWaker`] passed to `poll` should be scheduled to receive a
/// [`Waker`] passed to `poll` should be scheduled to receive a
/// wakeup.
///
/// # Runtime characteristics
Expand All @@ -67,44 +68,35 @@ pub trait Future {
/// typically do *not* suffer the same problems of "all wakeups must poll
/// all events"; they are more like `epoll(4)`.
///
/// An implementation of `poll` should strive to return quickly, and must
/// *never* block. Returning quickly prevents unnecessarily clogging up
/// An implementation of `poll` should strive to return quickly, and should
/// not block. Returning quickly prevents unnecessarily clogging up
/// threads or event loops. If it is known ahead of time that a call to
/// `poll` may end up taking awhile, the work should be offloaded to a
/// thread pool (or something similar) to ensure that `poll` can return
/// quickly.
///
/// # [`LocalWaker`], [`Waker`] and thread-safety
///
/// The `poll` function takes a [`LocalWaker`], an object which knows how to
/// awaken the current task. [`LocalWaker`] is not `Send` nor `Sync`, so in
/// order to make thread-safe futures the [`LocalWaker::into_waker`] method
/// should be used to convert the [`LocalWaker`] into a thread-safe version.
/// [`LocalWaker::wake`] implementations have the ability to be more
/// efficient, however, so when thread safety is not necessary,
/// [`LocalWaker`] should be preferred.
/// An implementation of `poll` may also never cause memory unsafety.
///
/// # Panics
///
/// Once a future has completed (returned `Ready` from `poll`),
/// then any future calls to `poll` may panic, block forever, or otherwise
/// cause bad behavior. The `Future` trait itself provides no guarantees
/// about the behavior of `poll` after a future has completed.
/// cause any kind of bad behavior expect causing memory unsafety.
/// The `Future` trait itself provides no guarantees about the behavior
/// of `poll` after a future has completed.
///
/// [`Poll::Pending`]: ../task/enum.Poll.html#variant.Pending
/// [`Poll::Ready(val)`]: ../task/enum.Poll.html#variant.Ready
/// [`LocalWaker`]: ../task/struct.LocalWaker.html
/// [`LocalWaker::into_waker`]: ../task/struct.LocalWaker.html#method.into_waker
/// [`LocalWaker::wake`]: ../task/struct.LocalWaker.html#method.wake
/// [`Waker`]: ../task/struct.Waker.html
fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output>;
/// [`Waker::wake`]: ../task/struct.Waker.html#method.wake
fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output>;
}

impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F {
type Output = F::Output;

fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
F::poll(Pin::new(&mut **self), lw)
fn poll(mut self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
F::poll(Pin::new(&mut **self), waker)
}
}

Expand All @@ -115,7 +107,7 @@ where
{
type Output = <<P as ops::Deref>::Target as Future>::Output;

fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
Pin::get_mut(self).as_mut().poll(lw)
fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
Pin::get_mut(self).as_mut().poll(waker)
}
}
4 changes: 2 additions & 2 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<T: ?Sized> !Send for *mut T { }
/// // be made into an object
/// ```
///
/// [trait object]: ../../book/first-edition/trait-objects.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
#[stable(feature = "rust1", since = "1.0.0")]
#[lang = "sized"]
#[rustc_on_unimplemented(
Expand Down Expand Up @@ -518,7 +518,7 @@ macro_rules! impls{
/// types. We track the Rust type using a phantom type parameter on
/// the struct `ExternalResource` which wraps a handle.
///
/// [FFI]: ../../book/first-edition/ffi.html
/// [FFI]: ../../book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code
///
/// ```
/// # #![allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pub const fn size_of<T>() -> usize {
/// then `size_of_val` can be used to get the dynamically-known size.
///
/// [slice]: ../../std/primitive.slice.html
/// [trait object]: ../../book/first-edition/trait-objects.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
///
/// # Examples
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ mod poll;
pub use self::poll::Poll;

mod wake;
pub use self::wake::{Waker, LocalWaker, UnsafeWake};
pub use self::wake::{Waker, RawWaker, RawWakerVTable};
Loading