Skip to content
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

Rollup of 8 pull requests #72036

Merged
merged 21 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
aab3457
Make BTreeMap::new and BTreeSet::new const
May 3, 2020
1a439d2
Simplify the error Registry methods a little
cuviper May 4, 2020
707cfd1
Fix the numbering of the tests
LG3696 May 5, 2020
a17234c
Add `SourceInfo::outermost`.
nnethercote May 6, 2020
afd8a4e
Improve `LocalDecl` creation.
nnethercote May 6, 2020
cda1627
Add a size assertion for `LocalDecl`.
nnethercote May 5, 2020
27ae2f0
Shrink `LocalDecl` by 56 bytes.
nnethercote May 6, 2020
001496c
Shrink `LocalDecl` by 16 bytes.
nnethercote May 6, 2020
b6d5d1f
Dead-code pass highlights too much of impl functions
mibac138 May 6, 2020
029515d
Add core::future::{pending,ready}
yoshuawuyts Apr 6, 2020
0bf2699
Fix `strip-priv-imports` pass name in the rustdoc documentation
stanislav-tkach May 7, 2020
9dabea1
fix canonicalization links
mark-i-m May 8, 2020
05fc7fa
Better documentation for io::Read::read() return value
Elinvynia May 8, 2020
62374ee
Rollup merge of #70834 - yoshuawuyts:future-pending-ready, r=sfackler
Dylan-DPC May 9, 2020
f16c27f
Rollup merge of #71839 - LG3696:master, r=cramertj
Dylan-DPC May 9, 2020
d16d02b
Rollup merge of #71890 - cuviper:simple-error-Registry, r=cramertj
Dylan-DPC May 9, 2020
2b3a114
Rollup merge of #71942 - nnethercote:shrink-LocalDecl, r=matthewjasper
Dylan-DPC May 9, 2020
966589e
Rollup merge of #71947 - mibac138:dead-code, r=cramertj
Dylan-DPC May 9, 2020
b86b626
Rollup merge of #71981 - DarkEld3r:patch-1, r=ollie27
Dylan-DPC May 9, 2020
46d97c2
Rollup merge of #72018 - mark-i-m:canon-chalk, r=mark-i-m
Dylan-DPC May 9, 2020
4b337d2
Rollup merge of #72031 - Elinvynia:master, r=Mark-Simulacrum
Dylan-DPC May 9, 2020
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/rustdoc/src/passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ By default, rustdoc will run some passes, namely:
* `collapse-docs`
* `unindent-comments`

However, `strip-private` implies `strip-private-imports`, and so effectively,
However, `strip-private` implies `strip-priv-imports`, and so effectively,
all passes are run by default.

## `strip-hidden`
Expand Down
3 changes: 2 additions & 1 deletion src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// map.insert(1, "a");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new() -> BTreeMap<K, V> {
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
pub const fn new() -> BTreeMap<K, V> {
BTreeMap { root: None, length: 0 }
}

Expand Down
3 changes: 2 additions & 1 deletion src/liballoc/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ impl<T: Ord> BTreeSet<T> {
/// let mut set: BTreeSet<i32> = BTreeSet::new();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new() -> BTreeSet<T> {
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
pub const fn new() -> BTreeSet<T> {
BTreeSet { map: BTreeMap::new() }
}

Expand Down
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
#![feature(coerce_unsized)]
#![feature(const_btree_new)]
#![feature(const_generic_impls_guard)]
#![feature(const_generics)]
#![feature(const_in_array_repeat_expressions)]
Expand Down
8 changes: 8 additions & 0 deletions src/libcore/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ use crate::{
};

mod future;
mod pending;
mod ready;

#[stable(feature = "futures_api", since = "1.36.0")]
pub use self::future::Future;

#[unstable(feature = "future_readiness_fns", issue = "70921")]
pub use pending::{pending, Pending};
#[unstable(feature = "future_readiness_fns", issue = "70921")]
pub use ready::{ready, Ready};

/// This type is needed because:
///
/// a) Generators cannot implement `for<'a, 'b> Generator<&'a mut Context<'b>>`, so we need to pass
Expand Down
57 changes: 57 additions & 0 deletions src/libcore/future/pending.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use crate::future::Future;
use crate::marker;
use crate::pin::Pin;
use crate::task::{Context, Poll};

/// Creates a future which never resolves, representing a computation that never
/// finishes.
///
/// This `struct` is created by the [`pending`] function. See its
/// documentation for more.
///
/// [`pending`]: fn.pending.html
#[unstable(feature = "future_readiness_fns", issue = "70921")]
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Pending<T> {
_data: marker::PhantomData<T>,
}

/// Creates a future which never resolves, representing a computation that never
/// finishes.
///
/// # Examples
///
/// ```no_run
/// #![feature(future_readiness_fns)]
/// use core::future;
///
/// # async fn run() {
/// let future = future::pending();
/// let () = future.await;
/// unreachable!();
/// # }
/// ```
#[unstable(feature = "future_readiness_fns", issue = "70921")]
pub fn pending<T>() -> Pending<T> {
Pending { _data: marker::PhantomData }
}

#[unstable(feature = "future_readiness_fns", issue = "70921")]
impl<T> Future for Pending<T> {
type Output = T;

fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<T> {
Poll::Pending
}
}

#[unstable(feature = "future_readiness_fns", issue = "70921")]
impl<T> Unpin for Pending<T> {}

#[unstable(feature = "future_readiness_fns", issue = "70921")]
impl<T> Clone for Pending<T> {
fn clone(&self) -> Self {
pending()
}
}
45 changes: 45 additions & 0 deletions src/libcore/future/ready.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use crate::future::Future;
use crate::pin::Pin;
use crate::task::{Context, Poll};

/// Creates a future that is immediately ready with a value.
///
/// This `struct` is created by the [`ready`] function. See its
/// documentation for more.
///
/// [`ready`]: fn.ready.html
#[unstable(feature = "future_readiness_fns", issue = "70921")]
#[derive(Debug, Clone)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Ready<T>(Option<T>);

#[unstable(feature = "future_readiness_fns", issue = "70921")]
impl<T> Unpin for Ready<T> {}

#[unstable(feature = "future_readiness_fns", issue = "70921")]
impl<T> Future for Ready<T> {
type Output = T;

#[inline]
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
Poll::Ready(self.0.take().expect("Ready polled after completion"))
}
}

/// Creates a future that is immediately ready with a value.
///
/// # Examples
///
/// ```
/// #![feature(future_readiness_fns)]
/// use core::future;
///
/// # async fn run() {
/// let a = future::ready(1);
/// assert_eq!(a.await, 1);
/// # }
/// ```
#[unstable(feature = "future_readiness_fns", issue = "70921")]
pub fn ready<T>(t: T) -> Ready<T> {
Ready(Some(t))
}
9 changes: 3 additions & 6 deletions src/librustc_errors/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ pub struct Registry {

impl Registry {
pub fn new(long_descriptions: &[(&'static str, Option<&'static str>)]) -> Registry {
Registry { long_descriptions: long_descriptions.iter().cloned().collect() }
Registry { long_descriptions: long_descriptions.iter().copied().collect() }
}

/// This will panic if an invalid error code is passed in
pub fn find_description(&self, code: &str) -> Option<&'static str> {
self.try_find_description(code).unwrap()
self.long_descriptions[code]
}
/// Returns `InvalidErrorCode` if the code requested does not exist in the
/// registry. Otherwise, returns an `Option` where `None` means the error
Expand All @@ -24,9 +24,6 @@ impl Registry {
&self,
code: &str,
) -> Result<Option<&'static str>, InvalidErrorCode> {
if !self.long_descriptions.contains_key(code) {
return Err(InvalidErrorCode);
}
Ok(*self.long_descriptions.get(code).unwrap())
self.long_descriptions.get(code).copied().ok_or(InvalidErrorCode)
}
}
6 changes: 3 additions & 3 deletions src/librustc_infer/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! For an overview of what canonicalization is and how it fits into
//! rustc, check out the [chapter in the rustc dev guide][c].
//!
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html

use crate::infer::canonical::{
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, Canonicalized,
Expand Down Expand Up @@ -35,7 +35,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// To get a good understanding of what is happening here, check
/// out the [chapter in the rustc dev guide][c].
///
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#canonicalizing-the-query
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query
pub fn canonicalize_query<V>(
&self,
value: &V,
Expand Down Expand Up @@ -79,7 +79,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// To get a good understanding of what is happening here, check
/// out the [chapter in the rustc dev guide][c].
///
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#canonicalizing-the-query-result
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query-result
pub fn canonicalize_response<V>(&self, value: &V) -> Canonicalized<'tcx, V>
where
V: TypeFoldable<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! For a more detailed look at what is happening here, check
//! out the [chapter in the rustc dev guide][c].
//!
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html

use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVariableOriginKind};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_infer/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! For an overview of what canonicaliation is and how it fits into
//! rustc, check out the [chapter in the rustc dev guide][c].
//!
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html

use crate::infer::canonical::substitute::{substitute_value, CanonicalExt};
use crate::infer::canonical::{
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// To get a good understanding of what is happening here, check
/// out the [chapter in the rustc dev guide][c].
///
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#processing-the-canonicalized-query-result
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#processing-the-canonicalized-query-result
pub fn instantiate_query_response_and_region_obligations<R>(
&self,
cause: &ObligationCause<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/canonical/substitute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! For an overview of what canonicalization is and how it fits into
//! rustc, check out the [chapter in the rustc dev guide][c].
//!
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html

use crate::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::ty::fold::TypeFoldable;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/infer/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! For a more detailed look at what is happening here, check
//! out the [chapter in the rustc dev guide][c].
//!
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html

use crate::infer::MemberConstraint;
use crate::ty::subst::GenericArg;
Expand Down
Loading