From 692f63803683534ca7ff1c0a0a5e15cbfc61db0a Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 13 Jul 2021 15:05:29 +0000 Subject: [PATCH 1/9] Fix VecMap Extend impl --- compiler/rustc_data_structures/src/vec_map.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_data_structures/src/vec_map.rs b/compiler/rustc_data_structures/src/vec_map.rs index 73b04d3329cb8..1786fa340cc8b 100644 --- a/compiler/rustc_data_structures/src/vec_map.rs +++ b/compiler/rustc_data_structures/src/vec_map.rs @@ -127,13 +127,15 @@ impl IntoIterator for VecMap { } } -impl Extend<(K, V)> for VecMap { +impl Extend<(K, V)> for VecMap { fn extend>(&mut self, iter: I) { - self.0.extend(iter); + for (k, v) in iter { + self.insert(k, v); + } } - fn extend_one(&mut self, item: (K, V)) { - self.0.extend_one(item); + fn extend_one(&mut self, (k, v): (K, V)) { + self.insert(k, v); } fn extend_reserve(&mut self, additional: usize) { From 95f296db63d58f82a6a96d8b7baf52efaa26b260 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 13 Jul 2021 15:06:09 +0000 Subject: [PATCH 2/9] Debug log all the things --- compiler/rustc_typeck/src/collect/type_of.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index ee84974cb73c2..cfe1a2f56f451 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -509,11 +509,10 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { } } +#[instrument(skip(tcx), level = "debug")] fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { use rustc_hir::{Expr, ImplItem, Item, TraitItem}; - debug!("find_opaque_ty_constraints({:?})", def_id); - struct ConstraintLocator<'tcx> { tcx: TyCtxt<'tcx>, def_id: DefId, @@ -522,13 +521,11 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { } impl ConstraintLocator<'_> { + #[instrument(skip(self), level = "debug")] fn check(&mut self, def_id: LocalDefId) { // Don't try to check items that cannot possibly constrain the type. if !self.tcx.has_typeck_results(def_id) { - debug!( - "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`: no typeck results", - self.def_id, def_id, - ); + debug!("no constraint: no typeck results"); return; } // Calling `mir_borrowck` can lead to cycle errors through @@ -540,10 +537,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { .get_by(|(key, _)| key.def_id == self.def_id) .is_none() { - debug!( - "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`", - self.def_id, def_id, - ); + debug!("no constraints in typeck results"); return; } // Use borrowck to get the type with unerased regions. @@ -603,7 +597,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { if let Some((prev_span, prev_ty)) = self.found { if *concrete_type != prev_ty { - debug!("find_opaque_ty_constraints: span={:?}", span); + debug!(?span); // Found different concrete types for the opaque type. let mut err = self.tcx.sess.struct_span_err( span, From 587e8fd11267911599322878fb37c8d185738c9b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 13 Jul 2021 15:19:35 +0000 Subject: [PATCH 3/9] Loop over all opaque types instead of looking at just the first one with the same DefId --- compiler/rustc_typeck/src/collect/type_of.rs | 20 ++++++++----------- .../ui/type-alias-impl-trait/issue-85113.rs | 1 + .../type-alias-impl-trait/issue-85113.stderr | 14 ++++++++++++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index cfe1a2f56f451..7b0002914eca8 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -542,13 +542,14 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { } // Use borrowck to get the type with unerased regions. let concrete_opaque_types = &self.tcx.mir_borrowck(def_id).concrete_opaque_types; - if let Some((opaque_type_key, concrete_type)) = - concrete_opaque_types.iter().find(|(key, _)| key.def_id == self.def_id) - { - debug!( - "find_opaque_ty_constraints: found constraint for `{:?}` at `{:?}`: {:?}", - self.def_id, def_id, concrete_type, - ); + debug!(?concrete_opaque_types); + for (opaque_type_key, concrete_type) in concrete_opaque_types { + if opaque_type_key.def_id != self.def_id { + // Ignore constraints for other opaque types. + continue; + } + + debug!(?concrete_type, ?opaque_type_key.substs, "found constraint"); // FIXME(oli-obk): trace the actual span from inference to improve errors. let span = self.tcx.def_span(def_id); @@ -613,11 +614,6 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { } else { self.found = Some((span, concrete_type)); } - } else { - debug!( - "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`", - self.def_id, def_id, - ); } } } diff --git a/src/test/ui/type-alias-impl-trait/issue-85113.rs b/src/test/ui/type-alias-impl-trait/issue-85113.rs index b09833f3ed014..0c37399df8dd2 100644 --- a/src/test/ui/type-alias-impl-trait/issue-85113.rs +++ b/src/test/ui/type-alias-impl-trait/issue-85113.rs @@ -12,6 +12,7 @@ trait Output<'a> {} impl<'a> Output<'a> for &'a str {} fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> { + //~^ ERROR: concrete type differs from previous defining opaque type use let out: OpaqueOutputImpl<'a> = arg; arg } diff --git a/src/test/ui/type-alias-impl-trait/issue-85113.stderr b/src/test/ui/type-alias-impl-trait/issue-85113.stderr index 361d66866ef8b..233c996340d84 100644 --- a/src/test/ui/type-alias-impl-trait/issue-85113.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-85113.stderr @@ -10,6 +10,18 @@ note: hidden type `&' str` captures lifetime smaller than the function bo LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a; | ^^^^^^^^^^^^^^^^^^^^ +error: concrete type differs from previous defining opaque type use + --> $DIR/issue-85113.rs:14:1 + | +LL | fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&' str`, got `&'a str` + | +note: previous use here + --> $DIR/issue-85113.rs:14:1 + | +LL | fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0477]: the type `&' str` does not fulfill the required lifetime --> $DIR/issue-85113.rs:5:29 | @@ -42,7 +54,7 @@ LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a; = note: expected `Output<'a>` found `Output<'_>` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0477, E0495, E0700. For more information about an error, try `rustc --explain E0477`. From 1a900042abe4ee9626cd7274816816e9ca691a25 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Thu, 15 Jul 2021 23:47:03 +0200 Subject: [PATCH 4/9] Added diagnostic items to functions for Clippy --- compiler/rustc_span/src/symbol.rs | 9 +++++++++ library/core/src/cmp.rs | 2 ++ library/core/src/iter/sources/repeat.rs | 1 + library/core/src/mem/mod.rs | 6 ++++++ 4 files changed, 18 insertions(+) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9051c9d69b5c1..944e896ba6fd5 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -368,6 +368,8 @@ symbols! { closure, closure_to_fn_coercion, cmp, + cmp_max, + cmp_min, cmpxchg16b_target_feature, cmse_nonsecure_entry, coerce_unsized, @@ -672,6 +674,7 @@ symbols! { item, item_like_imports, iter, + iter_repeat, keyword, kind, kreg, @@ -738,6 +741,12 @@ symbols! { maybe_uninit, maybe_uninit_uninit, maybe_uninit_zeroed, + mem_discriminant, + mem_drop, + mem_forget, + mem_replace, + mem_size_of, + mem_size_of_val, mem_uninitialized, mem_zeroed, member_constraints, diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 879deed3bed5e..79610bb409d37 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1104,6 +1104,7 @@ pub macro PartialOrd($item:item) { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_min")] pub fn min(v1: T, v2: T) -> T { v1.min(v2) } @@ -1166,6 +1167,7 @@ pub fn min_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_max")] pub fn max(v1: T, v2: T) -> T { v1.max(v2) } diff --git a/library/core/src/iter/sources/repeat.rs b/library/core/src/iter/sources/repeat.rs index a9478041c69c4..733142ed01103 100644 --- a/library/core/src/iter/sources/repeat.rs +++ b/library/core/src/iter/sources/repeat.rs @@ -51,6 +51,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "iter_repeat")] pub fn repeat(elt: T) -> Repeat { Repeat { element: elt } } diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 5bf47c3951da2..2c75de39ffa2f 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -140,6 +140,7 @@ pub use crate::intrinsics::transmute; #[inline] #[rustc_const_stable(feature = "const_forget", since = "1.46.0")] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mem_forget")] pub const fn forget(t: T) { let _ = ManuallyDrop::new(t); } @@ -298,6 +299,7 @@ pub fn forget_unsized(t: T) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] #[rustc_const_stable(feature = "const_size_of", since = "1.24.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of")] pub const fn size_of() -> usize { intrinsics::size_of::() } @@ -324,6 +326,7 @@ pub const fn size_of() -> usize { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of_val")] pub const fn size_of_val(val: &T) -> usize { // SAFETY: `val` is a reference, so it's a valid raw pointer unsafe { intrinsics::size_of_val(val) } @@ -814,6 +817,7 @@ pub fn take(dest: &mut T) -> T { #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "if you don't need the old value, you can just assign the new value directly"] #[rustc_const_unstable(feature = "const_replace", issue = "83164")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mem_replace")] pub const fn replace(dest: &mut T, src: T) -> T { // SAFETY: We read from `dest` but directly write `src` into it afterwards, // such that the old value is not duplicated. Nothing is dropped and @@ -888,6 +892,7 @@ pub const fn replace(dest: &mut T, src: T) -> T { /// [`RefCell`]: crate::cell::RefCell #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mem_drop")] pub fn drop(_x: T) {} /// Interprets `src` as having type `&U`, and then reads `src` without moving @@ -1015,6 +1020,7 @@ impl fmt::Debug for Discriminant { /// ``` #[stable(feature = "discriminant_value", since = "1.21.0")] #[rustc_const_unstable(feature = "const_discriminant", issue = "69821")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")] pub const fn discriminant(v: &T) -> Discriminant { Discriminant(intrinsics::discriminant_value(v)) } From d38f2b0cc1c58392fe9736c468e8943fc6472096 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Thu, 15 Jul 2021 23:51:34 +0200 Subject: [PATCH 5/9] Added diagnostic items to structs and traits for Clippy --- compiler/rustc_span/src/symbol.rs | 13 +++++++++++++ library/alloc/src/borrow.rs | 1 + library/alloc/src/collections/btree/map/entry.rs | 1 + library/core/src/any.rs | 1 + library/core/src/convert/mod.rs | 2 ++ library/core/src/iter/traits/double_ended.rs | 1 + library/core/src/time.rs | 1 + library/std/src/collections/hash/map.rs | 1 + library/std/src/fs.rs | 3 +++ library/std/src/io/mod.rs | 2 ++ 10 files changed, 26 insertions(+) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 944e896ba6fd5..fa2afaac37509 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -122,10 +122,14 @@ symbols! { // nice to have. Symbols { Alignment, + Any, Arc, Argument, ArgumentV1, Arguments, + AsMut, + AsRef, + BTreeEntry, BTreeMap, BTreeSet, BinaryHeap, @@ -139,6 +143,7 @@ symbols! { Continue, Copy, Count, + Cow, Debug, DebugStruct, DebugTuple, @@ -146,12 +151,17 @@ symbols! { Decoder, Default, Deref, + DirBuilder, + DoubleEndedIterator, + Duration, Encodable, Encoder, Eq, Equal, Err, Error, + File, + FileType, FormatSpec, Formatter, From, @@ -164,9 +174,12 @@ symbols! { HashMap, HashSet, Hasher, + HashMapEntry, Implied, Input, IntoIterator, + IoRead, + IoWrite, Is, ItemContext, Iterator, diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 9d61b3684b82c..482a497201de6 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -177,6 +177,7 @@ where /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Cow")] pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned, diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs index 6b30d95977395..5fec8dc2d1334 100644 --- a/library/alloc/src/collections/btree/map/entry.rs +++ b/library/alloc/src/collections/btree/map/entry.rs @@ -14,6 +14,7 @@ use Entry::*; /// /// [`entry`]: BTreeMap::entry #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "BTreeEntry")] pub enum Entry<'a, K: 'a, V: 'a> { /// A vacant entry. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 5e1725cfc7a63..19652106b3d01 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -108,6 +108,7 @@ use crate::intrinsics; // unsafe traits and unsafe methods (i.e., `type_id` would still be safe to call, // but we would likely want to indicate as such in documentation). #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Any")] pub trait Any: 'static { /// Gets the `TypeId` of `self`. /// diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 65af8508a6839..1e512af48051e 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -152,6 +152,7 @@ pub const fn identity(x: T) -> T { /// is_hello(s); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")] pub trait AsRef { /// Performs the conversion. #[stable(feature = "rust1", since = "1.0.0")] @@ -193,6 +194,7 @@ pub trait AsRef { /// /// [`Box`]: ../../std/boxed/struct.Box.html #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")] pub trait AsMut { /// Performs the conversion. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index 6d3ab788e5f48..9a9cf20077096 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -36,6 +36,7 @@ use crate::ops::{ControlFlow, Try}; /// assert_eq!(None, iter.next_back()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "DoubleEndedIterator")] pub trait DoubleEndedIterator: Iterator { /// Removes and returns an element from the end of the iterator. /// diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 92a4e60391894..2d8a1cb1ab016 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -61,6 +61,7 @@ const MICROS_PER_SEC: u64 = 1_000_000; /// crate to do so. #[stable(feature = "duration", since = "1.3.0")] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[cfg_attr(not(test), rustc_diagnostic_item = "Duration")] pub struct Duration { secs: u64, nanos: u32, // Always 0 <= nanos < NANOS_PER_SEC diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index d7cb8a556367c..fac285c96f00d 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -1829,6 +1829,7 @@ impl Debug for RawEntryBuilder<'_, K, V, S> { /// /// [`entry`]: HashMap::entry #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "HashMapEntry")] pub enum Entry<'a, K: 'a, V: 'a> { /// An occupied entry. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index a9ce814e2ec18..997b7670ea982 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -88,6 +88,7 @@ use crate::time::SystemTime; /// [`BufReader`]: io::BufReader /// [`sync_all`]: File::sync_all #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "File")] pub struct File { inner: fs_imp::File, } @@ -183,12 +184,14 @@ pub struct Permissions(fs_imp::FilePermissions); /// It is returned by [`Metadata::file_type`] method. #[stable(feature = "file_type", since = "1.1.0")] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +#[cfg_attr(not(test), rustc_diagnostic_item = "FileType")] pub struct FileType(fs_imp::FileType); /// A builder used to create directories in various manners. /// /// This builder also supports platform-specific options. #[stable(feature = "dir_builder", since = "1.6.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "DirBuilder")] #[derive(Debug)] pub struct DirBuilder { inner: fs_imp::DirBuilder, diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 9daeee711adea..714e4cdea0fae 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -514,6 +514,7 @@ pub(crate) fn default_read_exact(this: &mut R, mut buf: &mut [ /// [`File`]: crate::fs::File #[stable(feature = "rust1", since = "1.0.0")] #[doc(notable_trait)] +#[cfg_attr(not(test), rustc_diagnostic_item = "IoRead")] pub trait Read { /// Pull some bytes from this source into the specified buffer, returning /// how many bytes were read. @@ -1361,6 +1362,7 @@ impl Initializer { /// [`write_all`]: Write::write_all #[stable(feature = "rust1", since = "1.0.0")] #[doc(notable_trait)] +#[cfg_attr(not(test), rustc_diagnostic_item = "IoWrite")] pub trait Write { /// Write a buffer into this writer, returning how many bytes were written. /// From 7fc4fc747c90d800989dbe06ec6c5e12661a1f59 Mon Sep 17 00:00:00 2001 From: inquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com> Date: Thu, 15 Jul 2021 16:27:08 -0700 Subject: [PATCH 6/9] Stabilize `[T; N]::map()` --- library/core/src/array/mod.rs | 5 ++--- library/core/tests/lib.rs | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 32d344010aafd..78b799cd70976 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -296,7 +296,6 @@ impl [T; N] { /// # Examples /// /// ``` - /// #![feature(array_map)] /// let x = [1, 2, 3]; /// let y = x.map(|v| v + 1); /// assert_eq!(y, [2, 3, 4]); @@ -310,7 +309,7 @@ impl [T; N] { /// let y = x.map(|v| v.len()); /// assert_eq!(y, [6, 9, 3, 3]); /// ``` - #[unstable(feature = "array_map", issue = "75243")] + #[stable(feature = "array_map", since = "1.55.0")] pub fn map(self, f: F) -> [U; N] where F: FnMut(T) -> U, @@ -377,7 +376,7 @@ impl [T; N] { /// array if its elements are not `Copy`. /// /// ``` - /// #![feature(array_methods, array_map)] + /// #![feature(array_methods)] /// /// let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()]; /// let is_ascii = strings.each_ref().map(|s| s.is_ascii()); diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index cc4ff1be56314..c7756a503c3e9 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -1,7 +1,6 @@ #![feature(alloc_layout_extra)] #![feature(array_chunks)] #![feature(array_methods)] -#![feature(array_map)] #![feature(array_windows)] #![feature(bool_to_option)] #![feature(box_syntax)] From 8841a426e599c8968d9b30b57431333d0b68c592 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 16 Jul 2021 11:54:00 +0800 Subject: [PATCH 7/9] Mark `const_trait_impl` as active --- compiler/rustc_feature/src/active.rs | 2 +- src/test/ui/consts/const-float-classify.rs | 1 - src/test/ui/consts/rustc-impl-const-stability.rs | 1 - src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs | 1 - src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs | 1 - src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr | 6 +++--- .../ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs | 1 - .../ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs | 1 - .../call-const-trait-method-fail.rs | 1 - .../call-const-trait-method-fail.stderr | 2 +- .../call-const-trait-method-pass.rs | 1 - .../rfc-2632-const-trait-impl/call-generic-method-chain.rs | 1 - .../call-generic-method-nonconst.rs | 1 - .../rfc-2632-const-trait-impl/call-generic-method-pass.rs | 1 - .../rfc-2632-const-trait-impl/const-and-non-const-impl.rs | 1 - .../const-and-non-const-impl.stderr | 6 +++--- .../const-check-fns-in-const-impl.rs | 1 - .../const-check-fns-in-const-impl.stderr | 2 +- .../const-default-method-bodies.rs | 1 - .../const-default-method-bodies.stderr | 2 +- .../ui/rfc-2632-const-trait-impl/const-impl-norecover.rs | 1 - .../rfc-2632-const-trait-impl/const-impl-norecover.stderr | 2 +- .../ui/rfc-2632-const-trait-impl/const-impl-recovery.rs | 1 - .../ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr | 4 ++-- .../ui/rfc-2632-const-trait-impl/cross-crate.gated.stderr | 2 +- src/test/ui/rfc-2632-const-trait-impl/cross-crate.rs | 1 - .../ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr | 4 ++-- .../ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr | 2 +- src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs | 1 - .../ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr | 2 +- src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs | 1 - src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs | 1 - .../ui/rfc-2632-const-trait-impl/hir-const-check.stderr | 2 +- .../ui/rfc-2632-const-trait-impl/impl-with-default-fn.rs | 1 - .../rfc-2632-const-trait-impl/impl-with-default-fn.stderr | 6 +++--- src/test/ui/rfc-2632-const-trait-impl/stability.rs | 1 - src/test/ui/rfc-2632-const-trait-impl/stability.stderr | 4 ++-- src/test/ui/rfc-2632-const-trait-impl/syntax.rs | 1 - 38 files changed, 24 insertions(+), 47 deletions(-) diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index ede510b693679..fdb15f6849bc0 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -534,7 +534,7 @@ declare_features! ( (active, bindings_after_at, "1.41.0", Some(65490), None), /// Allows `impl const Trait for T` syntax. - (incomplete, const_trait_impl, "1.42.0", Some(67792), None), + (active, const_trait_impl, "1.42.0", Some(67792), None), /// Allows `T: ?const Trait` syntax in bounds. (incomplete, const_trait_bound_opt_out, "1.42.0", Some(67794), None), diff --git a/src/test/ui/consts/const-float-classify.rs b/src/test/ui/consts/const-float-classify.rs index 95e7f9e9c837a..5d38e032ac408 100644 --- a/src/test/ui/consts/const-float-classify.rs +++ b/src/test/ui/consts/const-float-classify.rs @@ -5,7 +5,6 @@ #![feature(const_float_bits_conv)] #![feature(const_float_classify)] #![feature(const_trait_impl)] -#![allow(incomplete_features)] // Don't promote const fn nop(x: T) -> T { x } diff --git a/src/test/ui/consts/rustc-impl-const-stability.rs b/src/test/ui/consts/rustc-impl-const-stability.rs index 01daa1c9cb42f..e3fda57548ea3 100644 --- a/src/test/ui/consts/rustc-impl-const-stability.rs +++ b/src/test/ui/consts/rustc-impl-const-stability.rs @@ -1,7 +1,6 @@ // build-pass #![crate_type = "lib"] -#![allow(incomplete_features)] #![feature(staged_api)] #![feature(const_trait_impl)] #![stable(feature = "foo", since = "1.0.0")] diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs index 5a66af1d29e94..4a1bd5da98b8a 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs @@ -3,7 +3,6 @@ // FIXME: This test should fail since, within a const impl of `Foo`, the bound on `Foo::Bar` should // require a const impl of `Add` for the associated type. -#![allow(incomplete_features)] #![feature(const_trait_impl)] struct NonConstAdd(i32); diff --git a/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs index 338ac3d250536..be73ec09ceb3b 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![allow(incomplete_features)] #[default_method_body_is_const] //~ ERROR attribute should be applied trait A { diff --git a/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr index 3af71d6ff78fb..fcb7e15b205e9 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr @@ -1,5 +1,5 @@ error: attribute should be applied to a trait method with body - --> $DIR/attr-misuse.rs:4:1 + --> $DIR/attr-misuse.rs:3:1 | LL | #[default_method_body_is_const] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | | } | |_- not a trait method or missing a body error: attribute should be applied to a trait method with body - --> $DIR/attr-misuse.rs:13:1 + --> $DIR/attr-misuse.rs:12:1 | LL | #[default_method_body_is_const] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | fn main() {} | ------------ not a trait method or missing a body error: attribute should be applied to a trait method with body - --> $DIR/attr-misuse.rs:6:5 + --> $DIR/attr-misuse.rs:5:5 | LL | #[default_method_body_is_const] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs index 4285eaf18aaad..d8fd7ef3c1f44 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![allow(incomplete_features)] pub trait MyTrait { fn func(self); diff --git a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs index 734ce17001edd..80e61ab0a9e8b 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![allow(incomplete_features)] #![feature(staged_api)] #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs index fa5570d5454a0..33e839fd1203d 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(const_trait_impl)] pub trait Plus { diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr index d3f350e1b61db..5a73c4debb481 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr @@ -1,5 +1,5 @@ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/call-const-trait-method-fail.rs:25:5 + --> $DIR/call-const-trait-method-fail.rs:24:5 | LL | a.plus(b) | ^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs index 44814b0654e91..cf38bc3c96453 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs @@ -1,6 +1,5 @@ // run-pass -#![allow(incomplete_features)] #![feature(const_trait_impl)] struct Int(i32); diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs index 47eed89d03d2d..f3391aa63468c 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs @@ -4,7 +4,6 @@ #![feature(const_trait_impl)] #![feature(const_fn_trait_bound)] -#![allow(incomplete_features)] struct S; diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs index 9aefe6380cb18..087f8fbdcd1ea 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs @@ -2,7 +2,6 @@ // ignore-test #![feature(const_trait_impl)] -#![allow(incomplete_features)] struct S; diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs index 953a65111990e..aee88d6053eee 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs @@ -4,7 +4,6 @@ #![feature(const_trait_impl)] #![feature(const_fn_trait_bound)] -#![allow(incomplete_features)] struct S; diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs index e148ad9a0ee14..4b2f049b99d9e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(const_trait_impl)] pub struct Int(i32); diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr index 99560ed06888a..a0960a21d46f8 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `std::ops::Add` for type `i32` - --> $DIR/const-and-non-const-impl.rs:6:1 + --> $DIR/const-and-non-const-impl.rs:5:1 | LL | impl const std::ops::Add for i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | impl const std::ops::Add for i32 { - impl Add for i32; error[E0119]: conflicting implementations of trait `std::ops::Add` for type `Int` - --> $DIR/const-and-non-const-impl.rs:24:1 + --> $DIR/const-and-non-const-impl.rs:23:1 | LL | impl std::ops::Add for Int { | -------------------------- first implementation here @@ -17,7 +17,7 @@ LL | impl const std::ops::Add for Int { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/const-and-non-const-impl.rs:6:1 + --> $DIR/const-and-non-const-impl.rs:5:1 | LL | impl const std::ops::Add for i32 { | ^^^^^^^^^^^-------------^^^^^--- diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs index fc85e98ef5326..3a7074163523b 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(const_trait_impl)] struct S; diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr index c6c78c7d1e895..aaec67161a6af 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr @@ -1,5 +1,5 @@ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/const-check-fns-in-const-impl.rs:12:16 + --> $DIR/const-check-fns-in-const-impl.rs:11:16 | LL | fn foo() { non_const() } | ^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs b/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs index d08c01750c379..7a0db9c98ea61 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs @@ -1,6 +1,5 @@ #![feature(const_trait_impl)] #![feature(const_fn_trait_bound)] // FIXME is this needed? -#![allow(incomplete_features)] trait ConstDefaultFn: Sized { fn b(self); diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr index d52e83609489b..63e4095af2943 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr @@ -1,5 +1,5 @@ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/const-default-method-bodies.rs:26:5 + --> $DIR/const-default-method-bodies.rs:25:5 | LL | NonConstImpl.a(); | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs b/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs index 936c90e88aaee..bed4e9fd1e610 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![allow(incomplete_features)] struct Foo; diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr index 612511a479956..603f6b7d2835e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr @@ -1,5 +1,5 @@ error: expected identifier, found keyword `impl` - --> $DIR/const-impl-norecover.rs:6:7 + --> $DIR/const-impl-norecover.rs:5:7 | LL | const impl Foo { | ^^^^ expected identifier, found keyword diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs index fd3dd2cef9d1c..470c653dd4701 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![allow(incomplete_features)] trait Foo {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr index 84fb619dc9648..f815389ff01c3 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr @@ -1,5 +1,5 @@ error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:6:7 + --> $DIR/const-impl-recovery.rs:5:7 | LL | const impl Foo for i32 {} | ^^^^ expected identifier, found keyword @@ -10,7 +10,7 @@ LL | impl const Foo for i32 {} |-- ^^^^^ error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:10:7 + --> $DIR/const-impl-recovery.rs:9:7 | LL | const impl Bar for T {} | ^^^^ expected identifier, found keyword diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gated.stderr b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gated.stderr index 30baa38547580..3f553a8ee7079 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gated.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gated.stderr @@ -1,5 +1,5 @@ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/cross-crate.rs:16:5 + --> $DIR/cross-crate.rs:15:5 | LL | NonConst.func(); | ^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.rs b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.rs index c28ff63895841..4bd3359947d94 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.rs @@ -1,6 +1,5 @@ // revisions: stock gated #![cfg_attr(gated, feature(const_trait_impl))] -#![allow(incomplete_features)] // aux-build: cross-crate.rs extern crate cross_crate; diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr index e6a86f251ca3c..9908f47a7b288 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr @@ -1,11 +1,11 @@ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/cross-crate.rs:16:5 + --> $DIR/cross-crate.rs:15:5 | LL | NonConst.func(); | ^^^^^^^^^^^^^^^ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/cross-crate.rs:18:5 + --> $DIR/cross-crate.rs:17:5 | LL | Const.func(); | ^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr index 4c630d33c5516..af4d3909e4051 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr @@ -1,5 +1,5 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate.rs:14:1 + --> $DIR/feature-gate.rs:13:1 | LL | fn main() {} | ^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs index d9772431941d3..7bac72e1bb6fb 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs @@ -2,7 +2,6 @@ // gate-test-const_trait_impl #![cfg_attr(gated, feature(const_trait_impl))] -#![allow(incomplete_features)] #![feature(rustc_attrs)] struct S; diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr index 724090e49cd41..91a8bb578a829 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr @@ -1,5 +1,5 @@ error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:10:6 + --> $DIR/feature-gate.rs:9:6 | LL | impl const T for S {} | ^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs b/src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs index d368082031260..91c3d2d5920bc 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs @@ -1,6 +1,5 @@ // run-pass -#![allow(incomplete_features)] #![feature(const_trait_impl)] #![feature(const_fn_trait_bound)] diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs index ad14dd62bc7b5..80a4442de2cba 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs @@ -1,7 +1,6 @@ // Regression test for #69615. #![feature(const_trait_impl)] -#![allow(incomplete_features)] pub trait MyTrait { fn method(&self) -> Option<()>; diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr index 8c76d7eb597b6..3ec329cba1eb2 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr @@ -1,5 +1,5 @@ error[E0744]: `?` is not allowed in a `const fn` - --> $DIR/hir-const-check.rs:12:9 + --> $DIR/hir-const-check.rs:11:9 | LL | Some(())?; | ^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.rs b/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.rs index def7c34b4e50e..59de9e9571944 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![allow(incomplete_features)] trait Tr { fn req(&self); diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.stderr b/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.stderr index eb7f899b4dee2..5301e0ad12ef1 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.stderr @@ -1,5 +1,5 @@ error: const trait implementations may not use non-const default functions - --> $DIR/impl-with-default-fn.rs:18:1 + --> $DIR/impl-with-default-fn.rs:17:1 | LL | / impl const Tr for S { LL | | fn req(&self) {} @@ -9,7 +9,7 @@ LL | | } = note: `prov` not implemented error: const trait implementations may not use non-const default functions - --> $DIR/impl-with-default-fn.rs:33:1 + --> $DIR/impl-with-default-fn.rs:32:1 | LL | / impl const Tr for u32 { LL | | fn req(&self) {} @@ -20,7 +20,7 @@ LL | | } = note: `prov` not implemented error[E0046]: not all trait items implemented, missing: `req` - --> $DIR/impl-with-default-fn.rs:27:1 + --> $DIR/impl-with-default-fn.rs:26:1 | LL | fn req(&self); | -------------- `req` from trait diff --git a/src/test/ui/rfc-2632-const-trait-impl/stability.rs b/src/test/ui/rfc-2632-const-trait-impl/stability.rs index 454fde34a2cdc..6b54a9eab5205 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/stability.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/stability.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(allow_internal_unstable)] #![feature(const_add)] #![feature(const_trait_impl)] diff --git a/src/test/ui/rfc-2632-const-trait-impl/stability.stderr b/src/test/ui/rfc-2632-const-trait-impl/stability.stderr index 5b2ebccef1c6d..86b685959a6cb 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/stability.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/stability.stderr @@ -1,5 +1,5 @@ error: trait methods cannot be stable const fn - --> $DIR/stability.rs:14:5 + --> $DIR/stability.rs:13:5 | LL | / fn sub(self, rhs: Self) -> Self { LL | | @@ -8,7 +8,7 @@ LL | | } | |_____^ error: `::add` is not yet stable as a const fn - --> $DIR/stability.rs:32:5 + --> $DIR/stability.rs:31:5 | LL | Int(1i32) + Int(2i32) | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/syntax.rs b/src/test/ui/rfc-2632-const-trait-impl/syntax.rs index 354d48d630f7b..82a1275bffaed 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/syntax.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/syntax.rs @@ -3,7 +3,6 @@ #![feature(const_trait_bound_opt_out)] #![feature(const_trait_impl)] -#![allow(incomplete_features)] // For now, this parses since an error does not occur until AST lowering. impl ?const T {} From f6efa3356622a2b939b93cb4a169c24418cf3446 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 16 Jul 2021 15:15:23 +0200 Subject: [PATCH 8/9] Add GUI test for auto-hide-trait-implementations setting --- .../auto-hide-trait-implementations.goml | 13 +++++++++++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/rustdoc-gui/auto-hide-trait-implementations.goml diff --git a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml new file mode 100644 index 0000000000000..7b1358fedc3b5 --- /dev/null +++ b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml @@ -0,0 +1,13 @@ +// Checks that the setting "auto hide trait implementations" is working as expected. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html + +// By default, the trait implementations are not collapsed. +assert-attribute: ("#trait-implementations-list > details", {"open": ""}, ALL) + +// We now set the setting to auto hide all trait implementations. +local-storage: {"rustdoc-auto-hide-trait-implementations": "true" } +// We reload to ensure the trait implementations are collapsed as expected. +reload: + +// We now check that all matching elements don't have the open attributes. +assert-attribute-false: ("#trait-implementations-list > details", {"open": ""}, ALL) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 85dd8805fbc4c..bed72ccb9f929 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -5,6 +5,7 @@ #![feature(doc_keyword)] #![feature(doc_cfg)] +use std::convert::AsRef; use std::fmt; /// Basic function with some code examples: @@ -36,6 +37,12 @@ impl Foo { } } +impl AsRef for Foo { + fn as_ref(&self) -> &str { + "hello" + } +} + /// Just a normal enum. #[doc(alias = "ThisIsAnAlias")] pub enum WhoLetTheDogOut { From 0ea2980ae5a87dd224c07d000d68852007b2e5c1 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 16 Jul 2021 08:04:49 -0700 Subject: [PATCH 9/9] feat(rustdoc): open sidebar menu when links inside it are focused Fixes #87172 Based on #87167 (which should be merged first) Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html Co-authored-by: Guillaume Gomez --- src/librustdoc/html/static/css/rustdoc.css | 3 ++- src/test/rustdoc-gui/sidebar-mobile.goml | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 9e3ad66753133..35c767a3c77ec 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1729,7 +1729,8 @@ details.undocumented[open] > summary::before { width: calc(100% + 30px); } - .show-it { + .show-it, .sidebar-elems:focus-within { + z-index: 2; left: 0; } diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml index 9a1442e48a9ea..f0c9361d0806b 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -8,3 +8,13 @@ assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"}) // Opening the sidebar menu. click: ".sidebar-menu" assert-css: (".sidebar-elems", {"display": "block", "left": "0px"}) +// Closing the sidebar menu. +click: ".sidebar-menu" +assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"}) +// Force the sidebar open by focusing a link inside it. +// This makes it easier for keyboard users to get to it. +focus: ".sidebar-title" +assert-css: (".sidebar-elems", {"display": "block", "left": "0px"}) +// When we tab out of the sidebar, close it. +focus: ".search-input" +assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})