Skip to content

Commit 945d110

Browse files
committed
Auto merge of rust-lang#72036 - Dylan-DPC:rollup-ca8b0ql, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - rust-lang#70834 (Add core::future::{pending,ready}) - rust-lang#71839 (Make BTreeMap::new and BTreeSet::new const) - rust-lang#71890 (Simplify the error Registry methods a little) - rust-lang#71942 (Shrink `LocalDecl`) - rust-lang#71947 (Dead-code pass highlights too much of impl functions) - rust-lang#71981 (Fix `strip-priv-imports` pass name in the rustdoc documentation) - rust-lang#72018 (Fix canonicalization links) - rust-lang#72031 (Better documentation for io::Read::read() return value) Failed merges: r? @ghost
2 parents 0f9088f + 4b337d2 commit 945d110

File tree

45 files changed

+414
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+414
-289
lines changed

src/doc/rustdoc/src/passes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ By default, rustdoc will run some passes, namely:
1717
* `collapse-docs`
1818
* `unindent-comments`
1919

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

2323
## `strip-hidden`

src/liballoc/collections/btree/map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
556556
/// map.insert(1, "a");
557557
/// ```
558558
#[stable(feature = "rust1", since = "1.0.0")]
559-
pub fn new() -> BTreeMap<K, V> {
559+
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
560+
pub const fn new() -> BTreeMap<K, V> {
560561
BTreeMap { root: None, length: 0 }
561562
}
562563

src/liballoc/collections/btree/set.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ impl<T: Ord> BTreeSet<T> {
309309
/// let mut set: BTreeSet<i32> = BTreeSet::new();
310310
/// ```
311311
#[stable(feature = "rust1", since = "1.0.0")]
312-
pub fn new() -> BTreeSet<T> {
312+
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
313+
pub const fn new() -> BTreeSet<T> {
313314
BTreeSet { map: BTreeMap::new() }
314315
}
315316

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#![feature(cfg_sanitize)]
8383
#![feature(cfg_target_has_atomic)]
8484
#![feature(coerce_unsized)]
85+
#![feature(const_btree_new)]
8586
#![feature(const_generic_impls_guard)]
8687
#![feature(const_generics)]
8788
#![feature(const_in_array_repeat_expressions)]

src/libcore/future/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ use crate::{
1010
};
1111

1212
mod future;
13+
mod pending;
14+
mod ready;
15+
1316
#[stable(feature = "futures_api", since = "1.36.0")]
1417
pub use self::future::Future;
1518

19+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
20+
pub use pending::{pending, Pending};
21+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
22+
pub use ready::{ready, Ready};
23+
1624
/// This type is needed because:
1725
///
1826
/// a) Generators cannot implement `for<'a, 'b> Generator<&'a mut Context<'b>>`, so we need to pass

src/libcore/future/pending.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use crate::future::Future;
2+
use crate::marker;
3+
use crate::pin::Pin;
4+
use crate::task::{Context, Poll};
5+
6+
/// Creates a future which never resolves, representing a computation that never
7+
/// finishes.
8+
///
9+
/// This `struct` is created by the [`pending`] function. See its
10+
/// documentation for more.
11+
///
12+
/// [`pending`]: fn.pending.html
13+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
14+
#[derive(Debug)]
15+
#[must_use = "futures do nothing unless you `.await` or poll them"]
16+
pub struct Pending<T> {
17+
_data: marker::PhantomData<T>,
18+
}
19+
20+
/// Creates a future which never resolves, representing a computation that never
21+
/// finishes.
22+
///
23+
/// # Examples
24+
///
25+
/// ```no_run
26+
/// #![feature(future_readiness_fns)]
27+
/// use core::future;
28+
///
29+
/// # async fn run() {
30+
/// let future = future::pending();
31+
/// let () = future.await;
32+
/// unreachable!();
33+
/// # }
34+
/// ```
35+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
36+
pub fn pending<T>() -> Pending<T> {
37+
Pending { _data: marker::PhantomData }
38+
}
39+
40+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
41+
impl<T> Future for Pending<T> {
42+
type Output = T;
43+
44+
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<T> {
45+
Poll::Pending
46+
}
47+
}
48+
49+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
50+
impl<T> Unpin for Pending<T> {}
51+
52+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
53+
impl<T> Clone for Pending<T> {
54+
fn clone(&self) -> Self {
55+
pending()
56+
}
57+
}

src/libcore/future/ready.rs

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use crate::future::Future;
2+
use crate::pin::Pin;
3+
use crate::task::{Context, Poll};
4+
5+
/// Creates a future that is immediately ready with a value.
6+
///
7+
/// This `struct` is created by the [`ready`] function. See its
8+
/// documentation for more.
9+
///
10+
/// [`ready`]: fn.ready.html
11+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
12+
#[derive(Debug, Clone)]
13+
#[must_use = "futures do nothing unless you `.await` or poll them"]
14+
pub struct Ready<T>(Option<T>);
15+
16+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
17+
impl<T> Unpin for Ready<T> {}
18+
19+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
20+
impl<T> Future for Ready<T> {
21+
type Output = T;
22+
23+
#[inline]
24+
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
25+
Poll::Ready(self.0.take().expect("Ready polled after completion"))
26+
}
27+
}
28+
29+
/// Creates a future that is immediately ready with a value.
30+
///
31+
/// # Examples
32+
///
33+
/// ```
34+
/// #![feature(future_readiness_fns)]
35+
/// use core::future;
36+
///
37+
/// # async fn run() {
38+
/// let a = future::ready(1);
39+
/// assert_eq!(a.await, 1);
40+
/// # }
41+
/// ```
42+
#[unstable(feature = "future_readiness_fns", issue = "70921")]
43+
pub fn ready<T>(t: T) -> Ready<T> {
44+
Ready(Some(t))
45+
}

src/librustc_errors/registry.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub struct Registry {
1010

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

1616
/// This will panic if an invalid error code is passed in
1717
pub fn find_description(&self, code: &str) -> Option<&'static str> {
18-
self.try_find_description(code).unwrap()
18+
self.long_descriptions[code]
1919
}
2020
/// Returns `InvalidErrorCode` if the code requested does not exist in the
2121
/// registry. Otherwise, returns an `Option` where `None` means the error
@@ -24,9 +24,6 @@ impl Registry {
2424
&self,
2525
code: &str,
2626
) -> Result<Option<&'static str>, InvalidErrorCode> {
27-
if !self.long_descriptions.contains_key(code) {
28-
return Err(InvalidErrorCode);
29-
}
30-
Ok(*self.long_descriptions.get(code).unwrap())
27+
self.long_descriptions.get(code).copied().ok_or(InvalidErrorCode)
3128
}
3229
}

src/librustc_infer/infer/canonical/canonicalizer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! For an overview of what canonicalization is and how it fits into
44
//! rustc, check out the [chapter in the rustc dev guide][c].
55
//!
6-
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
6+
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
77
88
use crate::infer::canonical::{
99
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, Canonicalized,
@@ -35,7 +35,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
3535
/// To get a good understanding of what is happening here, check
3636
/// out the [chapter in the rustc dev guide][c].
3737
///
38-
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#canonicalizing-the-query
38+
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query
3939
pub fn canonicalize_query<V>(
4040
&self,
4141
value: &V,
@@ -79,7 +79,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
7979
/// To get a good understanding of what is happening here, check
8080
/// out the [chapter in the rustc dev guide][c].
8181
///
82-
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#canonicalizing-the-query-result
82+
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query-result
8383
pub fn canonicalize_response<V>(&self, value: &V) -> Canonicalized<'tcx, V>
8484
where
8585
V: TypeFoldable<'tcx>,

src/librustc_infer/infer/canonical/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! For a more detailed look at what is happening here, check
2020
//! out the [chapter in the rustc dev guide][c].
2121
//!
22-
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
22+
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
2323
2424
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
2525
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVariableOriginKind};

src/librustc_infer/infer/canonical/query_response.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! For an overview of what canonicaliation is and how it fits into
66
//! rustc, check out the [chapter in the rustc dev guide][c].
77
//!
8-
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
8+
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
99
1010
use crate::infer::canonical::substitute::{substitute_value, CanonicalExt};
1111
use crate::infer::canonical::{
@@ -154,7 +154,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
154154
/// To get a good understanding of what is happening here, check
155155
/// out the [chapter in the rustc dev guide][c].
156156
///
157-
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#processing-the-canonicalized-query-result
157+
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#processing-the-canonicalized-query-result
158158
pub fn instantiate_query_response_and_region_obligations<R>(
159159
&self,
160160
cause: &ObligationCause<'tcx>,

src/librustc_infer/infer/canonical/substitute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! For an overview of what canonicalization is and how it fits into
55
//! rustc, check out the [chapter in the rustc dev guide][c].
66
//!
7-
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
7+
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
88
99
use crate::infer::canonical::{Canonical, CanonicalVarValues};
1010
use rustc_middle::ty::fold::TypeFoldable;

src/librustc_middle/infer/canonical.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! For a more detailed look at what is happening here, check
2020
//! out the [chapter in the rustc dev guide][c].
2121
//!
22-
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
22+
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
2323
2424
use crate::infer::MemberConstraint;
2525
use crate::ty::subst::GenericArg;

0 commit comments

Comments
 (0)