From 64cf7ad75fe90ed293f443c13062e8a74b755f8d Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Wed, 24 Mar 2021 06:15:03 +0100 Subject: [PATCH 1/8] Update RELEASES.md - `Div` and `Rem` by their `NonZero` variant is now implemented for all unsigned integers. - stabilization of `deque_range` - deprecation of `spin_loop_hint` --- RELEASES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 3cd253afbcd..21aef444a47 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -50,6 +50,8 @@ Libraries - [`io::Empty` now implements `io::Seek`.][78044] - [`rc::Weak` and `sync::Weak`'s methods such as `as_ptr` are now implemented for `T: ?Sized` types.][80764] +- [`Div` and `Rem` by their `NonZero` variant is now implemented for all unsigned integers.][79134] + Stabilized APIs --------------- @@ -72,6 +74,8 @@ Stabilized APIs - [`str::split_inclusive`] - [`sync::OnceState`] - [`task::Wake`] +- [`VecDeque::range`] +- [`VecDeque::range_mut`] Cargo ----- @@ -115,6 +119,7 @@ Compatibility Notes - `thumbv7neon-unknown-linux-gnueabihf` - `armv7-unknown-linux-gnueabi` - `x86_64-unknown-linux-gnux32` +- [`atomic::spin_loop_hint` has been deprecated.][80966] It's recommended to use `hint::spin_loop` instead. Internal Only ------------- @@ -145,6 +150,8 @@ Internal Only [80764]: https://github.com/rust-lang/rust/pull/80764 [80749]: https://github.com/rust-lang/rust/pull/80749 [80662]: https://github.com/rust-lang/rust/pull/80662 +[79134]: https://github.com/rust-lang/rust/pull/79134 +[80966]: https://github.com/rust-lang/rust/pull/80966 [cargo/8997]: https://github.com/rust-lang/cargo/pull/8997 [cargo/9112]: https://github.com/rust-lang/cargo/pull/9112 [feature-resolver@2.0]: https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2 @@ -166,6 +173,8 @@ Internal Only [`Seek::stream_position`]: https://doc.rust-lang.org/nightly/std/io/trait.Seek.html#method.stream_position [`Peekable::next_if`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if [`Peekable::next_if_eq`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if_eq +[`VecDeque::range`]: https://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.range +[`VecDeque::range_mut`]: https://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.range_mut Version 1.50.0 (2021-02-11) ============================ From 58218f6c27843f57a26fb861ca9b4c3e006cb285 Mon Sep 17 00:00:00 2001 From: Jacob Hughes Date: Wed, 31 Mar 2021 12:11:36 -0400 Subject: [PATCH 2/8] Remove T: Debug bound on UnsafeCell Debug impl --- library/core/src/fmt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index d696ffa8277..59493bb0425 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2268,7 +2268,7 @@ fn fmt(&self, f: &mut Formatter<'_>) -> Result { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl Debug for UnsafeCell { +impl Debug for UnsafeCell { fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.pad("UnsafeCell") } From 7baeaa95e274662b248428b738fd57e6e9f1a97d Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Mon, 12 Apr 2021 00:01:31 -0700 Subject: [PATCH 3/8] Stabilize BTree{Map,Set}::retain --- library/alloc/src/collections/btree/map.rs | 3 +-- library/alloc/src/collections/btree/set.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index a0dbb289252..971244718b4 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -940,7 +940,6 @@ pub fn remove_entry(&mut self, key: &Q) -> Option<(K, V)> /// # Examples /// /// ``` - /// #![feature(btree_retain)] /// use std::collections::BTreeMap; /// /// let mut map: BTreeMap = (0..8).map(|x| (x, x*10)).collect(); @@ -949,7 +948,7 @@ pub fn remove_entry(&mut self, key: &Q) -> Option<(K, V)> /// assert!(map.into_iter().eq(vec![(0, 0), (2, 20), (4, 40), (6, 60)])); /// ``` #[inline] - #[unstable(feature = "btree_retain", issue = "79025")] + #[stable(feature = "btree_retain", since = "1.53.0")] pub fn retain(&mut self, mut f: F) where K: Ord, diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index a331b8d8e4b..737932d931c 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -851,7 +851,6 @@ pub fn take(&mut self, value: &Q) -> Option /// # Examples /// /// ``` - /// #![feature(btree_retain)] /// use std::collections::BTreeSet; /// /// let xs = [1, 2, 3, 4, 5, 6]; @@ -860,7 +859,7 @@ pub fn take(&mut self, value: &Q) -> Option /// set.retain(|&k| k % 2 == 0); /// assert!(set.iter().eq([2, 4, 6].iter())); /// ``` - #[unstable(feature = "btree_retain", issue = "79025")] + #[stable(feature = "btree_retain", since = "1.53.0")] pub fn retain(&mut self, mut f: F) where T: Ord, From d1e23b8af8615a0b0bbb22f11674b977d2ecdd54 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 11 Apr 2021 11:24:17 +0200 Subject: [PATCH 4/8] Stabilize duration_zero. --- library/core/src/time.rs | 7 ++----- library/core/tests/lib.rs | 1 - library/std/src/lib.rs | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 2219353b055..f6d480ae54b 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -124,14 +124,13 @@ impl Duration { /// # Examples /// /// ``` - /// #![feature(duration_zero)] /// use std::time::Duration; /// /// let duration = Duration::ZERO; /// assert!(duration.is_zero()); /// assert_eq!(duration.as_nanos(), 0); /// ``` - #[unstable(feature = "duration_zero", issue = "73544")] + #[stable(feature = "duration_zero", since = "1.53.0")] pub const ZERO: Duration = Duration::from_nanos(0); /// The maximum duration. @@ -269,7 +268,6 @@ pub const fn from_nanos(nanos: u64) -> Duration { /// # Examples /// /// ``` - /// #![feature(duration_zero)] /// use std::time::Duration; /// /// assert!(Duration::ZERO.is_zero()); @@ -281,7 +279,7 @@ pub const fn from_nanos(nanos: u64) -> Duration { /// assert!(!Duration::from_nanos(1).is_zero()); /// assert!(!Duration::from_secs(1).is_zero()); /// ``` - #[unstable(feature = "duration_zero", issue = "73544")] + #[stable(feature = "duration_zero", since = "1.53.0")] #[inline] pub const fn is_zero(&self) -> bool { self.secs == 0 && self.nanos == 0 @@ -536,7 +534,6 @@ pub const fn checked_sub(self, rhs: Duration) -> Option { /// # Examples /// /// ``` - /// #![feature(duration_zero)] /// use std::time::Duration; /// /// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1)); diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 3e5e5f32609..4b52cc5aec1 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -24,7 +24,6 @@ #![feature(div_duration)] #![feature(duration_consts_2)] #![feature(duration_constants)] -#![feature(duration_zero)] #![feature(exact_size_is_empty)] #![feature(extern_types)] #![feature(flt2dec)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 91695ced6a9..d532bc076e0 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -261,7 +261,6 @@ #![cfg_attr(not(bootstrap), feature(doc_notable_trait))] #![feature(dropck_eyepatch)] #![feature(duration_constants)] -#![feature(duration_zero)] #![feature(edition_panic)] #![feature(exact_size_is_empty)] #![feature(exhaustive_patterns)] From b44ae964e2086b280a250dea62abad29164eea58 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 11 Apr 2021 11:36:35 +0200 Subject: [PATCH 5/8] Mark Duration::is_zero as rustc_const_stable. --- library/core/src/time.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index f6d480ae54b..fa6a6c2cccc 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -280,6 +280,7 @@ pub const fn from_nanos(nanos: u64) -> Duration { /// assert!(!Duration::from_secs(1).is_zero()); /// ``` #[stable(feature = "duration_zero", since = "1.53.0")] + #[rustc_const_stable(feature = "duration_zero", since = "1.53.0")] #[inline] pub const fn is_zero(&self) -> bool { self.secs == 0 && self.nanos == 0 From dd54459bfc7be527bc5dcca6c2724593e2ae7830 Mon Sep 17 00:00:00 2001 From: b-naber Date: Mon, 12 Apr 2021 19:14:51 +0200 Subject: [PATCH 6/8] don't bump in check_mistyped_turbofish_with_multiple_type_params --- .../rustc_parse/src/parser/diagnostics.rs | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 77e85c06ff5..70a5ac6f15e 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -666,21 +666,23 @@ pub(super) fn check_mistyped_turbofish_with_multiple_type_params( ); match x { Ok((_, _, false)) => { - self.bump(); // `>` - match self.parse_expr() { - Ok(_) => { - e.span_suggestion_verbose( - binop.span.shrink_to_lo(), - TURBOFISH_SUGGESTION_STR, - "::".to_string(), - Applicability::MaybeIncorrect, - ); - e.emit(); - *expr = self.mk_expr_err(expr.span.to(self.prev_token.span)); - return Ok(()); - } - Err(mut err) => { - err.cancel(); + if self.eat(&token::Gt) { + match self.parse_expr() { + Ok(_) => { + e.span_suggestion_verbose( + binop.span.shrink_to_lo(), + TURBOFISH_SUGGESTION_STR, + "::".to_string(), + Applicability::MaybeIncorrect, + ); + e.emit(); + *expr = + self.mk_expr_err(expr.span.to(self.prev_token.span)); + return Ok(()); + } + Err(mut err) => { + err.cancel(); + } } } } From 4dfaa784332f0fee3e64a75602fd44ad10527dff Mon Sep 17 00:00:00 2001 From: b-naber Date: Mon, 12 Apr 2021 21:06:11 +0200 Subject: [PATCH 7/8] add test --- src/test/ui/parser/issue-84117.rs | 9 +++++ src/test/ui/parser/issue-84117.stderr | 49 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/test/ui/parser/issue-84117.rs create mode 100644 src/test/ui/parser/issue-84117.stderr diff --git a/src/test/ui/parser/issue-84117.rs b/src/test/ui/parser/issue-84117.rs new file mode 100644 index 00000000000..0f200735915 --- /dev/null +++ b/src/test/ui/parser/issue-84117.rs @@ -0,0 +1,9 @@ +fn main() { + let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + //~^ ERROR expected one of `>`, a const expression + //~| ERROR expected one of `>`, a const expression, lifetime, or type, found `}` + //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` + //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` + //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` +} +//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `}` diff --git a/src/test/ui/parser/issue-84117.stderr b/src/test/ui/parser/issue-84117.stderr new file mode 100644 index 00000000000..d667a4977d0 --- /dev/null +++ b/src/test/ui/parser/issue-84117.stderr @@ -0,0 +1,49 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `}` + --> $DIR/issue-84117.rs:2:67 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ------------ ^ expected one of `>`, a const expression, lifetime, or type + | | | + | | help: use `=` if you meant to assign + | while parsing the type for `inner_local` + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` + --> $DIR/issue-84117.rs:2:65 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ^ expected one of 7 possible tokens + +error: expected one of `,`, `:`, `=`, or `>`, found `}` + --> $DIR/issue-84117.rs:8:1 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ------------ help: use `=` if you meant to assign - expected one of `,`, `:`, `=`, or `>` + | | + | while parsing the type for `outer_local` +... +LL | } + | ^ unexpected token + +error: expected one of `>`, a const expression, lifetime, or type, found `}` + --> $DIR/issue-84117.rs:2:67 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ------------ ^ expected one of `>`, a const expression, lifetime, or type + | | | + | | help: use `=` if you meant to assign + | while parsing the type for `inner_local` + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` + --> $DIR/issue-84117.rs:2:65 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ^ expected one of 7 possible tokens + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` + --> $DIR/issue-84117.rs:2:33 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ^ expected one of 7 possible tokens + +error: aborting due to 6 previous errors + From 1e2635815f851cc3322af84ca1e521afc3763ca9 Mon Sep 17 00:00:00 2001 From: Camelid Date: Mon, 12 Apr 2021 12:33:52 -0700 Subject: [PATCH 8/8] Fix typo in error message Also tweaked the message a bit by - removing the hyphen, because in my opinion the hyphen makes the message a bit harder to read, especially combined with the backticks; - adding the word "be", because I think it's a bit clearer that way. --- compiler/rustc_typeck/src/astconv/generics.rs | 2 +- src/test/ui/const-generics/diagnostics.stderr | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 845375f3e32..7a297f2c65f 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -82,7 +82,7 @@ fn generic_arg_mismatch_err( if param_type.is_suggestable() { err.span_suggestion( tcx.def_span(src_def_id), - "consider changing this type paramater to a `const`-generic", + "consider changing this type parameter to be a `const` generic", format!("const {}: {}", param_name, param_type), Applicability::MaybeIncorrect, ); diff --git a/src/test/ui/const-generics/diagnostics.stderr b/src/test/ui/const-generics/diagnostics.stderr index 7d038ff955d..c8ee6ad61ec 100644 --- a/src/test/ui/const-generics/diagnostics.stderr +++ b/src/test/ui/const-generics/diagnostics.stderr @@ -31,9 +31,12 @@ error[E0747]: type provided when a constant was expected --> $DIR/diagnostics.rs:12:19 | LL | impl Foo for B {} - | - ^ - | | - | help: consider changing this type paramater to a `const`-generic: `const N: u8` + | ^ + | +help: consider changing this type parameter to be a `const` generic + | +LL | impl Foo for B {} + | ^^^^^^^^^^^ error[E0747]: unresolved item provided when a constant was expected --> $DIR/diagnostics.rs:16:32