From ecb668691424595f6e302095c3078de2f89bf435 Mon Sep 17 00:00:00 2001 From: Kornel Date: Mon, 2 Aug 2021 15:52:22 +0100 Subject: [PATCH 01/16] Expand explanation of E0530 --- .../src/error_codes/E0530.md | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0530.md b/compiler/rustc_error_codes/src/error_codes/E0530.md index 502f674fc1d21..60fa711cbed36 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0530.md +++ b/compiler/rustc_error_codes/src/error_codes/E0530.md @@ -1,32 +1,57 @@ A binding shadowed something it shouldn't. -Erroneous code example: +A match arm or a variable has a name that is already used by +something else, e.g. + +* struct name +* enum variant +* static +* associated constant + +This error may also happen when an enum variant *with fields* is used +in a pattern, but without its fields. + +```compile_fail +enum Enum { + WithField(i32) +} + +use Enum::*; +match WithField(1) { + WithField => {} // error: missing (_) +} +``` + +Match bindings cannot shadow statics: ```compile_fail,E0530 static TEST: i32 = 0; -let r: (i32, i32) = (0, 0); +let r = 123; match r { - TEST => {} // error: match bindings cannot shadow statics + TEST => {} // error: name of a static } ``` -To fix this error, just change the binding's name in order to avoid shadowing -one of the following: +Fixed examples: -* struct name -* struct/enum variant -* static -* const -* associated const +``` +static TEST: i32 = 0; -Fixed example: +let r = 123; +match r { + some_value => {} // ok! +} +``` + +or ``` -static TEST: i32 = 0; +const TEST: i32 = 0; // const, not static -let r: (i32, i32) = (0, 0); +let r = 123; match r { - something => {} // ok! + TEST => {} // const is ok! + other_values => {} } ``` From 2a56a4fe541b6d239cd76dcfc7933395ae8ec4ec Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Sat, 7 Aug 2021 11:33:18 -0400 Subject: [PATCH 02/16] removed references to parent/child from std::thread documentation - also clarifies how thread.join and detaching of threads works - the previous prose implied that there is a relationship between a spawning thread and the thread being spawned, and that "child" threads couldn't outlive their parents unless detached, which is incorrect. --- library/std/src/thread/mod.rs | 71 ++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 36e1d502019b7..f44df845bf4dd 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -28,7 +28,7 @@ //! When the main thread of a Rust program terminates, the entire program shuts //! down, even if other threads are still running. However, this module provides //! convenient facilities for automatically waiting for the termination of a -//! child thread (i.e., join). +//! thread (i.e., join). //! //! ## Spawning a thread //! @@ -42,38 +42,43 @@ //! }); //! ``` //! -//! In this example, the spawned thread is "detached" from the current -//! thread. This means that it can outlive its parent (the thread that spawned -//! it), unless this parent is the main thread. +//! In this example, the spawned thread is "detached," which means that there is +//! no way for the program to learn when the spawned thread completes or otherwise +//! terminates. //! -//! The parent thread can also wait on the completion of the child -//! thread; a call to [`spawn`] produces a [`JoinHandle`], which provides -//! a `join` method for waiting: +//! To learn when a thread completes, it is necessary to capture the [`JoinHandle`] +//! object that is returned by the call to [`spawn`], which provides +//! a `join` method that allows the caller to wait for the completion of the +//! spawned thread: //! //! ```rust //! use std::thread; //! -//! let child = thread::spawn(move || { +//! let thread_join_handle = thread::spawn(move || { //! // some work here //! }); //! // some work here -//! let res = child.join(); +//! let res = thread_join_handle.join(); //! ``` //! //! The [`join`] method returns a [`thread::Result`] containing [`Ok`] of the final -//! value produced by the child thread, or [`Err`] of the value given to -//! a call to [`panic!`] if the child panicked. +//! value produced by the spawned thread, or [`Err`] of the value given to +//! a call to [`panic!`] if the thread panicked. +//! +//! Note that there is no parent/child relationship between a thread that spawns a +//! new thread and the thread being spawned. In particular, the spawned thread may or +//! may not outlive the spawning thread, unless the spawning thread is the main thread. //! //! ## Configuring threads //! //! A new thread can be configured before it is spawned via the [`Builder`] type, -//! which currently allows you to set the name and stack size for the child thread: +//! which currently allows you to set the name and stack size for the thread: //! //! ```rust //! # #![allow(unused_must_use)] //! use std::thread; //! -//! thread::Builder::new().name("child1".to_string()).spawn(move || { +//! thread::Builder::new().name("thread1".to_string()).spawn(move || { //! println!("Hello, world!"); //! }); //! ``` @@ -344,7 +349,7 @@ impl Builder { /// The spawned thread may outlive the caller (unless the caller thread /// is the main thread; the whole process is terminated when the main /// thread finishes). The join handle can be used to block on - /// termination of the child thread, including recovering its panics. + /// termination of the spawned thread, including recovering its panics. /// /// For a more complete documentation see [`thread::spawn`][`spawn`]. /// @@ -389,7 +394,7 @@ impl Builder { /// The spawned thread may outlive the caller (unless the caller thread /// is the main thread; the whole process is terminated when the main /// thread finishes). The join handle can be used to block on - /// termination of the child thread, including recovering its panics. + /// termination of the spawned thread, including recovering its panics. /// /// This method is identical to [`thread::Builder::spawn`][`Builder::spawn`], /// except for the relaxed lifetime bounds, which render it unsafe. @@ -516,15 +521,16 @@ impl Builder { /// Spawns a new thread, returning a [`JoinHandle`] for it. /// -/// The join handle will implicitly *detach* the child thread upon being -/// dropped. In this case, the child thread may outlive the parent (unless -/// the parent thread is the main thread; the whole process is terminated when -/// the main thread finishes). Additionally, the join handle provides a [`join`] -/// method that can be used to join the child thread. If the child thread -/// panics, [`join`] will return an [`Err`] containing the argument given to -/// [`panic!`]. +/// The join handle provides a [`join`] method that can be used to join the spawned +/// thread. If the spawned thread panics, [`join`] will return an [`Err`] containing +/// the argument given to [`panic!`]. +/// +/// If the join handle is dropped, the spawned thread will implicitly be *detached*. +/// In this case, the spawned thread may no longer be joined. +/// (It is the responsibility of the program to either eventually join threads it +/// creates or detach them; otherwise, a resource leak will result.) /// -/// This will create a thread using default parameters of [`Builder`], if you +/// This call will create a thread using default parameters of [`Builder`], if you /// want to specify the stack size or the name of the thread, use this API /// instead. /// @@ -533,8 +539,8 @@ impl Builder { /// /// - The `'static` constraint means that the closure and its return value /// must have a lifetime of the whole program execution. The reason for this -/// is that threads can `detach` and outlive the lifetime they have been -/// created in. +/// is that threads can outlive the lifetime they have been created in. +/// /// Indeed if the thread, and by extension its return value, can outlive their /// caller, we need to make sure that they will be valid afterwards, and since /// we *can't* know when it will return we need to have them valid as long as @@ -1236,10 +1242,10 @@ impl fmt::Debug for Thread { #[stable(feature = "rust1", since = "1.0.0")] pub type Result = crate::result::Result>; -// This packet is used to communicate the return value between the child thread -// and the parent thread. Memory is shared through the `Arc` within and there's +// This packet is used to communicate the return value between the spawned thread +// and the rest of the program. Memory is shared through the `Arc` within and there's // no need for a mutex here because synchronization happens with `join()` (the -// parent thread never reads this packet until the child has exited). +// caller will never read this packet until the thread has exited). // // This packet itself is then stored into a `JoinInner` which in turns is placed // in `JoinHandle` and `JoinGuard`. Due to the usage of `UnsafeCell` we need to @@ -1303,7 +1309,7 @@ impl JoinInner { /// }).unwrap(); /// ``` /// -/// Child being detached and outliving its parent: +/// A thread being detached and outliving the thread that spawned it: /// /// ```no_run /// use std::thread; @@ -1361,12 +1367,15 @@ impl JoinHandle { /// Waits for the associated thread to finish. /// + /// This function will return immediately if the associated thread has already finished. + /// /// In terms of [atomic memory orderings], the completion of the associated /// thread synchronizes with this function returning. In other words, all - /// operations performed by that thread are ordered before all + /// operations performed by that thread [happen + /// before](https://doc.rust-lang.org/nomicon/atomics.html#data-accesses) all /// operations that happen after `join` returns. /// - /// If the child thread panics, [`Err`] is returned with the parameter given + /// If the associated thread panics, [`Err`] is returned with the parameter given /// to [`panic!`]. /// /// [`Err`]: crate::result::Result::Err From eefd790d3b84d051f124222b9948d4a29fb0decf Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sun, 27 Dec 2020 19:46:01 +0100 Subject: [PATCH 03/16] impl const From for num --- library/core/src/convert/num.rs | 15 ++++++++++----- library/core/src/lib.rs | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs index 1d3a12962145e..75ef873abc965 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs @@ -45,7 +45,8 @@ impl_float_to_int!(f64 => u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize); macro_rules! impl_from { ($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => { #[$attr] - impl From<$Small> for $Large { + #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")] + impl const From<$Small> for $Large { // Rustdocs on the impl block show a "[+] show undocumented items" toggle. // Rustdocs on functions do not. #[doc = $doc] @@ -172,7 +173,8 @@ impl_from! { f32, f64, #[stable(feature = "lossless_float_conv", since = "1.6.0" macro_rules! try_from_unbounded { ($source:ty, $($target:ty),*) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Try to create the target number type from a source @@ -190,7 +192,8 @@ macro_rules! try_from_unbounded { macro_rules! try_from_lower_bounded { ($source:ty, $($target:ty),*) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Try to create the target number type from a source @@ -212,7 +215,8 @@ macro_rules! try_from_lower_bounded { macro_rules! try_from_upper_bounded { ($source:ty, $($target:ty),*) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Try to create the target number type from a source @@ -234,7 +238,8 @@ macro_rules! try_from_upper_bounded { macro_rules! try_from_both_bounded { ($source:ty, $($target:ty),*) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Try to create the target number type from a source diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 222ef34b6aa8a..37c3f8d4c16ab 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -99,6 +99,7 @@ #![feature(const_slice_from_raw_parts)] #![feature(const_slice_ptr_len)] #![feature(const_swap)] +#![feature(const_trait_impl)] #![feature(const_type_id)] #![feature(const_type_name)] #![feature(const_unreachable_unchecked)] From 09928a9a20ceefae6f82dbbe3b526f2227add1e9 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sat, 13 Mar 2021 18:40:47 +0100 Subject: [PATCH 04/16] Add tests --- library/core/tests/lib.rs | 2 ++ library/core/tests/num/const_from.rs | 21 +++++++++++++++++++++ library/core/tests/num/mod.rs | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 library/core/tests/num/const_from.rs diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index c7756a503c3e9..89eaa34a6717c 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -13,6 +13,8 @@ #![feature(const_ptr_read)] #![feature(const_ptr_write)] #![feature(const_ptr_offset)] +#![feature(const_trait_impl)] +#![feature(const_num_from_num)] #![feature(core_intrinsics)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] diff --git a/library/core/tests/num/const_from.rs b/library/core/tests/num/const_from.rs new file mode 100644 index 0000000000000..7c6de92e48026 --- /dev/null +++ b/library/core/tests/num/const_from.rs @@ -0,0 +1,21 @@ +#[test] +fn from() { + use core::convert::TryFrom; + use core::num::TryFromIntError; + + // From + const FROM: i64 = i64::from(1i32); + assert_eq!(FROM, 1i64); + + // Upper bounded + const U8_FROM_U16: Result = u8::try_from(1u16); + assert_eq!(U8_FROM_U16, Ok(1u8)); + + // Both bounded + const I8_FROM_I16: Result = i8::try_from(1i16); + assert_eq!(I8_FROM_I16, Ok(1i8)); + + // Lower bounded + const I16_FROM_U16: Result = i16::try_from(1u16); + assert_eq!(I16_FROM_U16, Ok(1i16)); +} diff --git a/library/core/tests/num/mod.rs b/library/core/tests/num/mod.rs index 76e838cf6bfbd..37b5e9127d5b0 100644 --- a/library/core/tests/num/mod.rs +++ b/library/core/tests/num/mod.rs @@ -27,6 +27,8 @@ mod u64; mod u8; mod bignum; + +mod const_from; mod dec2flt; mod flt2dec; mod int_log; From c8bf5ed628c5007bd7c88a2265698d3117cbdc72 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sat, 7 Aug 2021 18:59:07 +0200 Subject: [PATCH 05/16] Add test for int to float --- library/core/tests/num/const_from.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/tests/num/const_from.rs b/library/core/tests/num/const_from.rs index 7c6de92e48026..aca18ef39de1a 100644 --- a/library/core/tests/num/const_from.rs +++ b/library/core/tests/num/const_from.rs @@ -7,6 +7,10 @@ fn from() { const FROM: i64 = i64::from(1i32); assert_eq!(FROM, 1i64); + // From int to float + const FROM_F64: f64 = f64::from(42u8); + assert_eq!(FROM_F64, 42f64); + // Upper bounded const U8_FROM_U16: Result = u8::try_from(1u16); assert_eq!(U8_FROM_U16, Ok(1u8)); From d777cb84e2d27a5f44eab94854b74fea33034bb4 Mon Sep 17 00:00:00 2001 From: Ellen Date: Sat, 7 Aug 2021 18:44:36 +0100 Subject: [PATCH 06/16] less opt in const param of --- compiler/rustc_typeck/src/collect/type_of.rs | 7 ++++-- src/test/ui/const-generics/enum-variants.rs | 24 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/const-generics/enum-variants.rs diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 96b3fa9aa0143..7083b11f7d0ac 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -190,8 +190,12 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option< // Try to use the segment resolution if it is valid, otherwise we // default to the path resolution. let res = segment.res.filter(|&r| r != Res::Err).unwrap_or(path.res); + use def::CtorOf; let generics = match res { - Res::Def(DefKind::Ctor(..), def_id) => { + Res::Def(DefKind::Ctor(CtorOf::Variant, _), def_id) => { + tcx.generics_of(tcx.parent(def_id).and_then(|def_id| tcx.parent(def_id)).unwrap()) + } + Res::Def(DefKind::Variant | DefKind::Ctor(CtorOf::Struct, _), def_id) => { tcx.generics_of(tcx.parent(def_id).unwrap()) } // Other `DefKind`s don't have generics and would ICE when calling @@ -200,7 +204,6 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option< DefKind::Struct | DefKind::Union | DefKind::Enum - | DefKind::Variant | DefKind::Trait | DefKind::OpaqueTy | DefKind::TyAlias diff --git a/src/test/ui/const-generics/enum-variants.rs b/src/test/ui/const-generics/enum-variants.rs new file mode 100644 index 0000000000000..a82db1c4b3217 --- /dev/null +++ b/src/test/ui/const-generics/enum-variants.rs @@ -0,0 +1,24 @@ +// check-pass +pub enum Foo { + Variant, + Variant2(), + Variant3{}, +} + +struct Bar; +struct Bar2(); +struct Bar3 {} + +fn main() { + let _ = Foo::Variant::<1>; + let _ = Foo::Variant2::<1>(); + let _ = Foo::Variant3::<1>{}; + + let _ = Foo::<1>::Variant; + let _ = Foo::<1>::Variant2(); + let _ = Foo::<1>::Variant3{}; + + let _ = Bar::<1>; + let _ = Bar2::<1>(); + let _ = Bar3::<1>{}; +} From 5f61271e382cfab7159a6dedcf673cafaab51e5a Mon Sep 17 00:00:00 2001 From: Ellen Date: Sat, 7 Aug 2021 20:55:37 +0100 Subject: [PATCH 07/16] fmt --- compiler/rustc_typeck/src/collect/type_of.rs | 6 +++--- src/test/ui/const-generics/enum-variants.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 7083b11f7d0ac..b9483d6f98760 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -192,9 +192,9 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option< let res = segment.res.filter(|&r| r != Res::Err).unwrap_or(path.res); use def::CtorOf; let generics = match res { - Res::Def(DefKind::Ctor(CtorOf::Variant, _), def_id) => { - tcx.generics_of(tcx.parent(def_id).and_then(|def_id| tcx.parent(def_id)).unwrap()) - } + Res::Def(DefKind::Ctor(CtorOf::Variant, _), def_id) => tcx.generics_of( + tcx.parent(def_id).and_then(|def_id| tcx.parent(def_id)).unwrap(), + ), Res::Def(DefKind::Variant | DefKind::Ctor(CtorOf::Struct, _), def_id) => { tcx.generics_of(tcx.parent(def_id).unwrap()) } diff --git a/src/test/ui/const-generics/enum-variants.rs b/src/test/ui/const-generics/enum-variants.rs index a82db1c4b3217..5c6c4a8efac15 100644 --- a/src/test/ui/const-generics/enum-variants.rs +++ b/src/test/ui/const-generics/enum-variants.rs @@ -1,5 +1,5 @@ // check-pass -pub enum Foo { +enum Foo { Variant, Variant2(), Variant3{}, From 9a784894eeca79f5878ff4004166d07abeaff8a2 Mon Sep 17 00:00:00 2001 From: Klim Tsoutsman <32662194+tsoutsman@users.noreply.github.com> Date: Sun, 8 Aug 2021 22:35:51 +1000 Subject: [PATCH 08/16] Fix heading colours in Ayu theme Closes #87828 The issue seems to stem from #87210 where code headings were changed from a heading containing code to a heading with the `code-header` class. `rustdoc.css` was updated, but `ayu.css` was missed. --- src/librustdoc/html/static/css/themes/ayu.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index 849924ea5501e..8dd7b2b3edc40 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -37,7 +37,7 @@ h4 { .docblock code { color: #ffb454; } -h3 > code, h4 > code, h5 > code { +.code-header { color: #e6e1cf; } pre > code { From a4af0401dd39a5f10da4e386bd68524b35071783 Mon Sep 17 00:00:00 2001 From: Klim Tsoutsman Date: Mon, 9 Aug 2021 00:10:03 +1000 Subject: [PATCH 09/16] Clarify terms in rustdoc book Change code blocks to Rust --- src/doc/rustdoc/src/documentation-tests.md | 46 +++++++++++----------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md index cb7b85655b5a8..70900a0bab942 100644 --- a/src/doc/rustdoc/src/documentation-tests.md +++ b/src/doc/rustdoc/src/documentation-tests.md @@ -297,9 +297,14 @@ we can add the `#[macro_use]` attribute. Second, we’ll need to add our own ## Attributes -There are a few annotations that are useful to help `rustdoc` do the right +Code blocks can be annotated with attributes that help `rustdoc` do the right thing when testing your code: +The `ignore` attribute tells Rust to ignore your code. This is almost never +what you want as it's the most generic. Instead, consider annotating it +with `text` if it's not code or using `#`s to get a working example that +only shows the part you care about. + ```rust /// ```ignore /// fn foo() { @@ -307,10 +312,8 @@ thing when testing your code: # fn foo() {} ``` -The `ignore` directive tells Rust to ignore your code. This is almost never -what you want, as it's the most generic. Instead, consider annotating it -with `text` if it's not code, or using `#`s to get a working example that -only shows the part you care about. +`should_panic` tells `rustdoc` that the code should compile correctly but +panic during execution. If the code doesn't panic, the test will fail. ```rust /// ```should_panic @@ -319,8 +322,10 @@ only shows the part you care about. # fn foo() {} ``` -`should_panic` tells `rustdoc` that the code should compile correctly, but -not actually pass as a test. +The `no_run` attribute will compile your code but not run it. This is +important for examples such as "Here's how to retrieve a web page," +which you would want to ensure compiles, but might be run in a test +environment that has no network access. ```rust /// ```no_run @@ -331,24 +336,24 @@ not actually pass as a test. # fn foo() {} ``` -The `no_run` attribute will compile your code, but not run it. This is -important for examples such as "Here's how to retrieve a web page," -which you would want to ensure compiles, but might be run in a test -environment that has no network access. +`compile_fail` tells `rustdoc` that the compilation should fail. If it +compiles, then the test will fail. However, please note that code failing +with the current Rust release may work in a future release, as new features +are added. -```text +```rust /// ```compile_fail /// let x = 5; /// x += 2; // shouldn't compile! /// ``` +# fn foo() {} ``` -`compile_fail` tells `rustdoc` that the compilation should fail. If it -compiles, then the test will fail. However please note that code failing -with the current Rust release may work in a future release, as new features -are added. +`edition2018` tells `rustdoc` that the code sample should be compiled using +the 2018 edition of Rust. Similarly, you can specify `edition2015` to compile +the code with the 2015 edition. -```text +```rust /// Only runs on the 2018 edition. /// /// ```edition2018 @@ -358,12 +363,9 @@ are added. /// + "3".parse::()? /// }; /// ``` +# fn foo() {} ``` -`edition2018` tells `rustdoc` that the code sample should be compiled using -the 2018 edition of Rust. Similarly, you can specify `edition2015` to compile -the code with the 2015 edition. - ## Syntax reference The *exact* syntax for code blocks, including the edge cases, can be found @@ -385,7 +387,7 @@ section. However, it's preferable to use fenced code blocks over indented code blocks. Not only are fenced code blocks considered more idiomatic for Rust code, -but there is no way to use directives such as `ignore` or `should_panic` with +but there is no way to use attributes such as `ignore` or `should_panic` with indented code blocks. ### Include items only when collecting doctests From f93cbedadec03e5d4d6733e0756d87b6eb706a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 6 Aug 2021 02:36:54 -0700 Subject: [PATCH 10/16] Do not ICE on HIR based WF check when involving lifetimes Fix #87549. --- .../src/traits/error_reporting/mod.rs | 7 +++-- src/test/ui/wf/hir-wf-check-erase-regions.rs | 14 +++++++++ .../ui/wf/hir-wf-check-erase-regions.stderr | 31 +++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/wf/hir-wf-check-erase-regions.rs create mode 100644 src/test/ui/wf/hir-wf-check-erase-regions.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 3f713ce3c3914..ac07cc1f03439 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -245,9 +245,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if let ObligationCauseCode::WellFormed(Some(wf_loc)) = root_obligation.cause.code.peel_derives() { - if let Some(cause) = - self.tcx.diagnostic_hir_wf_check((obligation.predicate, wf_loc.clone())) - { + if let Some(cause) = self.tcx.diagnostic_hir_wf_check(( + tcx.erase_regions(obligation.predicate), + wf_loc.clone(), + )) { obligation.cause = cause; span = obligation.cause.span; } diff --git a/src/test/ui/wf/hir-wf-check-erase-regions.rs b/src/test/ui/wf/hir-wf-check-erase-regions.rs new file mode 100644 index 0000000000000..bb398e5698a80 --- /dev/null +++ b/src/test/ui/wf/hir-wf-check-erase-regions.rs @@ -0,0 +1,14 @@ +// Regression test for #87549. +// compile-flags: -C incremental=tmp/wf/hir-wf-check-erase-regions + +pub struct Table([Option; N]); + +impl<'a, T, const N: usize> IntoIterator for &'a Table { + type IntoIter = std::iter::Flatten>; //~ ERROR `&T` is not an iterator + type Item = &'a T; + + fn into_iter(self) -> Self::IntoIter { //~ ERROR `&T` is not an iterator + unimplemented!() + } +} +fn main() {} diff --git a/src/test/ui/wf/hir-wf-check-erase-regions.stderr b/src/test/ui/wf/hir-wf-check-erase-regions.stderr new file mode 100644 index 0000000000000..a704754e82a92 --- /dev/null +++ b/src/test/ui/wf/hir-wf-check-erase-regions.stderr @@ -0,0 +1,31 @@ +error[E0277]: `&T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:7:5 + | +LL | type IntoIter = std::iter::Flatten>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&T` is not an iterator + | + ::: $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL + | +LL | pub struct Flatten> { + | ------------ required by this bound in `Flatten` + | + = help: the trait `Iterator` is not implemented for `&T` + = note: required because of the requirements on the impl of `IntoIterator` for `&T` + +error[E0277]: `&T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:10:27 + | +LL | fn into_iter(self) -> Self::IntoIter { + | ^^^^^^^^^^^^^^ `&T` is not an iterator + | + ::: $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL + | +LL | pub struct Flatten> { + | ------------ required by this bound in `Flatten` + | + = help: the trait `Iterator` is not implemented for `&T` + = note: required because of the requirements on the impl of `IntoIterator` for `&T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. From cb19d836dc63a4e3c6cb3ac3b419097d8f5d87ff Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Mon, 9 Aug 2021 16:09:11 +0200 Subject: [PATCH 11/16] Proper table row formatting in platform support Also moves the target into alphabetical order --- src/doc/rustc/src/platform-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index b265760dc5757..e344bf75bbb43 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -115,6 +115,7 @@ The `std` column in the table below has the following meanings: target | std | notes -------|:---:|------- `aarch64-apple-ios` | ✓ | ARM64 iOS +[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | Apple iOS Simulator on ARM64 `aarch64-fuchsia` | ✓ | ARM64 Fuchsia `aarch64-linux-android` | ✓ | ARM64 Android `aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat @@ -165,7 +166,6 @@ target | std | notes `wasm32-unknown-unknown` | ✓ | WebAssembly `wasm32-wasi` | ✓ | WebAssembly with WASI `x86_64-apple-ios` | ✓ | 64-bit x86 iOS -[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | | Apple iOS Simulator on ARM64 `x86_64-fortanix-unknown-sgx` | ✓ | [Fortanix ABI] for 64-bit Intel SGX `x86_64-fuchsia` | ✓ | 64-bit Fuchsia `x86_64-linux-android` | ✓ | 64-bit x86 Android From bc4ce79764f6519ee9f1469fb3fddcc3f70b8e14 Mon Sep 17 00:00:00 2001 From: Chase Wilson Date: Fri, 30 Jul 2021 13:11:25 -0500 Subject: [PATCH 12/16] Added the `Option::unzip()` method --- library/core/src/option.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index d4e9c384f9302..57553865bd015 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1399,6 +1399,31 @@ impl Option { } } +impl Option<(T, U)> { + /// Unzips an option containing a tuple of two options + /// + /// If `self` is `Some((a, b))` this method returns `(Some(a), Some(b))`. + /// Otherwise, `(None, None)` is returned. + /// + /// # Examples + /// + /// ``` + /// let x = Some((1, "hi")); + /// let y = None::<(u8, u32)>; + /// + /// assert_eq!(x.unzip(), (Some(1), Some("hi"))); + /// assert_eq!(y.unzip(), (None, None)); + /// ``` + #[inline] + #[unstable(feature = "unzip_option", issue = "none", reason = "recently added")] + pub const fn unzip(self) -> (Option, Option) { + match self { + Some((a, b)) => (Some(a), Some(b)), + None => (None, None), + } + } +} + impl Option<&T> { /// Maps an `Option<&T>` to an `Option` by copying the contents of the /// option. From eea3520a8fc1c4a03626ee4f9d74b6d9833db54c Mon Sep 17 00:00:00 2001 From: Chase Wilson Date: Fri, 30 Jul 2021 13:13:59 -0500 Subject: [PATCH 13/16] Added some basic tests for `Option::unzip()` and `Option::zip()` (I noticed that zip had no tests) --- library/core/tests/option.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/library/core/tests/option.rs b/library/core/tests/option.rs index 88ea15a3b33fa..cd8fdebe36a05 100644 --- a/library/core/tests/option.rs +++ b/library/core/tests/option.rs @@ -399,7 +399,7 @@ fn test_unwrap_drop() { } #[test] -pub fn option_ext() { +fn option_ext() { let thing = "{{ f }}"; let f = thing.find("{{"); @@ -407,3 +407,35 @@ pub fn option_ext() { println!("None!"); } } + +#[test] +fn zip_options() { + let x = Some(10); + let y = Some("foo"); + let z: Option = None; + + assert_eq!(x.zip(y), Some((10, "foo"))); + assert_eq!(x.zip(z), None); + assert_eq!(z.zip(x), None); +} + +#[test] +fn unzip_options() { + let x = Some((10, "foo")); + let y = None::<(bool, i32)>; + + assert_eq!(x.unzip(), (Some(10), Some("foo"))); + assert_eq!(y.unzip(), (None, None)); +} + +#[test] +fn zip_unzip_roundtrip() { + let x = Some(10); + let y = Some("foo"); + + let z = x.zip(y); + assert_eq!(z, Some((10, "foo"))); + + let a = z.unzip(); + assert_eq!(a, (x, y)); +} From 9d8081e8b6e4082ed06bd984cd59ccf39741c9b7 Mon Sep 17 00:00:00 2001 From: Chase Wilson Date: Sat, 31 Jul 2021 18:16:34 -0500 Subject: [PATCH 14/16] Enabled unzip_option feature for core tests & unzip docs --- library/core/src/option.rs | 2 ++ library/core/tests/lib.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 57553865bd015..d65915cdc71e0 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1408,6 +1408,8 @@ impl Option<(T, U)> { /// # Examples /// /// ``` + /// #![feature(unzip_option)] + /// /// let x = Some((1, "hi")); /// let y = None::<(u8, u32)>; /// diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index c7756a503c3e9..cc3527f98ec65 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -66,6 +66,7 @@ #![feature(slice_group_by)] #![feature(trusted_random_access)] #![feature(unsize)] +#![feature(unzip_option)] #![deny(unsafe_op_in_unsafe_fn)] extern crate test; From ab2c5902ca404cb21fc9fa8bd6f5c52f33d92949 Mon Sep 17 00:00:00 2001 From: Chase Wilson Date: Thu, 5 Aug 2021 12:44:22 -0500 Subject: [PATCH 15/16] Added tracking issue to unstable attribute --- library/core/src/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index d65915cdc71e0..3f9f04606b36a 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1417,7 +1417,7 @@ impl Option<(T, U)> { /// assert_eq!(y.unzip(), (None, None)); /// ``` #[inline] - #[unstable(feature = "unzip_option", issue = "none", reason = "recently added")] + #[unstable(feature = "unzip_option", issue = "87800", reason = "recently added")] pub const fn unzip(self) -> (Option, Option) { match self { Some((a, b)) => (Some(a), Some(b)), From c046d62d756c08473db458cad3c8203ce98b25a4 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Fri, 6 Aug 2021 15:46:20 +0000 Subject: [PATCH 16/16] Use a more accurate span on assoc types WF checks --- compiler/rustc_typeck/src/check/wfcheck.rs | 18 ++++++++++-------- .../defaults-cyclic-fail-1.stderr | 8 ++++---- .../defaults-cyclic-fail-2.stderr | 8 ++++---- .../projection-bound-cycle-generic.stderr | 4 ++-- .../projection-bound-cycle.stderr | 4 ++-- src/test/ui/issues/issue-21946.stderr | 4 ++-- src/test/ui/issues/issue-23122-1.stderr | 4 ++-- src/test/ui/issues/issue-23122-2.stderr | 4 ++-- ...ons-outlives-nominal-type-region-rev.stderr | 4 ++-- ...regions-outlives-nominal-type-region.stderr | 4 ++-- ...gions-outlives-nominal-type-type-rev.stderr | 4 ++-- .../regions-outlives-nominal-type-type.stderr | 4 ++-- .../regions-struct-not-wf.stderr | 12 ++++++------ src/test/ui/specialization/issue-51892.stderr | 4 ++-- .../wf/wf-impl-associated-type-region.stderr | 4 ++-- .../ui/wf/wf-outlives-ty-in-fn-or-trait.stderr | 8 ++++---- .../wf/wf-trait-associated-type-region.stderr | 4 ++-- 17 files changed, 52 insertions(+), 50 deletions(-) diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index e33cc603b5e54..b824370965928 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -194,12 +194,13 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let trait_item = tcx.hir().expect_trait_item(hir_id); - let method_sig = match trait_item.kind { - hir::TraitItemKind::Fn(ref sig, _) => Some(sig), - _ => None, + let (method_sig, span) = match trait_item.kind { + hir::TraitItemKind::Fn(ref sig, _) => (Some(sig), trait_item.span), + hir::TraitItemKind::Type(_bounds, Some(ty)) => (None, ty.span), + _ => (None, trait_item.span), }; check_object_unsafe_self_trait_by_name(tcx, &trait_item); - check_associated_item(tcx, trait_item.hir_id(), trait_item.span, method_sig); + check_associated_item(tcx, trait_item.hir_id(), span, method_sig); } fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool { @@ -268,12 +269,13 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let impl_item = tcx.hir().expect_impl_item(hir_id); - let method_sig = match impl_item.kind { - hir::ImplItemKind::Fn(ref sig, _) => Some(sig), - _ => None, + let (method_sig, span) = match impl_item.kind { + hir::ImplItemKind::Fn(ref sig, _) => (Some(sig), impl_item.span), + hir::ImplItemKind::TyAlias(ty) => (None, ty.span), + _ => (None, impl_item.span), }; - check_associated_item(tcx, impl_item.hir_id(), impl_item.span, method_sig); + check_associated_item(tcx, impl_item.hir_id(), span, method_sig); } fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr index 5e98520b41187..008eddcb29dbc 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr @@ -1,14 +1,14 @@ error[E0275]: overflow evaluating the requirement `::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:26:5 + --> $DIR/defaults-cyclic-fail-1.rs:26:14 | LL | type A = Box; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ error[E0275]: overflow evaluating the requirement `::A == _` - --> $DIR/defaults-cyclic-fail-1.rs:32:5 + --> $DIR/defaults-cyclic-fail-1.rs:32:14 | LL | type B = &'static Self::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr index c538805f85821..d0fbab077153f 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr @@ -1,14 +1,14 @@ error[E0275]: overflow evaluating the requirement `::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:27:5 + --> $DIR/defaults-cyclic-fail-2.rs:27:14 | LL | type A = Box; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ error[E0275]: overflow evaluating the requirement `::A == _` - --> $DIR/defaults-cyclic-fail-2.rs:33:5 + --> $DIR/defaults-cyclic-fail-2.rs:33:14 | LL | type B = &'static Self::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr index d5e9caf9ecd4e..345e2b3fcb12c 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr @@ -1,11 +1,11 @@ error[E0275]: overflow evaluating the requirement `::Item: Sized` - --> $DIR/projection-bound-cycle-generic.rs:44:5 + --> $DIR/projection-bound-cycle-generic.rs:44:18 | LL | struct OnlySized where T: Sized { f: T } | - required by this bound in `OnlySized` ... LL | type Assoc = OnlySized<::Item>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr index fac62fef1ecff..eefc09fa78863 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr @@ -1,11 +1,11 @@ error[E0275]: overflow evaluating the requirement `::Item: Sized` - --> $DIR/projection-bound-cycle.rs:46:5 + --> $DIR/projection-bound-cycle.rs:46:18 | LL | struct OnlySized where T: Sized { f: T } | - required by this bound in `OnlySized` ... LL | type Assoc = OnlySized<::Item>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21946.stderr b/src/test/ui/issues/issue-21946.stderr index 0497bd20469a0..67f6b3081bb30 100644 --- a/src/test/ui/issues/issue-21946.stderr +++ b/src/test/ui/issues/issue-21946.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `::A == _` - --> $DIR/issue-21946.rs:8:5 + --> $DIR/issue-21946.rs:8:14 | LL | type A = ::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23122-1.stderr b/src/test/ui/issues/issue-23122-1.stderr index 8613c1ef8c201..0b568b30e08d8 100644 --- a/src/test/ui/issues/issue-23122-1.stderr +++ b/src/test/ui/issues/issue-23122-1.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement ` as Next>::Next == _` - --> $DIR/issue-23122-1.rs:10:5 + --> $DIR/issue-23122-1.rs:10:17 | LL | type Next = as Next>::Next; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index 5008a499986d4..68a95dc265e82 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:9:5 + --> $DIR/issue-23122-2.rs:9:17 | LL | type Next = as Next>::Next; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr index dfa44008ad784..09b51fe056870 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:9 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:20 | LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined on the impl at 16:10 --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:10 diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr index 3561379138b9b..957a9d6dd3c12 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region.rs:17:9 + --> $DIR/regions-outlives-nominal-type-region.rs:17:20 | LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined on the impl at 16:10 --> $DIR/regions-outlives-nominal-type-region.rs:16:10 diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr index 207686defa1ac..1589f93d90c8e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:9 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:20 | LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined on the impl at 16:10 --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:10 diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr index c1c4e78f785c3..4bfaa1aac782a 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type.rs:17:9 + --> $DIR/regions-outlives-nominal-type-type.rs:17:20 | LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined on the impl at 16:10 --> $DIR/regions-outlives-nominal-type-type.rs:16:10 diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr index 71caeefabac34..1b1a2f7b043b7 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -1,18 +1,18 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:13:5 + --> $DIR/regions-struct-not-wf.rs:13:16 | LL | impl<'a, T> Trait<'a, T> for usize { | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = &'a T; - | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:21:5 + --> $DIR/regions-struct-not-wf.rs:21:16 | LL | impl<'a, T> Trait<'a, T> for u32 { | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | note: ...that is required by this bound --> $DIR/regions-struct-not-wf.rs:16:20 @@ -21,10 +21,10 @@ LL | struct RefOk<'a, T:'a> { | ^^ error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:25:5 + --> $DIR/regions-struct-not-wf.rs:25:16 | LL | type Out = &'a &'b T; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined on the impl at 24:6 --> $DIR/regions-struct-not-wf.rs:24:6 diff --git a/src/test/ui/specialization/issue-51892.stderr b/src/test/ui/specialization/issue-51892.stderr index 2d30164380a8e..10a39a4914770 100644 --- a/src/test/ui/specialization/issue-51892.stderr +++ b/src/test/ui/specialization/issue-51892.stderr @@ -1,8 +1,8 @@ error: unconstrained generic constant - --> $DIR/issue-51892.rs:15:5 + --> $DIR/issue-51892.rs:15:17 | LL | type Type = [u8; std::mem::size_of::<::Type>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<::Type>()]:` diff --git a/src/test/ui/wf/wf-impl-associated-type-region.stderr b/src/test/ui/wf/wf-impl-associated-type-region.stderr index f3b32ad3f7e85..3f324190b7b6b 100644 --- a/src/test/ui/wf/wf-impl-associated-type-region.stderr +++ b/src/test/ui/wf/wf-impl-associated-type-region.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-impl-associated-type-region.rs:10:5 + --> $DIR/wf-impl-associated-type-region.rs:10:16 | LL | impl<'a, T> Foo<'a> for T { | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Bar = &'a T; - | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at error: aborting due to previous error diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index 4c25ab9593958..68c1e9091d753 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -1,18 +1,18 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:16 | LL | impl<'a, T> Trait<'a, T> for usize { | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = &'a fn(T); - | ^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at + | ^^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:16 | LL | impl<'a, T> Trait<'a, T> for u32 { | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = &'a dyn Baz; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'a (dyn Baz + 'a)` does not outlive the data it points at + | ^^^^^^^^^^^^^^ ...so that the reference type `&'a (dyn Baz + 'a)` does not outlive the data it points at error: aborting due to 2 previous errors diff --git a/src/test/ui/wf/wf-trait-associated-type-region.stderr b/src/test/ui/wf/wf-trait-associated-type-region.stderr index ae681ba6c9bb5..6e2cc8aba4b72 100644 --- a/src/test/ui/wf/wf-trait-associated-type-region.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-region.stderr @@ -1,8 +1,8 @@ error[E0309]: the associated type `>::Type1` may not live long enough - --> $DIR/wf-trait-associated-type-region.rs:9:5 + --> $DIR/wf-trait-associated-type-region.rs:9:18 | LL | type Type2 = &'a Self::Type1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `>::Type1: 'a`... = note: ...so that the reference type `&'a >::Type1` does not outlive the data it points at