From bf256d4f8fdd0dd34a2f5cb7265aec88e47615f6 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Thu, 6 Nov 2025 18:55:08 +0000 Subject: [PATCH] Stabilize the `supertrait_item_shadowing` feature --- compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/unstable.rs | 2 - compiler/rustc_hir_typeck/src/method/probe.rs | 10 ++-- compiler/rustc_lint_defs/src/builtin.rs | 8 +-- .../rustc_middle/src/mir/interpret/pointer.rs | 10 ++-- .../compiler-builtins/src/int/addsub.rs | 1 + .../compiler-builtins/src/int/mul.rs | 1 + library/core/src/array/mod.rs | 8 +-- .../core/src/iter/adapters/array_chunks.rs | 8 +-- .../tests/ui/implied_bounds_in_impls.fixed | 1 + .../tests/ui/implied_bounds_in_impls.rs | 1 + .../tests/ui/implied_bounds_in_impls.stderr | 14 ++--- src/tools/miri/src/machine.rs | 2 +- .../assoc-const-eq-ty-alias-noninteracting.rs | 1 + tests/ui/associated-consts/shadowed-const.rs | 9 ++- .../associated-consts/shadowed-const.stderr | 12 ++-- ...type-shadowed-from-non-local-supertrait.rs | 2 + ...-shadowed-from-non-local-supertrait.stderr | 2 +- ...ssociated-type-shadowed-from-supertrait.rs | 2 + ...iated-type-shadowed-from-supertrait.stderr | 2 +- tests/ui/associated-types/issue-20825-2.rs | 2 + .../explicit-paths-in-traits-pass.rs | 1 + tests/ui/delegation/explicit-paths.rs | 1 + tests/ui/delegation/explicit-paths.stderr | 34 +++++------ tests/ui/delegation/list.rs | 1 + tests/ui/error-codes/E0221.rs | 9 +-- tests/ui/error-codes/E0221.stderr | 4 +- .../feature-gate-supertrait-item-shadowing.rs | 22 ------- ...ture-gate-supertrait-item-shadowing.stderr | 57 ------------------- .../supertrait-shadowing/assoc-const.rs | 2 +- .../supertrait-shadowing/common-ancestor-2.rs | 1 - .../common-ancestor-2.stderr | 14 ++--- .../supertrait-shadowing/common-ancestor-3.rs | 1 - .../common-ancestor-3.stderr | 18 +++--- .../supertrait-shadowing/common-ancestor.rs | 1 - .../common-ancestor.stderr | 14 ++--- .../supertrait-shadowing/definition-site.rs | 1 - .../definition-site.stderr | 10 ++-- .../false-subtrait-after-inference.rs | 1 - .../false-subtrait-after-inference.stderr | 20 +++---- .../no-common-ancestor-2.rs | 2 +- .../no-common-ancestor.rs | 2 - .../no-common-ancestor.stderr | 6 +- .../supertrait-shadowing/out-of-scope.rs | 2 +- .../trivially-false-subtrait.rs | 2 +- .../supertrait-shadowing/type-dependent.rs | 2 +- tests/ui/span/issue-37767.rs | 14 ++--- tests/ui/suggestions/issue-98500.rs | 2 + tests/ui/suggestions/issue-98500.stderr | 4 +- tests/ui/traits/track-obligations.rs | 18 +++--- tests/ui/traits/track-obligations.stderr | 29 +++++----- 51 files changed, 159 insertions(+), 236 deletions(-) delete mode 100644 tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.rs delete mode 100644 tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.stderr diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 364a1202b05c2..30d23a80f56c6 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -409,6 +409,8 @@ declare_features! ( (accepted, struct_field_attributes, "1.20.0", Some(38814)), /// Allows struct variants `Foo { baz: u8, .. }` in enums (RFC 418). (accepted, struct_variant, "1.0.0", None), + /// Allows subtrait items to shadow supertrait items. + (accepted, supertrait_item_shadowing, "CURRENT_RUSTC_VERSION", Some(89151)), /// Allows `#[target_feature(...)]`. (accepted, target_feature, "1.27.0", None), /// Allows the use of `#[target_feature]` on safe functions. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 8397cd294e0a9..194e5ee6b5e91 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -648,8 +648,6 @@ declare_features! ( (unstable, string_deref_patterns, "1.67.0", Some(87121)), /// Allows `super let` statements. (unstable, super_let, "1.88.0", Some(139076)), - /// Allows subtrait items to shadow supertrait items. - (unstable, supertrait_item_shadowing, "1.86.0", Some(89151)), /// Allows the use of target_feature when a function is marked inline(always). (unstable, target_feature_inline_always, "1.91.0", Some(145574)), /// Allows using `#[thread_local]` on `static` items. diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index a8457134031c9..e5812037fb3a2 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1728,12 +1728,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // We collapse to a subtrait pick *after* filtering unstable candidates // to make sure we don't prefer a unstable subtrait method over a stable // supertrait method. - if self.tcx.features().supertrait_item_shadowing() { - if let Some(pick) = - self.collapse_candidates_to_subtrait_pick(self_ty, &applicable_candidates) - { - return Some(Ok(pick)); - } + if let Some(pick) = + self.collapse_candidates_to_subtrait_pick(self_ty, &applicable_candidates) + { + return Some(Ok(pick)); } let sources = diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 86aa6341aff87..73baa57346356 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4923,11 +4923,8 @@ declare_lint! { /// silently, this lint detects these cases when users want to deny them /// or fix the call sites. pub SUPERTRAIT_ITEM_SHADOWING_USAGE, - // FIXME(supertrait_item_shadowing): It is not decided if this should - // warn by default at the call site. Allow, "detects when a supertrait item is shadowed by a subtrait item", - @feature_gate = supertrait_item_shadowing; } declare_lint! { @@ -4962,11 +4959,8 @@ declare_lint! { /// silently, this lint detects these cases when users want to deny them /// or fix their trait definitions. pub SUPERTRAIT_ITEM_SHADOWING_DEFINITION, - // FIXME(supertrait_item_shadowing): It is not decided if this should - // warn by default at the usage site. - Allow, + Warn, "detects when a supertrait item is shadowed by a subtrait item", - @feature_gate = supertrait_item_shadowing; } declare_lint! { diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index 2aac8852b7e84..55ca01063c682 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -70,7 +70,7 @@ pub trait Provenance: Copy + PartialEq + fmt::Debug + 'static { const WILDCARD: Option; /// Determines how a pointer should be printed. - fn fmt(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result; + fn fmt_ptr(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result; /// If `OFFSET_IS_ADDR == false`, provenance must always be able to /// identify the allocation this ptr points to (i.e., this must return `Some`). @@ -174,7 +174,7 @@ impl Provenance for CtfeProvenance { // `CtfeProvenance` does not implement wildcard provenance. const WILDCARD: Option = None; - fn fmt(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt_ptr(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Print AllocId. fmt::Debug::fmt(&ptr.provenance.alloc_id(), f)?; // propagates `alternate` flag // Print offset only if it is non-zero. @@ -206,7 +206,7 @@ impl Provenance for AllocId { // `AllocId` does not implement wildcard provenance. const WILDCARD: Option = None; - fn fmt(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt_ptr(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Forward `alternate` flag to `alloc_id` printing. if f.alternate() { write!(f, "{:#?}", ptr.provenance)?; @@ -248,14 +248,14 @@ static_assert_size!(Pointer>, 16); // all the Miri types. impl fmt::Debug for Pointer { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - Provenance::fmt(self, f) + Provenance::fmt_ptr(self, f) } } impl fmt::Debug for Pointer> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.provenance { - Some(prov) => Provenance::fmt(&Pointer::new(prov, self.offset), f), + Some(prov) => Provenance::fmt_ptr(&Pointer::new(prov, self.offset), f), None => write!(f, "{:#x}[noalloc]", self.offset.bytes()), } } diff --git a/library/compiler-builtins/compiler-builtins/src/int/addsub.rs b/library/compiler-builtins/compiler-builtins/src/int/addsub.rs index b2b21fc2c4401..54d3917e51b61 100644 --- a/library/compiler-builtins/compiler-builtins/src/int/addsub.rs +++ b/library/compiler-builtins/compiler-builtins/src/int/addsub.rs @@ -20,6 +20,7 @@ trait UAddSub: DInt + Int { impl UAddSub for u128 {} +#[allow(supertrait_item_shadowing_definition)] trait AddSub: Int where ::Unsigned: UAddSub, diff --git a/library/compiler-builtins/compiler-builtins/src/int/mul.rs b/library/compiler-builtins/compiler-builtins/src/int/mul.rs index 040c69342d148..74b61cf1db57e 100644 --- a/library/compiler-builtins/compiler-builtins/src/int/mul.rs +++ b/library/compiler-builtins/compiler-builtins/src/int/mul.rs @@ -1,5 +1,6 @@ use crate::int::{DInt, HInt, Int}; +#[allow(supertrait_item_shadowing_definition)] trait Mul: DInt + Int where Self::H: DInt, diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 0dc10758a8560..165dc9d21bed5 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -442,7 +442,7 @@ impl Copy for [T; N] {} impl Clone for [T; N] { #[inline] fn clone(&self) -> Self { - SpecArrayClone::clone(self) + SpecArrayClone::spec_clone(self) } #[inline] @@ -452,19 +452,19 @@ impl Clone for [T; N] { } trait SpecArrayClone: Clone { - fn clone(array: &[Self; N]) -> [Self; N]; + fn spec_clone(array: &[Self; N]) -> [Self; N]; } impl SpecArrayClone for T { #[inline] - default fn clone(array: &[T; N]) -> [T; N] { + default fn spec_clone(array: &[T; N]) -> [T; N] { from_trusted_iterator(array.iter().cloned()) } } impl SpecArrayClone for T { #[inline] - fn clone(array: &[T; N]) -> [T; N] { + fn spec_clone(array: &[T; N]) -> [T; N] { *array } } diff --git a/library/core/src/iter/adapters/array_chunks.rs b/library/core/src/iter/adapters/array_chunks.rs index 8f1744fc5fbb7..92c1fa3086809 100644 --- a/library/core/src/iter/adapters/array_chunks.rs +++ b/library/core/src/iter/adapters/array_chunks.rs @@ -104,7 +104,7 @@ where Self: Sized, F: FnMut(B, Self::Item) -> B, { - ::fold(self, init, f) + ::spec_fold(self, init, f) } } @@ -196,7 +196,7 @@ where } trait SpecFold: Iterator { - fn fold(self, init: B, f: F) -> B + fn spec_fold(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B; @@ -207,7 +207,7 @@ where I: Iterator, { #[inline] - default fn fold(mut self, init: B, f: F) -> B + default fn spec_fold(mut self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B, @@ -221,7 +221,7 @@ where I: Iterator + TrustedRandomAccessNoCoerce, { #[inline] - fn fold(mut self, init: B, mut f: F) -> B + fn spec_fold(mut self, init: B, mut f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B, diff --git a/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed b/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed index 4fe3fa4eab516..a052829242f9a 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed @@ -144,6 +144,7 @@ fn issue11880() { type U; } trait Y: X { + #[allow(supertrait_item_shadowing_definition)] type T; type V; } diff --git a/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs b/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs index 6cc824db11072..0bc1a9b4908aa 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs @@ -144,6 +144,7 @@ fn issue11880() { type U; } trait Y: X { + #[allow(supertrait_item_shadowing_definition)] type T; type V; } diff --git a/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr b/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr index e2888d86f3151..f253b60e2c19c 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr @@ -193,7 +193,7 @@ LL + fn f3() -> impl Trait4 {} | error: this bound is already specified as the supertrait of `Y` - --> tests/ui/implied_bounds_in_impls.rs:165:21 + --> tests/ui/implied_bounds_in_impls.rs:166:21 | LL | fn f3() -> impl X + Y {} | ^ @@ -205,7 +205,7 @@ LL + fn f3() -> impl Y {} | error: this bound is already specified as the supertrait of `Y` - --> tests/ui/implied_bounds_in_impls.rs:167:21 + --> tests/ui/implied_bounds_in_impls.rs:168:21 | LL | fn f4() -> impl X + Y {} | ^ @@ -217,7 +217,7 @@ LL + fn f4() -> impl Y {} | error: this bound is already specified as the supertrait of `Y` - --> tests/ui/implied_bounds_in_impls.rs:169:21 + --> tests/ui/implied_bounds_in_impls.rs:170:21 | LL | fn f5() -> impl X + Y {} | ^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL + fn f5() -> impl Y {} | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:173:17 + --> tests/ui/implied_bounds_in_impls.rs:174:17 | LL | fn apit(_: impl Deref + DerefMut) {} | ^^^^^ @@ -241,7 +241,7 @@ LL + fn apit(_: impl DerefMut) {} | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:177:20 + --> tests/ui/implied_bounds_in_impls.rs:178:20 | LL | fn f() -> impl Deref + DerefMut; | ^^^^^ @@ -253,7 +253,7 @@ LL + fn f() -> impl DerefMut; | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:186:23 + --> tests/ui/implied_bounds_in_impls.rs:187:23 | LL | type Assoc = impl Deref + DerefMut; | ^^^^^ @@ -265,7 +265,7 @@ LL + type Assoc = impl DerefMut; | error: this bound is already specified as the supertrait of `DerefMut` - --> tests/ui/implied_bounds_in_impls.rs:193:18 + --> tests/ui/implied_bounds_in_impls.rs:194:18 | LL | type Tait = impl Deref + DerefMut; | ^^^^^ diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 27d461f68848b..d4aa79204f3eb 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -346,7 +346,7 @@ impl interpret::Provenance for Provenance { } } - fn fmt(ptr: &interpret::Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt_ptr(ptr: &interpret::Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (prov, addr) = ptr.into_raw_parts(); // offset is absolute address write!(f, "{:#x}", addr.bytes())?; if f.alternate() { diff --git a/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs b/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs index 76df014ccd9bd..488f2a73b3e04 100644 --- a/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs +++ b/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs @@ -6,6 +6,7 @@ //@ check-pass #![feature(associated_const_equality)] +#![allow(supertrait_item_shadowing_definition)] trait Trait: SuperTrait { type N; diff --git a/tests/ui/associated-consts/shadowed-const.rs b/tests/ui/associated-consts/shadowed-const.rs index d9b565742d42a..e06affb1c6aaa 100644 --- a/tests/ui/associated-consts/shadowed-const.rs +++ b/tests/ui/associated-consts/shadowed-const.rs @@ -1,5 +1,8 @@ // Checking that none of these ICE, which was introduced in // https://github.com/rust-lang/rust/issues/93553 + +#![allow(supertrait_item_shadowing_definition)] + trait Foo { type Bar; } @@ -15,9 +18,9 @@ trait Baz2: Foo { } trait Baz3 { - const BAR: usize; - const QUX: Self::BAR; - //~^ ERROR expected type, found constant + const BAR: usize; + const QUX: Self::BAR; + //~^ ERROR expected type, found constant } fn main() {} diff --git a/tests/ui/associated-consts/shadowed-const.stderr b/tests/ui/associated-consts/shadowed-const.stderr index 2db645b3c9662..be4ec4191dc28 100644 --- a/tests/ui/associated-consts/shadowed-const.stderr +++ b/tests/ui/associated-consts/shadowed-const.stderr @@ -1,14 +1,14 @@ error: expected type, found constant - --> $DIR/shadowed-const.rs:19:20 + --> $DIR/shadowed-const.rs:22:22 | -LL | const QUX: Self::BAR; - | ^^^ unexpected constant +LL | const QUX: Self::BAR; + | ^^^ unexpected constant | note: the associated constant is defined here - --> $DIR/shadowed-const.rs:18:3 + --> $DIR/shadowed-const.rs:21:5 | -LL | const BAR: usize; - | ^^^^^^^^^^^^^^^^ +LL | const BAR: usize; + | ^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.rs b/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.rs index 045a43548dcaa..96917b69fea31 100644 --- a/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.rs +++ b/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.rs @@ -1,6 +1,8 @@ // Test that no help message is emitted that suggests renaming the // associated type from a non-local trait +#![allow(supertrait_item_shadowing_definition)] + pub trait NewIter: Iterator { type Item; } diff --git a/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.stderr b/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.stderr index fdb4e4fc1a85e..f6adc7f22a4ce 100644 --- a/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.stderr +++ b/tests/ui/associated-types/associated-type-shadowed-from-non-local-supertrait.stderr @@ -1,5 +1,5 @@ error[E0191]: the value of the associated type `Item` in `Iterator` must be specified - --> $DIR/associated-type-shadowed-from-non-local-supertrait.rs:8:27 + --> $DIR/associated-type-shadowed-from-non-local-supertrait.rs:10:27 | LL | type Item; | --------- `Iterator::Item` shadowed here, consider renaming it diff --git a/tests/ui/associated-types/associated-type-shadowed-from-supertrait.rs b/tests/ui/associated-types/associated-type-shadowed-from-supertrait.rs index 95d03892838b8..2951fbc54d6dc 100644 --- a/tests/ui/associated-types/associated-type-shadowed-from-supertrait.rs +++ b/tests/ui/associated-types/associated-type-shadowed-from-supertrait.rs @@ -1,6 +1,8 @@ // Test Setting the value of an associated type // that is shadowed from a supertrait +#![allow(supertrait_item_shadowing_definition)] + pub trait Super { type X; } diff --git a/tests/ui/associated-types/associated-type-shadowed-from-supertrait.stderr b/tests/ui/associated-types/associated-type-shadowed-from-supertrait.stderr index e6cec255eeef8..1d85d6b4eb0ed 100644 --- a/tests/ui/associated-types/associated-type-shadowed-from-supertrait.stderr +++ b/tests/ui/associated-types/associated-type-shadowed-from-supertrait.stderr @@ -1,5 +1,5 @@ error[E0191]: the value of the associated type `X` in `Super` must be specified - --> $DIR/associated-type-shadowed-from-supertrait.rs:12:27 + --> $DIR/associated-type-shadowed-from-supertrait.rs:14:27 | LL | type X; | ------ `Super::X` defined here, consider renaming it diff --git a/tests/ui/associated-types/issue-20825-2.rs b/tests/ui/associated-types/issue-20825-2.rs index d0b6fff7e38b4..2060ca1289b02 100644 --- a/tests/ui/associated-types/issue-20825-2.rs +++ b/tests/ui/associated-types/issue-20825-2.rs @@ -1,3 +1,5 @@ +#![allow(supertrait_item_shadowing_definition)] + //@ check-pass pub trait Subscriber { type Input; diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.rs b/tests/ui/delegation/explicit-paths-in-traits-pass.rs index 7d281ad150a03..e7d1d09a9d0ec 100644 --- a/tests/ui/delegation/explicit-paths-in-traits-pass.rs +++ b/tests/ui/delegation/explicit-paths-in-traits-pass.rs @@ -2,6 +2,7 @@ #![feature(fn_delegation)] #![allow(incomplete_features)] +#![allow(supertrait_item_shadowing_definition)] trait ToReuse { fn foo(&self, x: i32) -> i32 { x } diff --git a/tests/ui/delegation/explicit-paths.rs b/tests/ui/delegation/explicit-paths.rs index 3b0454eb52400..e0d57daaf9daf 100644 --- a/tests/ui/delegation/explicit-paths.rs +++ b/tests/ui/delegation/explicit-paths.rs @@ -1,5 +1,6 @@ #![feature(fn_delegation)] #![allow(incomplete_features)] +#![allow(supertrait_item_shadowing_definition)] trait Trait { fn foo1(&self, x: i32) -> i32 { x } diff --git a/tests/ui/delegation/explicit-paths.stderr b/tests/ui/delegation/explicit-paths.stderr index 30239f3648a53..460cfab85f215 100644 --- a/tests/ui/delegation/explicit-paths.stderr +++ b/tests/ui/delegation/explicit-paths.stderr @@ -1,5 +1,5 @@ error[E0407]: method `foo3` is not a member of trait `Trait` - --> $DIR/explicit-paths.rs:49:9 + --> $DIR/explicit-paths.rs:50:9 | LL | reuse to_reuse::foo3; | ^^^^^^^^^^^^^^^^----^ @@ -8,7 +8,7 @@ LL | reuse to_reuse::foo3; | not a member of trait `Trait` error[E0407]: method `foo4` is not a member of trait `Trait` - --> $DIR/explicit-paths.rs:51:9 + --> $DIR/explicit-paths.rs:52:9 | LL | reuse F::foo4 { &self.0 } | ^^^^^^^^^----^^^^^^^^^^^^ @@ -17,49 +17,49 @@ LL | reuse F::foo4 { &self.0 } | not a member of trait `Trait` error[E0425]: cannot find function `foo4` in `S` - --> $DIR/explicit-paths.rs:27:14 + --> $DIR/explicit-paths.rs:28:14 | LL | reuse S::foo4; | ^^^^ not found in `S` error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:38:18 + --> $DIR/explicit-paths.rs:39:18 | LL | reuse F::foo4 { &self.0 } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:27:5 + --> $DIR/explicit-paths.rs:28:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:51:18 + --> $DIR/explicit-paths.rs:52:18 | LL | reuse F::foo4 { &self.0 } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:27:5 + --> $DIR/explicit-paths.rs:28:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:65:18 + --> $DIR/explicit-paths.rs:66:18 | LL | reuse F::foo4 { &F } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:27:5 + --> $DIR/explicit-paths.rs:28:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0119]: conflicting implementations of trait `Trait` for type `S` - --> $DIR/explicit-paths.rs:74:5 + --> $DIR/explicit-paths.rs:75:5 | LL | impl Trait for S { | ---------------- first implementation here @@ -68,7 +68,7 @@ LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ conflicting implementation for `S` error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:61:36 + --> $DIR/explicit-paths.rs:62:36 | LL | trait Trait2 : Trait { | -------------------- found this type parameter @@ -80,24 +80,24 @@ LL | reuse ::foo1 { self } = note: expected reference `&F` found reference `&Self` note: method defined here - --> $DIR/explicit-paths.rs:5:8 + --> $DIR/explicit-paths.rs:6:8 | LL | fn foo1(&self, x: i32) -> i32 { x } | ^^^^ ----- error[E0277]: the trait bound `S2: Trait` is not satisfied - --> $DIR/explicit-paths.rs:76:16 + --> $DIR/explicit-paths.rs:77:16 | LL | reuse ::foo1; | ^^ unsatisfied trait bound | help: the trait `Trait` is not implemented for `S2` - --> $DIR/explicit-paths.rs:73:5 + --> $DIR/explicit-paths.rs:74:5 | LL | struct S2; | ^^^^^^^^^ help: the following other types implement trait `Trait` - --> $DIR/explicit-paths.rs:10:1 + --> $DIR/explicit-paths.rs:11:1 | LL | impl Trait for F {} | ^^^^^^^^^^^^^^^^ `F` @@ -109,7 +109,7 @@ LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ `S` error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:76:30 + --> $DIR/explicit-paths.rs:77:30 | LL | reuse ::foo1; | ^^^^ @@ -120,7 +120,7 @@ LL | reuse ::foo1; = note: expected reference `&S2` found reference `&S` note: method defined here - --> $DIR/explicit-paths.rs:5:8 + --> $DIR/explicit-paths.rs:6:8 | LL | fn foo1(&self, x: i32) -> i32 { x } | ^^^^ ----- diff --git a/tests/ui/delegation/list.rs b/tests/ui/delegation/list.rs index 208b14816797a..e9fd917b13a18 100644 --- a/tests/ui/delegation/list.rs +++ b/tests/ui/delegation/list.rs @@ -2,6 +2,7 @@ #![feature(fn_delegation)] #![allow(incomplete_features)] +#![allow(supertrait_item_shadowing_definition)] trait Trait { fn foo(&self) -> u8 { 0 } diff --git a/tests/ui/error-codes/E0221.rs b/tests/ui/error-codes/E0221.rs index 7c7e139a0989d..6116f05972e4b 100644 --- a/tests/ui/error-codes/E0221.rs +++ b/tests/ui/error-codes/E0221.rs @@ -1,3 +1,5 @@ +#![allow(supertrait_item_shadowing_definition)] + trait T1 {} trait T2 {} @@ -5,7 +7,7 @@ trait Foo { type A: T1; } -trait Bar : Foo { +trait Bar: Foo { type A: T2; fn do_something() { let _: Self::A; @@ -15,7 +17,7 @@ trait Bar : Foo { trait T3 {} -trait My : std::str::FromStr { +trait My: std::str::FromStr { type Err: T3; fn test() { let _: Self::Err; @@ -23,5 +25,4 @@ trait My : std::str::FromStr { } } -fn main() { -} +fn main() {} diff --git a/tests/ui/error-codes/E0221.stderr b/tests/ui/error-codes/E0221.stderr index a18e91806d7d9..913dffbb20c55 100644 --- a/tests/ui/error-codes/E0221.stderr +++ b/tests/ui/error-codes/E0221.stderr @@ -1,5 +1,5 @@ error[E0221]: ambiguous associated type `A` in bounds of `Self` - --> $DIR/E0221.rs:11:16 + --> $DIR/E0221.rs:13:16 | LL | type A: T1; | ---------- ambiguous `A` from `Foo` @@ -22,7 +22,7 @@ LL + let _: ::A; | error[E0221]: ambiguous associated type `Err` in bounds of `Self` - --> $DIR/E0221.rs:21:16 + --> $DIR/E0221.rs:23:16 | LL | type Err: T3; | ------------ ambiguous `Err` from `My` diff --git a/tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.rs b/tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.rs deleted file mode 100644 index 218d2eefeaff7..0000000000000 --- a/tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.rs +++ /dev/null @@ -1,22 +0,0 @@ -trait Sup { - fn method(&self) {} -} - -trait Trait: Sup { - fn method(&self) {} -} - -impl Sup for i32 {} -impl Trait for i32 {} - -fn poly(x: T) { - x.method(); - //~^ ERROR multiple applicable items in scope -} - -fn concrete() { - 1.method(); - //~^ ERROR multiple applicable items in scope -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.stderr b/tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.stderr deleted file mode 100644 index 5669073f4abb7..0000000000000 --- a/tests/ui/feature-gates/feature-gate-supertrait-item-shadowing.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0034]: multiple applicable items in scope - --> $DIR/feature-gate-supertrait-item-shadowing.rs:13:7 - | -LL | x.method(); - | ^^^^^^ multiple `method` found - | -note: candidate #1 is defined in the trait `Sup` - --> $DIR/feature-gate-supertrait-item-shadowing.rs:2:5 - | -LL | fn method(&self) {} - | ^^^^^^^^^^^^^^^^ -note: candidate #2 is defined in the trait `Trait` - --> $DIR/feature-gate-supertrait-item-shadowing.rs:6:5 - | -LL | fn method(&self) {} - | ^^^^^^^^^^^^^^^^ -help: disambiguate the method for candidate #1 - | -LL - x.method(); -LL + Sup::method(&x); - | -help: disambiguate the method for candidate #2 - | -LL - x.method(); -LL + Trait::method(&x); - | - -error[E0034]: multiple applicable items in scope - --> $DIR/feature-gate-supertrait-item-shadowing.rs:18:7 - | -LL | 1.method(); - | ^^^^^^ multiple `method` found - | -note: candidate #1 is defined in an impl of the trait `Sup` for the type `i32` - --> $DIR/feature-gate-supertrait-item-shadowing.rs:2:5 - | -LL | fn method(&self) {} - | ^^^^^^^^^^^^^^^^ -note: candidate #2 is defined in an impl of the trait `Trait` for the type `i32` - --> $DIR/feature-gate-supertrait-item-shadowing.rs:6:5 - | -LL | fn method(&self) {} - | ^^^^^^^^^^^^^^^^ -help: disambiguate the method for candidate #1 - | -LL - 1.method(); -LL + Sup::method(&1); - | -help: disambiguate the method for candidate #2 - | -LL - 1.method(); -LL + Trait::method(&1); - | - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/methods/supertrait-shadowing/assoc-const.rs b/tests/ui/methods/supertrait-shadowing/assoc-const.rs index a542ce7d326d1..9750136556504 100644 --- a/tests/ui/methods/supertrait-shadowing/assoc-const.rs +++ b/tests/ui/methods/supertrait-shadowing/assoc-const.rs @@ -1,8 +1,8 @@ //@ run-pass //@ check-run-results -#![feature(supertrait_item_shadowing)] #![allow(dead_code)] +#![allow(supertrait_item_shadowing_definition)] trait A { const CONST: i32; diff --git a/tests/ui/methods/supertrait-shadowing/common-ancestor-2.rs b/tests/ui/methods/supertrait-shadowing/common-ancestor-2.rs index cecf6dccf9d16..2e80601ba5302 100644 --- a/tests/ui/methods/supertrait-shadowing/common-ancestor-2.rs +++ b/tests/ui/methods/supertrait-shadowing/common-ancestor-2.rs @@ -1,7 +1,6 @@ //@ run-pass //@ check-run-results -#![feature(supertrait_item_shadowing)] #![warn(supertrait_item_shadowing_usage)] #![warn(supertrait_item_shadowing_definition)] #![allow(dead_code)] diff --git a/tests/ui/methods/supertrait-shadowing/common-ancestor-2.stderr b/tests/ui/methods/supertrait-shadowing/common-ancestor-2.stderr index 934d5a0f7cfd3..6731a5652daa2 100644 --- a/tests/ui/methods/supertrait-shadowing/common-ancestor-2.stderr +++ b/tests/ui/methods/supertrait-shadowing/common-ancestor-2.stderr @@ -1,11 +1,11 @@ warning: trait item `hello` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-2.rs:24:5 + --> $DIR/common-ancestor-2.rs:23:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-2.rs:10:5 + --> $DIR/common-ancestor-2.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ @@ -13,24 +13,24 @@ LL | fn hello(&self) { LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/common-ancestor-2.rs:6:9 + --> $DIR/common-ancestor-2.rs:5:9 | LL | #![warn(supertrait_item_shadowing_definition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `hello` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-2.rs:32:8 + --> $DIR/common-ancestor-2.rs:31:8 | LL | ().hello(); | ^^^^^ | note: item from `C` shadows a supertrait item - --> $DIR/common-ancestor-2.rs:24:5 + --> $DIR/common-ancestor-2.rs:23:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: items from several supertraits are shadowed: `A` and `B` - --> $DIR/common-ancestor-2.rs:10:5 + --> $DIR/common-ancestor-2.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | fn hello(&self) { LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/common-ancestor-2.rs:5:9 + --> $DIR/common-ancestor-2.rs:4:9 | LL | #![warn(supertrait_item_shadowing_usage)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/methods/supertrait-shadowing/common-ancestor-3.rs b/tests/ui/methods/supertrait-shadowing/common-ancestor-3.rs index 040fa9aab3987..efead4388ec34 100644 --- a/tests/ui/methods/supertrait-shadowing/common-ancestor-3.rs +++ b/tests/ui/methods/supertrait-shadowing/common-ancestor-3.rs @@ -1,7 +1,6 @@ //@ run-pass //@ check-run-results -#![feature(supertrait_item_shadowing)] #![warn(supertrait_item_shadowing_usage)] #![warn(supertrait_item_shadowing_definition)] #![allow(dead_code)] diff --git a/tests/ui/methods/supertrait-shadowing/common-ancestor-3.stderr b/tests/ui/methods/supertrait-shadowing/common-ancestor-3.stderr index 28e44a2ff209a..2d0f2aefe6a08 100644 --- a/tests/ui/methods/supertrait-shadowing/common-ancestor-3.stderr +++ b/tests/ui/methods/supertrait-shadowing/common-ancestor-3.stderr @@ -1,11 +1,11 @@ warning: trait item `hello` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:24:5 + --> $DIR/common-ancestor-3.rs:23:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-3.rs:10:5 + --> $DIR/common-ancestor-3.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ @@ -13,19 +13,19 @@ LL | fn hello(&self) { LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/common-ancestor-3.rs:6:9 + --> $DIR/common-ancestor-3.rs:5:9 | LL | #![warn(supertrait_item_shadowing_definition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `hello` from `D` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:34:5 + --> $DIR/common-ancestor-3.rs:33:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `C`, `B`, and `A` - --> $DIR/common-ancestor-3.rs:10:5 + --> $DIR/common-ancestor-3.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ @@ -37,18 +37,18 @@ LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ warning: trait item `hello` from `D` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:42:8 + --> $DIR/common-ancestor-3.rs:41:8 | LL | ().hello(); | ^^^^^ | note: item from `D` shadows a supertrait item - --> $DIR/common-ancestor-3.rs:34:5 + --> $DIR/common-ancestor-3.rs:33:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: items from several supertraits are shadowed: `A`, `B`, and `C` - --> $DIR/common-ancestor-3.rs:10:5 + --> $DIR/common-ancestor-3.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | fn hello(&self) { LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/common-ancestor-3.rs:5:9 + --> $DIR/common-ancestor-3.rs:4:9 | LL | #![warn(supertrait_item_shadowing_usage)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/methods/supertrait-shadowing/common-ancestor.rs b/tests/ui/methods/supertrait-shadowing/common-ancestor.rs index 8e67c93536755..6df46d776d002 100644 --- a/tests/ui/methods/supertrait-shadowing/common-ancestor.rs +++ b/tests/ui/methods/supertrait-shadowing/common-ancestor.rs @@ -1,7 +1,6 @@ //@ run-pass //@ check-run-results -#![feature(supertrait_item_shadowing)] #![warn(supertrait_item_shadowing_usage)] #![warn(supertrait_item_shadowing_definition)] #![allow(dead_code)] diff --git a/tests/ui/methods/supertrait-shadowing/common-ancestor.stderr b/tests/ui/methods/supertrait-shadowing/common-ancestor.stderr index f404fa6b53a35..17bd8536d4383 100644 --- a/tests/ui/methods/supertrait-shadowing/common-ancestor.stderr +++ b/tests/ui/methods/supertrait-shadowing/common-ancestor.stderr @@ -1,38 +1,38 @@ warning: trait item `hello` from `B` shadows identically named item from supertrait - --> $DIR/common-ancestor.rs:17:5 + --> $DIR/common-ancestor.rs:16:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ | note: item from `A` is shadowed by a subtrait item - --> $DIR/common-ancestor.rs:10:5 + --> $DIR/common-ancestor.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/common-ancestor.rs:6:9 + --> $DIR/common-ancestor.rs:5:9 | LL | #![warn(supertrait_item_shadowing_definition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `hello` from `B` shadows identically named item from supertrait - --> $DIR/common-ancestor.rs:25:8 + --> $DIR/common-ancestor.rs:24:8 | LL | ().hello(); | ^^^^^ | note: item from `B` shadows a supertrait item - --> $DIR/common-ancestor.rs:17:5 + --> $DIR/common-ancestor.rs:16:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: item from `A` is shadowed by a subtrait item - --> $DIR/common-ancestor.rs:10:5 + --> $DIR/common-ancestor.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/common-ancestor.rs:5:9 + --> $DIR/common-ancestor.rs:4:9 | LL | #![warn(supertrait_item_shadowing_usage)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/methods/supertrait-shadowing/definition-site.rs b/tests/ui/methods/supertrait-shadowing/definition-site.rs index 2768a6a6b2717..1756f1e4e1aac 100644 --- a/tests/ui/methods/supertrait-shadowing/definition-site.rs +++ b/tests/ui/methods/supertrait-shadowing/definition-site.rs @@ -1,4 +1,3 @@ -#![feature(supertrait_item_shadowing)] #![deny(supertrait_item_shadowing_definition)] trait SuperSuper { diff --git a/tests/ui/methods/supertrait-shadowing/definition-site.stderr b/tests/ui/methods/supertrait-shadowing/definition-site.stderr index f0bbf414a690c..8fcd728fb5a4e 100644 --- a/tests/ui/methods/supertrait-shadowing/definition-site.stderr +++ b/tests/ui/methods/supertrait-shadowing/definition-site.stderr @@ -1,28 +1,28 @@ error: trait item `method` from `Super` shadows identically named item from supertrait - --> $DIR/definition-site.rs:9:5 + --> $DIR/definition-site.rs:8:5 | LL | fn method(); | ^^^^^^^^^^^^ | note: item from `SuperSuper` is shadowed by a subtrait item - --> $DIR/definition-site.rs:5:5 + --> $DIR/definition-site.rs:4:5 | LL | fn method(); | ^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/definition-site.rs:2:9 + --> $DIR/definition-site.rs:1:9 | LL | #![deny(supertrait_item_shadowing_definition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait item `method` from `Sub` shadows identically named item from supertrait - --> $DIR/definition-site.rs:14:5 + --> $DIR/definition-site.rs:13:5 | LL | fn method(); | ^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `Super` and `SuperSuper` - --> $DIR/definition-site.rs:5:5 + --> $DIR/definition-site.rs:4:5 | LL | fn method(); | ^^^^^^^^^^^^ diff --git a/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.rs b/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.rs index c3bc47e6740d8..18132faa47a9d 100644 --- a/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.rs +++ b/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.rs @@ -1,4 +1,3 @@ -#![feature(supertrait_item_shadowing)] #![warn(supertrait_item_shadowing_usage)] #![warn(supertrait_item_shadowing_definition)] diff --git a/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.stderr b/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.stderr index 47019ca7a320f..dfa8199ecccd7 100644 --- a/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.stderr +++ b/tests/ui/methods/supertrait-shadowing/false-subtrait-after-inference.stderr @@ -1,55 +1,55 @@ warning: trait item `hello` from `Downstream` shadows identically named item from supertrait - --> $DIR/false-subtrait-after-inference.rs:13:5 + --> $DIR/false-subtrait-after-inference.rs:12:5 | LL | fn hello(&self) {} | ^^^^^^^^^^^^^^^ | note: item from `Upstream` is shadowed by a subtrait item - --> $DIR/false-subtrait-after-inference.rs:8:5 + --> $DIR/false-subtrait-after-inference.rs:7:5 | LL | fn hello(&self) {} | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/false-subtrait-after-inference.rs:3:9 + --> $DIR/false-subtrait-after-inference.rs:2:9 | LL | #![warn(supertrait_item_shadowing_definition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `hello` from `Downstream` shadows identically named item from supertrait - --> $DIR/false-subtrait-after-inference.rs:22:7 + --> $DIR/false-subtrait-after-inference.rs:21:7 | LL | x.hello(); | ^^^^^ | note: item from `Downstream` shadows a supertrait item - --> $DIR/false-subtrait-after-inference.rs:13:5 + --> $DIR/false-subtrait-after-inference.rs:12:5 | LL | fn hello(&self) {} | ^^^^^^^^^^^^^^^ note: item from `Upstream` is shadowed by a subtrait item - --> $DIR/false-subtrait-after-inference.rs:8:5 + --> $DIR/false-subtrait-after-inference.rs:7:5 | LL | fn hello(&self) {} | ^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/false-subtrait-after-inference.rs:2:9 + --> $DIR/false-subtrait-after-inference.rs:1:9 | LL | #![warn(supertrait_item_shadowing_usage)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `i32: Foo` is not satisfied - --> $DIR/false-subtrait-after-inference.rs:22:7 + --> $DIR/false-subtrait-after-inference.rs:21:7 | LL | x.hello(); | ^^^^^ the trait `Foo` is not implemented for `i32` | help: this trait has no implementations, consider adding one - --> $DIR/false-subtrait-after-inference.rs:18:1 + --> $DIR/false-subtrait-after-inference.rs:17:1 | LL | trait Foo {} | ^^^^^^^^^ note: required for `W` to implement `Downstream` - --> $DIR/false-subtrait-after-inference.rs:16:9 + --> $DIR/false-subtrait-after-inference.rs:15:9 | LL | impl Downstream for W where T: Foo {} | ^^^^^^^^^^ ^^^^ --- unsatisfied trait bound introduced here diff --git a/tests/ui/methods/supertrait-shadowing/no-common-ancestor-2.rs b/tests/ui/methods/supertrait-shadowing/no-common-ancestor-2.rs index 2834ca31b7140..c0fccecaa719f 100644 --- a/tests/ui/methods/supertrait-shadowing/no-common-ancestor-2.rs +++ b/tests/ui/methods/supertrait-shadowing/no-common-ancestor-2.rs @@ -1,4 +1,4 @@ -#![feature(supertrait_item_shadowing)] +#![allow(supertrait_item_shadowing_definition)] trait A { fn hello(&self) { diff --git a/tests/ui/methods/supertrait-shadowing/no-common-ancestor.rs b/tests/ui/methods/supertrait-shadowing/no-common-ancestor.rs index 7323439d5884f..1cb11a11f0def 100644 --- a/tests/ui/methods/supertrait-shadowing/no-common-ancestor.rs +++ b/tests/ui/methods/supertrait-shadowing/no-common-ancestor.rs @@ -1,5 +1,3 @@ -#![feature(supertrait_item_shadowing)] - trait A { fn hello(&self) { println!("A"); diff --git a/tests/ui/methods/supertrait-shadowing/no-common-ancestor.stderr b/tests/ui/methods/supertrait-shadowing/no-common-ancestor.stderr index 4e83f60c76514..c5f8d2174d21a 100644 --- a/tests/ui/methods/supertrait-shadowing/no-common-ancestor.stderr +++ b/tests/ui/methods/supertrait-shadowing/no-common-ancestor.stderr @@ -1,16 +1,16 @@ error[E0034]: multiple applicable items in scope - --> $DIR/no-common-ancestor.rs:18:8 + --> $DIR/no-common-ancestor.rs:16:8 | LL | ().hello(); | ^^^^^ multiple `hello` found | note: candidate #1 is defined in an impl of the trait `A` for the type `T` - --> $DIR/no-common-ancestor.rs:4:5 + --> $DIR/no-common-ancestor.rs:2:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `B` for the type `T` - --> $DIR/no-common-ancestor.rs:11:5 + --> $DIR/no-common-ancestor.rs:9:5 | LL | fn hello(&self) { | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/methods/supertrait-shadowing/out-of-scope.rs b/tests/ui/methods/supertrait-shadowing/out-of-scope.rs index bd263be59cc7d..352dca6b3a7ef 100644 --- a/tests/ui/methods/supertrait-shadowing/out-of-scope.rs +++ b/tests/ui/methods/supertrait-shadowing/out-of-scope.rs @@ -1,8 +1,8 @@ //@ run-pass //@ check-run-results -#![feature(supertrait_item_shadowing)] #![allow(dead_code)] +#![allow(supertrait_item_shadowing_definition)] mod out_of_scope { pub trait Subtrait: super::Supertrait { diff --git a/tests/ui/methods/supertrait-shadowing/trivially-false-subtrait.rs b/tests/ui/methods/supertrait-shadowing/trivially-false-subtrait.rs index e44c7c18083d0..78563550685ee 100644 --- a/tests/ui/methods/supertrait-shadowing/trivially-false-subtrait.rs +++ b/tests/ui/methods/supertrait-shadowing/trivially-false-subtrait.rs @@ -3,8 +3,8 @@ // Make sure we don't prefer a subtrait that we would've otherwise eliminated // in `consider_probe` during method probing. -#![feature(supertrait_item_shadowing)] #![allow(dead_code)] +#![allow(supertrait_item_shadowing_definition)] struct W(T); diff --git a/tests/ui/methods/supertrait-shadowing/type-dependent.rs b/tests/ui/methods/supertrait-shadowing/type-dependent.rs index 3af884fd52dcd..23e26c4e9a451 100644 --- a/tests/ui/methods/supertrait-shadowing/type-dependent.rs +++ b/tests/ui/methods/supertrait-shadowing/type-dependent.rs @@ -3,8 +3,8 @@ // Makes sure we can shadow with type-dependent method syntax. -#![feature(supertrait_item_shadowing)] #![allow(dead_code)] +#![allow(supertrait_item_shadowing_definition)] trait A { fn hello() { diff --git a/tests/ui/span/issue-37767.rs b/tests/ui/span/issue-37767.rs index 9e34c2c1fac74..7baac65da3b20 100644 --- a/tests/ui/span/issue-37767.rs +++ b/tests/ui/span/issue-37767.rs @@ -2,11 +2,11 @@ trait A { fn foo(&mut self) {} } -trait B : A { +trait B { fn foo(&mut self) {} } -fn bar(a: &T) { +fn bar(a: &T) { a.foo() //~ ERROR multiple applicable items } @@ -14,23 +14,23 @@ trait C { fn foo(&self) {} } -trait D : C { +trait D { fn foo(&self) {} } -fn quz(a: &T) { +fn quz(a: &T) { a.foo() //~ ERROR multiple applicable items } -trait E : Sized { +trait E: Sized { fn foo(self) {} } -trait F : E { +trait F: Sized { fn foo(self) {} } -fn foo(a: T) { +fn foo(a: T) { a.foo() //~ ERROR multiple applicable items } diff --git a/tests/ui/suggestions/issue-98500.rs b/tests/ui/suggestions/issue-98500.rs index 869b665c8cbb7..8abd8b7287e07 100644 --- a/tests/ui/suggestions/issue-98500.rs +++ b/tests/ui/suggestions/issue-98500.rs @@ -1,5 +1,7 @@ //@ aux-build:dyn-incompatible.rs +#![allow(supertrait_item_shadowing_definition)] + extern crate dyn_incompatible; pub trait B where diff --git a/tests/ui/suggestions/issue-98500.stderr b/tests/ui/suggestions/issue-98500.stderr index ec984c0d60e16..758b831d20b54 100644 --- a/tests/ui/suggestions/issue-98500.stderr +++ b/tests/ui/suggestions/issue-98500.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `B` is not dyn compatible - --> $DIR/issue-98500.rs:11:14 + --> $DIR/issue-98500.rs:13:14 | LL | struct S(Box); | ^^^^^ `B` is not dyn compatible @@ -13,7 +13,7 @@ LL | fn f(); LL | fn f2(self: &Arc); | ^^ ...because method `f2`'s `self` parameter cannot be dispatched on | - ::: $DIR/issue-98500.rs:5:11 + ::: $DIR/issue-98500.rs:7:11 | LL | pub trait B where | - this trait is not dyn compatible... diff --git a/tests/ui/traits/track-obligations.rs b/tests/ui/traits/track-obligations.rs index 77e753c13f739..6bcde4b4c5eb0 100644 --- a/tests/ui/traits/track-obligations.rs +++ b/tests/ui/traits/track-obligations.rs @@ -1,5 +1,7 @@ // These are simplifications of the tower traits by the same name: +#![allow(supertrait_item_shadowing_definition)] + pub trait Service { type Response; } @@ -15,15 +17,9 @@ pub struct Res; // This is encoding a trait alias. -pub trait ParticularService: - Service { -} +pub trait ParticularService: Service {} -impl ParticularService for T -where - T: Service, -{ -} +impl ParticularService for T where T: Service {} // This is also a trait alias. // The weird = bound is there so that users of the trait do not @@ -73,7 +69,11 @@ where fn check(&self) {} } -fn check(_: C) where ALayer: ParticularServiceLayer {} +fn check(_: C) +where + ALayer: ParticularServiceLayer, +{ +} // But, they give very different error messages. diff --git a/tests/ui/traits/track-obligations.stderr b/tests/ui/traits/track-obligations.stderr index 141f565077a5b..df7d44b8918df 100644 --- a/tests/ui/traits/track-obligations.stderr +++ b/tests/ui/traits/track-obligations.stderr @@ -14,13 +14,10 @@ LL | Client(()).check(); | ^^^^^ method cannot be called on `Client<()>` due to unsatisfied trait bounds | note: trait bound `>::Response = Res` was not satisfied - --> $DIR/track-obligations.rs:24:21 + --> $DIR/track-obligations.rs:22:55 | -LL | impl ParticularService for T - | ----------------- - -LL | where -LL | T: Service, - | ^^^^^^^^^^^^^^ unsatisfied trait bound introduced here +LL | impl ParticularService for T where T: Service {} + | ----------------- - ^^^^^^^^^^^^^^ unsatisfied trait bound introduced here error[E0271]: type mismatch resolving `>::Response == Res` --> $DIR/track-obligations.rs:87:11 @@ -31,20 +28,17 @@ LL | check(()); | required by a bound introduced by this call | note: expected this to be `Res` - --> $DIR/track-obligations.rs:60:21 + --> $DIR/track-obligations.rs:56:21 | LL | type Response = bool; | ^^^^ note: required for `AService` to implement `ParticularService` --> $DIR/track-obligations.rs:22:9 | -LL | impl ParticularService for T - | ^^^^^^^^^^^^^^^^^ ^ -LL | where -LL | T: Service, - | -------------- unsatisfied trait bound introduced here +LL | impl ParticularService for T where T: Service {} + | ^^^^^^^^^^^^^^^^^ ^ -------------- unsatisfied trait bound introduced here note: required for `ALayer<_>` to implement `ParticularServiceLayer<_>` - --> $DIR/track-obligations.rs:40:12 + --> $DIR/track-obligations.rs:36:12 | LL | impl ParticularServiceLayer for T | ^^^^^^^^^^^^^^^^^^^^^^^^^ ^ @@ -52,10 +46,13 @@ LL | impl ParticularServiceLayer for T LL | T::Service: ParticularService, | ----------------- unsatisfied trait bound introduced here note: required by a bound in `check` - --> $DIR/track-obligations.rs:76:36 + --> $DIR/track-obligations.rs:74:16 | -LL | fn check(_: C) where ALayer: ParticularServiceLayer {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +LL | fn check(_: C) + | ----- required by a bound in this function +LL | where +LL | ALayer: ParticularServiceLayer, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors