diff --git a/.mailmap b/.mailmap index a2e3c581eabba..3e512377d0377 100644 --- a/.mailmap +++ b/.mailmap @@ -54,9 +54,10 @@ Chris C Cerami Chris C Cerami Chris Thorn Chris Thorn Chris Vittal Christopher Vittal -Christian Poveda -Christian Poveda -Christian Poveda +Christian Poveda +Christian Poveda +Christian Poveda +Christian Poveda Clark Gaebel Clinton Ryan Corey Richardson Elaine "See More" Nemo @@ -154,6 +155,7 @@ Lindsey Kuper Luke Metz Luqman Aden Luqman Aden +Manish Goregaokar Marcell Pardavi Margaret Meyerhofer Mark Rousskov @@ -185,6 +187,7 @@ Neil Pankey Nick Platt Nicole Mazzuca Nif Ward +Nika Layzell Oliver Middleton Oliver Scherer Oliver Scherer @@ -204,7 +207,6 @@ Paul Faria Paul Faria Peer Aramillo Irizar parir Peter Elmers Peter Liniker -Peter Zotov Phil Dawes Phil Dawes Philipp Brüschweiler Philipp Brüschweiler @@ -255,6 +257,7 @@ Ulrik Sverdrup Ulrik Sverdrup Vadim Petrochenkov Vadim Petrochenkov petrochenkov Vitali Haravy Vitali Haravy +whitequark William Ting Xuefeng Wu Xuefeng Wu Xuefeng Wu XuefengWu diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fbbd7c4a2e49..fc8ca5d07b212 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -367,7 +367,7 @@ labels to triage issues: to fix the issue. * The dark blue **final-comment-period** label marks bugs that are using the - RFC signoff functionality of [rfcbot][rfcbot] and are currently in the final + RFC signoff functionality of [rfcbot] and are currently in the final comment period. * Red, **I**-prefixed labels indicate the **importance** of the issue. The @@ -385,7 +385,7 @@ labels to triage issues: label. * The gray **proposed-final-comment-period** label marks bugs that are using - the RFC signoff functionality of [rfcbot][rfcbot] and are currently awaiting + the RFC signoff functionality of [rfcbot] and are currently awaiting signoff of all team members in order to enter the final comment period. * Pink, **regression**-prefixed labels track regressions from stable to the diff --git a/Cargo.lock b/Cargo.lock index f3fad1296bfd7..847a406985d76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1773,9 +1773,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" [[package]] name = "libc" -version = "0.2.64" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c" +checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" dependencies = [ "rustc-std-workspace-core", ] diff --git a/RELEASES.md b/RELEASES.md index 5afc6f9bdc0cb..e3597473f62fd 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4951,10 +4951,10 @@ Stabilized APIs --------------- * [`std::panic`] -* [`std::panic::catch_unwind`][] (renamed from `recover`) -* [`std::panic::resume_unwind`][] (renamed from `propagate`) -* [`std::panic::AssertUnwindSafe`][] (renamed from `AssertRecoverSafe`) -* [`std::panic::UnwindSafe`][] (renamed from `RecoverSafe`) +* [`std::panic::catch_unwind`] (renamed from `recover`) +* [`std::panic::resume_unwind`] (renamed from `propagate`) +* [`std::panic::AssertUnwindSafe`] (renamed from `AssertRecoverSafe`) +* [`std::panic::UnwindSafe`] (renamed from `RecoverSafe`) * [`str::is_char_boundary`] * [`<*const T>::as_ref`] * [`<*mut T>::as_ref`] @@ -5234,18 +5234,18 @@ Libraries --------- * Stabilized APIs: - * [`str::encode_utf16`][] (renamed from `utf16_units`) - * [`str::EncodeUtf16`][] (renamed from `Utf16Units`) + * [`str::encode_utf16`] (renamed from `utf16_units`) + * [`str::EncodeUtf16`] (renamed from `Utf16Units`) * [`Ref::map`] * [`RefMut::map`] * [`ptr::drop_in_place`] * [`time::Instant`] * [`time::SystemTime`] * [`Instant::now`] - * [`Instant::duration_since`][] (renamed from `duration_from_earlier`) + * [`Instant::duration_since`] (renamed from `duration_from_earlier`) * [`Instant::elapsed`] * [`SystemTime::now`] - * [`SystemTime::duration_since`][] (renamed from `duration_from_earlier`) + * [`SystemTime::duration_since`] (renamed from `duration_from_earlier`) * [`SystemTime::elapsed`] * Various `Add`/`Sub` impls for `Time` and `SystemTime` * [`SystemTimeError`] @@ -5432,8 +5432,8 @@ Libraries * Stabilized APIs * `Path` - * [`Path::strip_prefix`][] (renamed from relative_from) - * [`path::StripPrefixError`][] (new error type returned from strip_prefix) + * [`Path::strip_prefix`] (renamed from relative_from) + * [`path::StripPrefixError`] (new error type returned from strip_prefix) * `Ipv4Addr` * [`Ipv4Addr::is_loopback`] * [`Ipv4Addr::is_private`] @@ -5646,7 +5646,7 @@ Libraries * Stabilized APIs: [`Read::read_exact`], - [`ErrorKind::UnexpectedEof`][] (renamed from `UnexpectedEOF`), + [`ErrorKind::UnexpectedEof`] (renamed from `UnexpectedEOF`), [`fs::DirBuilder`], [`fs::DirBuilder::new`], [`fs::DirBuilder::recursive`], [`fs::DirBuilder::create`], [`os::unix::fs::DirBuilderExt`], @@ -5659,11 +5659,11 @@ Libraries [`collections::hash_set::HashSet::drain`], [`collections::binary_heap::Drain`], [`collections::binary_heap::BinaryHeap::drain`], - [`Vec::extend_from_slice`][] (renamed from `push_all`), + [`Vec::extend_from_slice`] (renamed from `push_all`), [`Mutex::get_mut`], [`Mutex::into_inner`], [`RwLock::get_mut`], [`RwLock::into_inner`], - [`Iterator::min_by_key`][] (renamed from `min_by`), - [`Iterator::max_by_key`][] (renamed from `max_by`). + [`Iterator::min_by_key`] (renamed from `min_by`), + [`Iterator::max_by_key`] (renamed from `max_by`). * The [core library][1.6co] is stable, as are most of its APIs. * [The `assert_eq!` macro supports arguments that don't implement `Sized`][1.6ae], such as arrays. In this way it behaves more like diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index d4ad65e84b7b4..6f096e582f575 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -188,11 +188,7 @@ pub extern fn rust_begin_panic(info: &PanicInfo) -> ! { In many cases, you may need to manually link to the `compiler_builtins` crate when building a `no_std` binary. You may observe this via linker error messages -such as "```undefined reference to `__rust_probestack'```". Using this crate -also requires enabling the library feature `compiler_builtins_lib`. You can read -more about this [here][compiler-builtins-lib]. - -[compiler-builtins-lib]: ../library-features/compiler-builtins-lib.md +such as "```undefined reference to `__rust_probestack'```". ## More about the language items diff --git a/src/doc/unstable-book/src/library-features/compiler-builtins-lib.md b/src/doc/unstable-book/src/library-features/compiler-builtins-lib.md deleted file mode 100644 index 6c71c3f2ce191..0000000000000 --- a/src/doc/unstable-book/src/library-features/compiler-builtins-lib.md +++ /dev/null @@ -1,35 +0,0 @@ -# `compiler_builtins_lib` - -The tracking issue for this feature is: None. - ------------------------- - -This feature is required to link to the `compiler_builtins` crate which contains -"compiler intrinsics". Compiler intrinsics are software implementations of basic -operations like multiplication of `u64`s. These intrinsics are only required on -platforms where these operations don't directly map to a hardware instruction. - -You should never need to explicitly link to the `compiler_builtins` crate when -building "std" programs as `compiler_builtins` is already in the dependency -graph of `std`. But you may need it when building `no_std` **binary** crates. If -you get a *linker* error like: - -``` text -$PWD/src/main.rs:11: undefined reference to `__aeabi_lmul' -$PWD/src/main.rs:11: undefined reference to `__aeabi_uldivmod' -``` - -That means that you need to link to this crate. - -When you link to this crate, make sure it only appears once in your crate -dependency graph. Also, it doesn't matter where in the dependency graph you -place the `compiler_builtins` crate. - - - -``` rust,ignore -#![feature(compiler_builtins_lib)] -#![no_std] - -extern crate compiler_builtins; -``` diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 0148711bb8625..c527b378f7465 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -1094,7 +1094,7 @@ impl FusedIterator for Iter<'_, T> {} /// An owning iterator over the elements of a `BinaryHeap`. /// -/// This `struct` is created by the [`into_iter`] method on [`BinaryHeap`][`BinaryHeap`] +/// This `struct` is created by the [`into_iter`] method on [`BinaryHeap`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.BinaryHeap.html#method.into_iter diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 7d0a862d79e48..fa8aae04011ed 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -283,7 +283,7 @@ pub struct IterMut<'a, K: 'a, V: 'a> { /// An owning iterator over the entries of a `BTreeMap`. /// -/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`][`BTreeMap`] +/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.BTreeMap.html#method.into_iter diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 282d163141bc8..f5487426814a5 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -83,7 +83,7 @@ impl fmt::Debug for Iter<'_, T> { /// An owning iterator over the items of a `BTreeSet`. /// -/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`][`BTreeSet`] +/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`BTreeSet`]: struct.BTreeSet.html diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 4931093c55c99..29bf2fdb30cf7 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -105,7 +105,7 @@ impl fmt::Debug for IterMut<'_, T> { /// An owning iterator over the elements of a `LinkedList`. /// -/// This `struct` is created by the [`into_iter`] method on [`LinkedList`][`LinkedList`] +/// This `struct` is created by the [`into_iter`] method on [`LinkedList`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.LinkedList.html#method.into_iter diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 9d2eec94a0c02..2cc450bb68a20 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2474,7 +2474,7 @@ impl FusedIterator for IterMut<'_, T> {} /// An owning iterator over the elements of a `VecDeque`. /// -/// This `struct` is created by the [`into_iter`] method on [`VecDeque`][`VecDeque`] +/// This `struct` is created by the [`into_iter`] method on [`VecDeque`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.VecDeque.html#method.into_iter diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 01d4913665c07..e6162e0f571e2 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -330,7 +330,7 @@ //! //! Additionally, the return value of this function is [`fmt::Result`] which is a //! type alias of [`Result`]`<(), `[`std::fmt::Error`]`>`. Formatting implementations -//! should ensure that they propagate errors from the [`Formatter`][`Formatter`] (e.g., when +//! should ensure that they propagate errors from the [`Formatter`] (e.g., when //! calling [`write!`]). However, they should never return errors spuriously. That //! is, a formatting implementation must and may only return an error if the //! passed-in [`Formatter`] returns an error. This is because, contrary to what diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 2f6d10c027be3..7b83658fca60d 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -450,7 +450,8 @@ impl [T] { // and `rem` is the remaining part of `n`. // Using `Vec` to access `set_len()`. - let mut buf = Vec::with_capacity(self.len().checked_mul(n).expect("capacity overflow")); + let capacity = self.len().checked_mul(n).expect("capacity overflow"); + let mut buf = Vec::with_capacity(capacity); // `2^expn` repetition is done by doubling `buf` `expn`-times. buf.extend(self); @@ -476,7 +477,7 @@ impl [T] { // `rem` (`= n - 2^expn`) repetition is done by copying // first `rem` repetitions from `buf` itself. - let rem_len = self.len() * n - buf.len(); // `self.len() * rem` + let rem_len = capacity - buf.len(); // `self.len() * rem` if rem_len > 0 { // `buf.extend(buf[0 .. rem_len])`: unsafe { @@ -487,8 +488,7 @@ impl [T] { rem_len, ); // `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`). - let buf_cap = buf.capacity(); - buf.set_len(buf_cap); + buf.set_len(capacity); } } buf diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index dcd7dc49526b6..93a51ccb20737 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -242,7 +242,7 @@ use crate::raw_vec::RawVec; /// ensures no unnecessary allocations or deallocations occur. Emptying a `Vec` /// and then filling it back up to the same [`len`] should incur no calls to /// the allocator. If you wish to free up unused memory, use -/// [`shrink_to_fit`][`shrink_to_fit`]. +/// [`shrink_to_fit`]. /// /// [`push`] and [`insert`] will never (re)allocate if the reported capacity is /// sufficient. [`push`] and [`insert`] *will* (re)allocate if @@ -2461,7 +2461,7 @@ where /// An iterator that moves out of a vector. /// -/// This `struct` is created by the `into_iter` method on [`Vec`][`Vec`] (provided +/// This `struct` is created by the `into_iter` method on [`Vec`] (provided /// by the [`IntoIterator`] trait). /// /// [`Vec`]: struct.Vec.html diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs index f14ed38b9b0f2..dcb819f9381a4 100644 --- a/src/libcore/future/future.rs +++ b/src/libcore/future/future.rs @@ -99,6 +99,21 @@ pub trait Future { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll; } +/// Conversion into a `Future`. +#[unstable(feature = "into_future", issue = "67644")] +pub trait IntoFuture { + /// The output that the future will produce on completion. + #[unstable(feature = "into_future", issue = "67644")] + type Output; + /// Which kind of future are we turning this into? + #[unstable(feature = "into_future", issue = "67644")] + type Future: Future; + + /// Creates a future from a value. + #[unstable(feature = "into_future", issue = "67644")] + fn into_future(self) -> Self::Future; +} + #[stable(feature = "futures_api", since = "1.36.0")] impl Future for &mut F { type Output = F::Output; @@ -119,3 +134,13 @@ where Pin::get_mut(self).as_mut().poll(cx) } } + +#[unstable(feature = "into_future", issue = "67644")] +impl IntoFuture for F { + type Output = F::Output; + type Future = F; + + fn into_future(self) -> Self::Future { + self + } +} diff --git a/src/libcore/future/mod.rs b/src/libcore/future/mod.rs index 89ea4713cfdaa..aecd57b9ce71a 100644 --- a/src/libcore/future/mod.rs +++ b/src/libcore/future/mod.rs @@ -5,3 +5,6 @@ mod future; #[stable(feature = "futures_api", since = "1.36.0")] pub use self::future::Future; + +#[unstable(feature = "into_future", issue = "67644")] +pub use self::future::IntoFuture; diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 502090731f4a1..416c73f50bd89 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -697,7 +697,7 @@ extern "rust-intrinsic" { #[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")] pub fn min_align_of() -> usize; - #[rustc_const_unstable(feature = "const_pref_align_of", issue = "0")] + #[rustc_const_unstable(feature = "const_pref_align_of", issue = "none")] pub fn pref_align_of() -> usize; /// The size of the referenced value in bytes. @@ -708,13 +708,13 @@ extern "rust-intrinsic" { pub fn min_align_of_val(_: &T) -> usize; /// Gets a static string slice containing the name of a type. - #[rustc_const_unstable(feature = "const_type_name", issue = "0")] + #[rustc_const_unstable(feature = "const_type_name", issue = "none")] pub fn type_name() -> &'static str; /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever /// crate it is invoked in. - #[rustc_const_unstable(feature = "const_type_id", issue = "0")] + #[rustc_const_unstable(feature = "const_type_id", issue = "none")] pub fn type_id() -> u64; /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: @@ -1222,7 +1222,7 @@ extern "rust-intrinsic" { /// let num_leading = unsafe { ctlz_nonzero(x) }; /// assert_eq!(num_leading, 3); /// ``` - #[rustc_const_unstable(feature = "constctlz", issue = "0")] + #[rustc_const_unstable(feature = "constctlz", issue = "none")] pub fn ctlz_nonzero(x: T) -> T; /// Returns the number of trailing unset bits (zeroes) in an integer type `T`. @@ -1267,7 +1267,7 @@ extern "rust-intrinsic" { /// let num_trailing = unsafe { cttz_nonzero(x) }; /// assert_eq!(num_trailing, 3); /// ``` - #[rustc_const_unstable(feature = "const_cttz", issue = "0")] + #[rustc_const_unstable(feature = "const_cttz", issue = "none")] pub fn cttz_nonzero(x: T) -> T; /// Reverses the bytes in an integer type `T`. @@ -1396,7 +1396,7 @@ extern "rust-intrinsic" { pub fn nontemporal_store(ptr: *mut T, val: T); /// See documentation of `<*const T>::offset_from` for details. - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "0")] + #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "none")] pub fn ptr_offset_from(ptr: *const T, base: *const T) -> isize; /// Internal hook used by Miri to implement unwinding. diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs index e66d9c5bd2e7e..9a52823a45474 100644 --- a/src/libcore/macros/mod.rs +++ b/src/libcore/macros/mod.rs @@ -252,8 +252,6 @@ macro_rules! debug_assert_ne { /// # Examples /// /// ``` -/// #![feature(matches_macro)] -/// /// let foo = 'f'; /// assert!(matches!(foo, 'A'..='Z' | 'a'..='z')); /// @@ -261,7 +259,7 @@ macro_rules! debug_assert_ne { /// assert!(matches!(bar, Some(x) if x > 2)); /// ``` #[macro_export] -#[unstable(feature = "matches_macro", issue = "65721")] +#[stable(feature = "matches_macro", since = "1.42.0")] macro_rules! matches { ($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )?) => { match $expression { diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 978d622156413..3b98bc1c272f0 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -142,7 +142,7 @@ pub trait Unsize { /// In either of the two scenarios above, we reject usage of such a constant in /// a pattern match. /// -/// See also the [structural match RFC][RFC1445], and [issue 63438][] which +/// See also the [structural match RFC][RFC1445], and [issue 63438] which /// motivated migrating from attribute-based design to this trait. /// /// [RFC1445]: https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index fd7b7cf0b3490..f1f1bb13f0f24 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -226,7 +226,7 @@ impl f32 { } /// Returns `true` if the number is neither zero, infinite, - /// [subnormal][subnormal], or `NaN`. + /// [subnormal], or `NaN`. /// /// ``` /// use std::f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 540c6a529d7c8..5f9dc541b7d91 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -226,7 +226,7 @@ impl f64 { } /// Returns `true` if the number is neither zero, infinite, - /// [subnormal][subnormal], or `NaN`. + /// [subnormal], or `NaN`. /// /// ``` /// use std::f64; diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index 505a65cee3de0..04c7789fa4ff4 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -2,12 +2,12 @@ /// /// Instances of `Fn` can be called repeatedly without mutating state. /// -/// *This trait (`Fn`) is not to be confused with [function pointers][] +/// *This trait (`Fn`) is not to be confused with [function pointers] /// (`fn`).* /// /// `Fn` is implemented automatically by closures which only take immutable /// references to captured variables or don't capture anything at all, as well -/// as (safe) [function pointers][] (with some caveats, see their documentation +/// as (safe) [function pointers] (with some caveats, see their documentation /// for more details). Additionally, for any type `F` that implements `Fn`, `&F` /// implements `Fn`, too. /// @@ -78,7 +78,7 @@ pub trait Fn: FnMut { /// /// `FnMut` is implemented automatically by closures which take mutable /// references to captured variables, as well as all types that implement -/// [`Fn`], e.g., (safe) [function pointers][] (since `FnMut` is a supertrait of +/// [`Fn`], e.g., (safe) [function pointers] (since `FnMut` is a supertrait of /// [`Fn`]). Additionally, for any type `F` that implements `FnMut`, `&mut F` /// implements `FnMut`, too. /// @@ -162,7 +162,7 @@ pub trait FnMut: FnOnce { /// /// `FnOnce` is implemented automatically by closure that might consume captured /// variables, as well as all types that implement [`FnMut`], e.g., (safe) -/// [function pointers][] (since `FnOnce` is a supertrait of [`FnMut`]). +/// [function pointers] (since `FnOnce` is a supertrait of [`FnMut`]). /// /// Since both [`Fn`] and [`FnMut`] are subtraits of `FnOnce`, any instance of /// [`Fn`] or [`FnMut`] can be used where a `FnOnce` is expected. diff --git a/src/libcore/result.rs b/src/libcore/result.rs index ce4c8995a3c48..5628658c5bdf5 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1370,7 +1370,7 @@ unsafe impl TrustedLen for IterMut<'_, A> {} /// The iterator yields one value if the result is [`Ok`], otherwise none. /// /// This struct is created by the [`into_iter`] method on -/// [`Result`][`Result`] (provided by the [`IntoIterator`] trait). +/// [`Result`] (provided by the [`IntoIterator`] trait). /// /// [`Ok`]: enum.Result.html#variant.Ok /// [`Result`]: enum.Result.html diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 5ddf5d48965d5..9b4d201573238 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -34,7 +34,7 @@ use crate::mem; use crate::ops::{self, FnMut, Range}; use crate::option::Option; use crate::option::Option::{None, Some}; -use crate::ptr; +use crate::ptr::{self, NonNull}; use crate::result::Result; use crate::result::Result::{Err, Ok}; @@ -628,7 +628,7 @@ impl [T] { ptr.add(self.len()) }; - Iter { ptr, end, _marker: marker::PhantomData } + Iter { ptr: NonNull::new_unchecked(ptr as *mut T), end, _marker: marker::PhantomData } } } @@ -656,7 +656,7 @@ impl [T] { ptr.add(self.len()) }; - IterMut { ptr, end, _marker: marker::PhantomData } + IterMut { ptr: NonNull::new_unchecked(ptr), end, _marker: marker::PhantomData } } } @@ -3095,7 +3095,7 @@ macro_rules! is_empty { // The way we encode the length of a ZST iterator, this works both for ZST // and non-ZST. ($self: ident) => { - $self.ptr == $self.end + $self.ptr.as_ptr() as *const T == $self.end }; } // To get rid of some bounds checks (see `position`), we compute the length in a somewhat @@ -3105,17 +3105,17 @@ macro_rules! len { #![allow(unused_unsafe)] // we're sometimes used within an unsafe block let start = $self.ptr; - let size = size_from_ptr(start); + let size = size_from_ptr(start.as_ptr()); if size == 0 { // This _cannot_ use `unchecked_sub` because we depend on wrapping // to represent the length of long ZST slice iterators. - ($self.end as usize).wrapping_sub(start as usize) + ($self.end as usize).wrapping_sub(start.as_ptr() as usize) } else { // We know that `start <= end`, so can do better than `offset_from`, // which needs to deal in signed. By setting appropriate flags here // we can tell LLVM this, which helps it remove bounds checks. // SAFETY: By the type invariant, `start <= end` - let diff = unsafe { unchecked_sub($self.end as usize, start as usize) }; + let diff = unsafe { unchecked_sub($self.end as usize, start.as_ptr() as usize) }; // By also telling LLVM that the pointers are apart by an exact // multiple of the type size, it can optimize `len() == 0` down to // `start == end` instead of `(end - start) < size`. @@ -3161,7 +3161,7 @@ macro_rules! iterator { // Helper function for creating a slice from the iterator. #[inline(always)] fn make_slice(&self) -> &'a [T] { - unsafe { from_raw_parts(self.ptr, len!(self)) } + unsafe { from_raw_parts(self.ptr.as_ptr(), len!(self)) } } // Helper function for moving the start of the iterator forwards by `offset` elements, @@ -3171,10 +3171,10 @@ macro_rules! iterator { unsafe fn post_inc_start(&mut self, offset: isize) -> * $raw_mut T { if mem::size_of::() == 0 { zst_shrink!(self, offset); - self.ptr + self.ptr.as_ptr() } else { - let old = self.ptr; - self.ptr = self.ptr.offset(offset); + let old = self.ptr.as_ptr(); + self.ptr = NonNull::new_unchecked(self.ptr.as_ptr().offset(offset)); old } } @@ -3186,7 +3186,7 @@ macro_rules! iterator { unsafe fn pre_dec_end(&mut self, offset: isize) -> * $raw_mut T { if mem::size_of::() == 0 { zst_shrink!(self, offset); - self.ptr + self.ptr.as_ptr() } else { self.end = self.end.offset(-offset); self.end @@ -3215,7 +3215,7 @@ macro_rules! iterator { fn next(&mut self) -> Option<$elem> { // could be implemented with slices, but this avoids bounds checks unsafe { - assume(!self.ptr.is_null()); + assume(!self.ptr.as_ptr().is_null()); if mem::size_of::() != 0 { assume(!self.end.is_null()); } @@ -3245,9 +3245,12 @@ macro_rules! iterator { if mem::size_of::() == 0 { // We have to do it this way as `ptr` may never be 0, but `end` // could be (due to wrapping). - self.end = self.ptr; + self.end = self.ptr.as_ptr(); } else { - self.ptr = self.end; + unsafe { + // End can't be 0 if T isn't ZST because ptr isn't 0 and end >= ptr + self.ptr = NonNull::new_unchecked(self.end as *mut T); + } } return None; } @@ -3308,7 +3311,7 @@ macro_rules! iterator { fn next_back(&mut self) -> Option<$elem> { // could be implemented with slices, but this avoids bounds checks unsafe { - assume(!self.ptr.is_null()); + assume(!self.ptr.as_ptr().is_null()); if mem::size_of::() != 0 { assume(!self.end.is_null()); } @@ -3324,7 +3327,7 @@ macro_rules! iterator { fn nth_back(&mut self, n: usize) -> Option<$elem> { if n >= len!(self) { // This iterator is now empty. - self.end = self.ptr; + self.end = self.ptr.as_ptr(); return None; } // We are in bounds. `pre_dec_end` does the right thing even for ZSTs. @@ -3365,7 +3368,7 @@ macro_rules! iterator { /// [slices]: ../../std/primitive.slice.html #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { - ptr: *const T, + ptr: NonNull, end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that // ptr == end is a quick test for the Iterator being empty, that works // for both ZST and non-ZST. @@ -3467,7 +3470,7 @@ impl AsRef<[T]> for Iter<'_, T> { /// [slices]: ../../std/primitive.slice.html #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { - ptr: *mut T, + ptr: NonNull, end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that // ptr == end is a quick test for the Iterator being empty, that works // for both ZST and non-ZST. @@ -3522,7 +3525,7 @@ impl<'a, T> IterMut<'a, T> { /// ``` #[stable(feature = "iter_to_slice", since = "1.4.0")] pub fn into_slice(self) -> &'a mut [T] { - unsafe { from_raw_parts_mut(self.ptr, len!(self)) } + unsafe { from_raw_parts_mut(self.ptr.as_ptr(), len!(self)) } } /// Views the underlying data as a subslice of the original data. @@ -5682,7 +5685,7 @@ impl_marker_for!(BytewiseEquality, #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a T { - &*self.ptr.add(i) + &*self.ptr.as_ptr().add(i) } fn may_have_side_effect() -> bool { false @@ -5692,7 +5695,7 @@ unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> { #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for IterMut<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut T { - &mut *self.ptr.add(i) + &mut *self.ptr.as_ptr().add(i) } fn may_have_side_effect() -> bool { false diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index ed84bd118f725..5fca5f061caf2 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -168,6 +168,7 @@ pub struct LoweringContext<'a, 'hir: 'a> { allow_try_trait: Option>, allow_gen_future: Option>, + allow_into_future: Option>, } pub trait Resolver { @@ -300,6 +301,7 @@ pub fn lower_crate<'a, 'hir>( in_scope_lifetimes: Vec::new(), allow_try_trait: Some([sym::try_trait][..].into()), allow_gen_future: Some([sym::gen_future][..].into()), + allow_into_future: Some([sym::into_future][..].into()), } .lower_crate(krate) } diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index 8a9614c6cb2c0..dbfa351b918b2 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -529,7 +529,7 @@ impl<'hir> LoweringContext<'_, 'hir> { /// Desugar `.await` into: /// ```rust - /// match { + /// match ::std::future::IntoFuture::into_future() { /// mut pinned => loop { /// match ::std::future::poll_with_tls_context(unsafe { /// <::std::pin::Pin>::new_unchecked(&mut pinned) @@ -653,11 +653,27 @@ impl<'hir> LoweringContext<'_, 'hir> { // mut pinned => loop { ... } let pinned_arm = self.arm(pinned_pat, loop_expr); - // match { + // `match ::std::future::IntoFuture::into_future() { ... }` + let into_future_span = self.mark_span_with_reason( + DesugaringKind::Await, + await_span, + self.allow_into_future.clone(), + ); + let expr = self.lower_expr_mut(expr); + let into_future_expr = self.expr_call_std_path( + into_future_span, + &[sym::future, sym::IntoFuture, sym::into_future], + arena_vec![self; expr], + ); + + // match { // mut pinned => loop { .. } // } - let expr = self.lower_expr(expr); - hir::ExprKind::Match(expr, arena_vec![self; pinned_arm], hir::MatchSource::AwaitDesugar) + hir::ExprKind::Match( + into_future_expr, + arena_vec![self; pinned_arm], + hir::MatchSource::AwaitDesugar, + ) } fn lower_expr_closure( diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 93f167cdb9e54..2be36ad418a5b 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -416,22 +416,30 @@ impl<'tcx, Tag> Scalar { } } + #[inline] + fn to_unsigned_with_bit_width(self, bits: u64) -> InterpResult<'static, u128> { + let sz = Size::from_bits(bits); + self.to_bits(sz) + } + + /// Converts the scalar to produce an `u8`. Fails if the scalar is a pointer. pub fn to_u8(self) -> InterpResult<'static, u8> { - let sz = Size::from_bits(8); - let b = self.to_bits(sz)?; - Ok(b as u8) + self.to_unsigned_with_bit_width(8).map(|v| v as u8) + } + + /// Converts the scalar to produce an `u16`. Fails if the scalar is a pointer. + pub fn to_u16(self) -> InterpResult<'static, u16> { + self.to_unsigned_with_bit_width(16).map(|v| v as u16) } + /// Converts the scalar to produce an `u32`. Fails if the scalar is a pointer. pub fn to_u32(self) -> InterpResult<'static, u32> { - let sz = Size::from_bits(32); - let b = self.to_bits(sz)?; - Ok(b as u32) + self.to_unsigned_with_bit_width(32).map(|v| v as u32) } + /// Converts the scalar to produce an `u64`. Fails if the scalar is a pointer. pub fn to_u64(self) -> InterpResult<'static, u64> { - let sz = Size::from_bits(64); - let b = self.to_bits(sz)?; - Ok(b as u64) + self.to_unsigned_with_bit_width(64).map(|v| v as u64) } pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> { @@ -439,25 +447,31 @@ impl<'tcx, Tag> Scalar { Ok(b as u64) } - pub fn to_i8(self) -> InterpResult<'static, i8> { - let sz = Size::from_bits(8); + #[inline] + fn to_signed_with_bit_width(self, bits: u64) -> InterpResult<'static, i128> { + let sz = Size::from_bits(bits); let b = self.to_bits(sz)?; - let b = sign_extend(b, sz) as i128; - Ok(b as i8) + Ok(sign_extend(b, sz) as i128) + } + + /// Converts the scalar to produce an `i8`. Fails if the scalar is a pointer. + pub fn to_i8(self) -> InterpResult<'static, i8> { + self.to_signed_with_bit_width(8).map(|v| v as i8) + } + + /// Converts the scalar to produce an `i16`. Fails if the scalar is a pointer. + pub fn to_i16(self) -> InterpResult<'static, i16> { + self.to_signed_with_bit_width(16).map(|v| v as i16) } + /// Converts the scalar to produce an `i32`. Fails if the scalar is a pointer. pub fn to_i32(self) -> InterpResult<'static, i32> { - let sz = Size::from_bits(32); - let b = self.to_bits(sz)?; - let b = sign_extend(b, sz) as i128; - Ok(b as i32) + self.to_signed_with_bit_width(32).map(|v| v as i32) } + /// Converts the scalar to produce an `i64`. Fails if the scalar is a pointer. pub fn to_i64(self) -> InterpResult<'static, i64> { - let sz = Size::from_bits(64); - let b = self.to_bits(sz)?; - let b = sign_extend(b, sz) as i128; - Ok(b as i64) + self.to_signed_with_bit_width(64).map(|v| v as i64) } pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> { diff --git a/src/librustc_data_structures/graph/iterate/mod.rs b/src/librustc_data_structures/graph/iterate/mod.rs index 53475cdf4ba42..d9d4c7e321fb5 100644 --- a/src/librustc_data_structures/graph/iterate/mod.rs +++ b/src/librustc_data_structures/graph/iterate/mod.rs @@ -101,14 +101,14 @@ pub enum ControlFlow { pub enum NodeStatus { /// This node has been examined by the depth-first search but is not yet `Settled`. /// - /// Also referred to as "gray" or "discovered" nodes in [CLR][]. + /// Also referred to as "gray" or "discovered" nodes in [CLR]. /// /// [CLR]: https://en.wikipedia.org/wiki/Introduction_to_Algorithms Visited, /// This node and all nodes reachable from it have been examined by the depth-first search. /// - /// Also referred to as "black" or "finished" nodes in [CLR][]. + /// Also referred to as "black" or "finished" nodes in [CLR]. /// /// [CLR]: https://en.wikipedia.org/wiki/Introduction_to_Algorithms Settled, @@ -122,13 +122,13 @@ struct Event { /// A depth-first search that also tracks when all successors of a node have been examined. /// /// This is based on the DFS described in [Introduction to Algorithms (1st ed.)][CLR], hereby -/// referred to as **CLR**. However, we use the terminology in [`NodeStatus`][] above instead of +/// referred to as **CLR**. However, we use the terminology in [`NodeStatus`] above instead of /// "discovered"/"finished" or "white"/"grey"/"black". Each node begins the search with no status, /// becomes `Visited` when it is first examined by the DFS and is `Settled` when all nodes /// reachable from it have been examined. This allows us to differentiate between "tree", "back" /// and "forward" edges (see [`TriColorVisitor::node_examined`]). /// -/// Unlike the pseudocode in [CLR][], this implementation is iterative and does not use timestamps. +/// Unlike the pseudocode in [CLR], this implementation is iterative and does not use timestamps. /// We accomplish this by storing `Event`s on the stack that result in a (possible) state change /// for each node. A `Visited` event signifies that we should examine this node if it has not yet /// been `Visited` or `Settled`. When a node is examined for the first time, we mark it as @@ -246,7 +246,7 @@ where /// By checking the value of `prior_status`, this visitor can determine whether the edge /// leading to this node was a tree edge (`None`), forward edge (`Some(Settled)`) or back edge /// (`Some(Visited)`). For a full explanation of each edge type, see the "Depth-first Search" - /// chapter in [CLR][] or [wikipedia][]. + /// chapter in [CLR] or [wikipedia]. /// /// If you want to know *both* nodes linked by each edge, you'll need to modify /// `TriColorDepthFirstSearch` to store a `source` node for each `Visited` event. diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index e4dd2f006ab23..617e56ffe3674 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -15,7 +15,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(nll)] -#![feature(matches_macro)] #![recursion_limit = "256"] #[macro_use] diff --git a/src/librustc_mir/dataflow/generic.rs b/src/librustc_mir/dataflow/generic.rs index 659ebeab65022..7eb6f5cc073df 100644 --- a/src/librustc_mir/dataflow/generic.rs +++ b/src/librustc_mir/dataflow/generic.rs @@ -10,7 +10,7 @@ //! interface, but make `Engine` and `ResultsCursor` the canonical way to perform and inspect a //! dataflow analysis. This requires porting the graphviz debugging logic to this module, deciding //! on a way to handle the `before` methods in `BitDenotation` and creating an adapter so that -//! gen-kill problems can still be evaluated efficiently. See the discussion in [#64566][] for more +//! gen-kill problems can still be evaluated efficiently. See the discussion in [#64566] for more //! information. //! //! [gk]: https://en.wikipedia.org/wiki/Data-flow_analysis#Bit_vector_problems diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 30db1ce345ab3..32b35c4139dad 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -29,7 +29,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(range_is_empty)] #![feature(stmt_expr_attributes)] #![feature(trait_alias)] -#![feature(matches_macro)] #![recursion_limit = "256"] #[macro_use] diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index 746d83b05c6b3..bd895171e358e 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -1,6 +1,5 @@ //! A copy of the `Qualif` trait in `qualify_consts.rs` that is suitable for the new validator. -use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::ty::{self, Ty}; use syntax_pos::DUMMY_SP; @@ -33,12 +32,6 @@ pub trait Qualif { /// of the type. fn in_any_value_of_ty(_cx: &ConstCx<'_, 'tcx>, _ty: Ty<'tcx>) -> bool; - fn in_static(cx: &ConstCx<'_, 'tcx>, def_id: DefId) -> bool { - // `mir_const_qualif` does return the qualifs in the final value of a `static`, so we could - // use value-based qualification here, but we shouldn't do this without a good reason. - Self::in_any_value_of_ty(cx, cx.tcx.type_of(def_id)) - } - fn in_projection_structurally( cx: &ConstCx<'_, 'tcx>, per_local: &impl Fn(Local) -> bool, @@ -101,8 +94,14 @@ pub trait Qualif { } Operand::Constant(ref constant) => { - if let Some(static_) = constant.check_static_ptr(cx.tcx) { - Self::in_static(cx, static_) + if constant.check_static_ptr(cx.tcx).is_some() { + // `mir_const_qualif` does return the qualifs in the final value of a `static`, + // so we could use value-based qualification here, but we shouldn't do this + // without a good reason. + // + // Note: this uses `constant.literal.ty` which is a reference or pointer to the + // type of the actual `static` item. + Self::in_any_value_of_ty(cx, constant.literal.ty) } else if let ty::ConstKind::Unevaluated(def_id, _) = constant.literal.val { // Don't peek inside trait associated constants. if cx.tcx.trait_of_item(def_id).is_some() { diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index a928867d9de93..fdc587ba5dacf 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1076,7 +1076,7 @@ impl<'a, K, V> IterMut<'a, K, V> { /// An owning iterator over the entries of a `HashMap`. /// -/// This `struct` is created by the [`into_iter`] method on [`HashMap`][`HashMap`] +/// This `struct` is created by the [`into_iter`] method on [`HashMap`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.HashMap.html#method.into_iter diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index fff64e9fc9008..566e5146cf857 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -1101,7 +1101,7 @@ pub struct Iter<'a, K: 'a> { /// An owning iterator over the items of a `HashSet`. /// -/// This `struct` is created by the [`into_iter`] method on [`HashSet`][`HashSet`] +/// This `struct` is created by the [`into_iter`] method on [`HashSet`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`HashSet`]: struct.HashSet.html diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 9c7422c2b20a6..908736c63931b 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -10,7 +10,11 @@ use core::task::{Context, Poll}; #[doc(inline)] #[stable(feature = "futures_api", since = "1.36.0")] -pub use core::future::*; +pub use core::future::Future; + +#[doc(inline)] +#[unstable(feature = "into_future", issue = "67644")] +pub use core::future::IntoFuture; /// Wrap a generator in a future. /// diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9e9df5ab9b6ce..930bf397bc45b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -269,6 +269,7 @@ #![feature(hashmap_internals)] #![feature(int_error_internals)] #![feature(int_error_matching)] +#![feature(into_future)] #![feature(integer_atomics)] #![feature(lang_items)] #![feature(libc)] @@ -276,7 +277,6 @@ #![feature(linkage)] #![feature(log_syntax)] #![feature(manually_drop_take)] -#![feature(matches_macro)] #![feature(maybe_uninit_ref)] #![feature(maybe_uninit_slice)] #![feature(needs_panic_runtime)] diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 580ff1610ac83..f308d511cf850 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2,7 +2,7 @@ //! Cross-platform path manipulation. //! -//! This module provides two types, [`PathBuf`] and [`Path`][`Path`] (akin to [`String`] +//! This module provides two types, [`PathBuf`] and [`Path`] (akin to [`String`] //! and [`str`]), for working with paths abstractly. These types are thin wrappers //! around [`OsString`] and [`OsStr`] respectively, meaning that they work directly //! on strings according to the local platform's path syntax. @@ -296,6 +296,13 @@ where } // See note at the top of this module to understand why these are used: +// +// These casts are safe as OsStr is internally a wrapper around [u8] on all +// platforms. +// +// Note that currently this relies on the special knowledge that libstd has; +// these types are single-element structs but are not marked repr(transparent) +// or repr(C) which would make these casts allowable outside std. fn os_str_as_u8_slice(s: &OsStr) -> &[u8] { unsafe { &*(s as *const OsStr as *const [u8]) } } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 0e334c191e7b9..e70204d6839fc 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -286,7 +286,7 @@ mod sync; mod cache_aligned; -/// The receiving half of Rust's [`channel`][] (or [`sync_channel`]) type. +/// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type. /// This half can only be owned by one thread. /// /// Messages sent to the channel can be retrieved using [`recv`]. @@ -558,7 +558,7 @@ pub struct SendError(#[stable(feature = "rust1", since = "1.0.0")] pub T); /// An error returned from the [`recv`] function on a [`Receiver`]. /// /// The [`recv`] operation can only fail if the sending half of a -/// [`channel`][`channel`] (or [`sync_channel`]) is disconnected, implying that no further +/// [`channel`] (or [`sync_channel`]) is disconnected, implying that no further /// messages will ever be received. /// /// [`recv`]: struct.Receiver.html#method.recv @@ -1108,7 +1108,7 @@ impl Receiver { /// /// This function will always block the current thread if there is no data /// available and it's possible for more data to be sent. Once a message is - /// sent to the corresponding [`Sender`][] (or [`SyncSender`]), then this + /// sent to the corresponding [`Sender`] (or [`SyncSender`]), then this /// receiver will wake up and return that message. /// /// If the corresponding [`Sender`] has disconnected, or it disconnects while @@ -1194,7 +1194,7 @@ impl Receiver { /// /// This function will always block the current thread if there is no data /// available and it's possible for more data to be sent. Once a message is - /// sent to the corresponding [`Sender`][] (or [`SyncSender`]), then this + /// sent to the corresponding [`Sender`] (or [`SyncSender`]), then this /// receiver will wake up and return that message. /// /// If the corresponding [`Sender`] has disconnected, or it disconnects while @@ -1295,7 +1295,7 @@ impl Receiver { /// /// This function will always block the current thread if there is no data /// available and it's possible for more data to be sent. Once a message is - /// sent to the corresponding [`Sender`][] (or [`SyncSender`]), then this + /// sent to the corresponding [`Sender`] (or [`SyncSender`]), then this /// receiver will wake up and return that message. /// /// If the corresponding [`Sender`] has disconnected, or it disconnects while diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 2ff36133a7cef..fdd29af858185 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -25,7 +25,7 @@ use crate::sys_common::rwlock as sys; /// The type parameter `T` represents the data that this lock protects. It is /// required that `T` satisfies [`Send`] to be shared across threads and /// [`Sync`] to allow concurrent access through readers. The RAII guards -/// returned from the locking methods implement [`Deref`][] (and [`DerefMut`] +/// returned from the locking methods implement [`Deref`] (and [`DerefMut`] /// for the `write` methods) to allow access to the content of the lock. /// /// # Poisoning diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 31370e2c92e71..7b8819377e67c 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -11,7 +11,6 @@ #![feature(const_transmute)] #![feature(crate_visibility_modifier)] #![feature(label_break_value)] -#![feature(matches_macro)] #![feature(nll)] #![feature(try_trait)] #![feature(slice_patterns)] diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 8fdc199d9ed7c..7ae037faf151d 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -379,6 +379,8 @@ symbols! { infer_static_outlives_requirements, inline, intel, + into_future, + IntoFuture, into_iter, IntoIterator, into_result, diff --git a/src/test/ui/async-await/async-fn-size-moved-locals.rs b/src/test/ui/async-await/async-fn-size-moved-locals.rs index 4a413381aa300..f2469de7394b0 100644 --- a/src/test/ui/async-await/async-fn-size-moved-locals.rs +++ b/src/test/ui/async-await/async-fn-size-moved-locals.rs @@ -112,7 +112,7 @@ async fn mixed_sizes() { fn main() { assert_eq!(1028, std::mem::size_of_val(&single())); assert_eq!(1032, std::mem::size_of_val(&single_with_noop())); - assert_eq!(3084, std::mem::size_of_val(&joined())); - assert_eq!(3084, std::mem::size_of_val(&joined_with_noop())); - assert_eq!(7188, std::mem::size_of_val(&mixed_sizes())); + assert_eq!(3080, std::mem::size_of_val(&joined())); + assert_eq!(3080, std::mem::size_of_val(&joined_with_noop())); + assert_eq!(6164, std::mem::size_of_val(&mixed_sizes())); } diff --git a/src/test/ui/async-await/await-into-future.rs b/src/test/ui/async-await/await-into-future.rs new file mode 100644 index 0000000000000..d5ff0eb304937 --- /dev/null +++ b/src/test/ui/async-await/await-into-future.rs @@ -0,0 +1,28 @@ +// check-pass + +// edition:2018 + +#![feature(into_future)] + +use std::{future::{Future, IntoFuture}, pin::Pin}; + +struct AwaitMe; + +impl IntoFuture for AwaitMe { + type Output = i32; + type Future = Pin>>; + + fn into_future(self) -> Self::Future { + Box::pin(me()) + } +} + +async fn me() -> i32 { + 41 +} + +async fn run() { + assert_eq!(AwaitMe.await, 41); +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-62009-1.stderr b/src/test/ui/async-await/issues/issue-62009-1.stderr index 3a49a5a97de3d..e31904b6c1f7b 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.stderr +++ b/src/test/ui/async-await/issues/issue-62009-1.stderr @@ -32,11 +32,8 @@ error[E0277]: the trait bound `[closure@$DIR/issue-62009-1.rs:13:5: 13:15]: std: | LL | (|_| 2333).await; | ^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:13:5: 13:15]` - | - ::: $SRC_DIR/libstd/future.rs:LL:COL | -LL | F: Future, - | ------ required by this bound in `std::future::poll_with_tls_context` + = note: required by `std::future::IntoFuture::into_future` error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/const-eval/promote-static.rs b/src/test/ui/consts/const-eval/promote-static.rs new file mode 100644 index 0000000000000..d3c663c53e905 --- /dev/null +++ b/src/test/ui/consts/const-eval/promote-static.rs @@ -0,0 +1,14 @@ +// regression test for #67609. + +// check-pass + +static NONE: Option = None; + +static NONE_REF_REF: &&Option = { + let x = &&NONE; + x +}; + +fn main() { + println!("{:?}", NONE_REF_REF); +} diff --git a/src/test/ui/issues/issue-51770.rs b/src/test/ui/issues/issue-51770.rs new file mode 100644 index 0000000000000..bcb37a5f4ff5d --- /dev/null +++ b/src/test/ui/issues/issue-51770.rs @@ -0,0 +1,20 @@ +// check-pass + +#![crate_type = "lib"] + +// In an older version, when NLL was still a feature, the following previously did not compile +// #![feature(nll)] + +use std::ops::Index; + +pub struct Test { + a: T, +} + +impl Index for Test { + type Output = T; + + fn index(&self, _index: usize) -> &Self::Output { + &self.a + } +}