Skip to content

Commit bf256d4

Browse files
committed
Stabilize the supertrait_item_shadowing feature
1 parent b01cc1c commit bf256d4

File tree

51 files changed

+159
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+159
-236
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ declare_features! (
409409
(accepted, struct_field_attributes, "1.20.0", Some(38814)),
410410
/// Allows struct variants `Foo { baz: u8, .. }` in enums (RFC 418).
411411
(accepted, struct_variant, "1.0.0", None),
412+
/// Allows subtrait items to shadow supertrait items.
413+
(accepted, supertrait_item_shadowing, "CURRENT_RUSTC_VERSION", Some(89151)),
412414
/// Allows `#[target_feature(...)]`.
413415
(accepted, target_feature, "1.27.0", None),
414416
/// Allows the use of `#[target_feature]` on safe functions.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ declare_features! (
648648
(unstable, string_deref_patterns, "1.67.0", Some(87121)),
649649
/// Allows `super let` statements.
650650
(unstable, super_let, "1.88.0", Some(139076)),
651-
/// Allows subtrait items to shadow supertrait items.
652-
(unstable, supertrait_item_shadowing, "1.86.0", Some(89151)),
653651
/// Allows the use of target_feature when a function is marked inline(always).
654652
(unstable, target_feature_inline_always, "1.91.0", Some(145574)),
655653
/// Allows using `#[thread_local]` on `static` items.

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,12 +1728,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
17281728
// We collapse to a subtrait pick *after* filtering unstable candidates
17291729
// to make sure we don't prefer a unstable subtrait method over a stable
17301730
// supertrait method.
1731-
if self.tcx.features().supertrait_item_shadowing() {
1732-
if let Some(pick) =
1733-
self.collapse_candidates_to_subtrait_pick(self_ty, &applicable_candidates)
1734-
{
1735-
return Some(Ok(pick));
1736-
}
1731+
if let Some(pick) =
1732+
self.collapse_candidates_to_subtrait_pick(self_ty, &applicable_candidates)
1733+
{
1734+
return Some(Ok(pick));
17371735
}
17381736

17391737
let sources =

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,11 +4923,8 @@ declare_lint! {
49234923
/// silently, this lint detects these cases when users want to deny them
49244924
/// or fix the call sites.
49254925
pub SUPERTRAIT_ITEM_SHADOWING_USAGE,
4926-
// FIXME(supertrait_item_shadowing): It is not decided if this should
4927-
// warn by default at the call site.
49284926
Allow,
49294927
"detects when a supertrait item is shadowed by a subtrait item",
4930-
@feature_gate = supertrait_item_shadowing;
49314928
}
49324929

49334930
declare_lint! {
@@ -4962,11 +4959,8 @@ declare_lint! {
49624959
/// silently, this lint detects these cases when users want to deny them
49634960
/// or fix their trait definitions.
49644961
pub SUPERTRAIT_ITEM_SHADOWING_DEFINITION,
4965-
// FIXME(supertrait_item_shadowing): It is not decided if this should
4966-
// warn by default at the usage site.
4967-
Allow,
4962+
Warn,
49684963
"detects when a supertrait item is shadowed by a subtrait item",
4969-
@feature_gate = supertrait_item_shadowing;
49704964
}
49714965

49724966
declare_lint! {

compiler/rustc_middle/src/mir/interpret/pointer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub trait Provenance: Copy + PartialEq + fmt::Debug + 'static {
7070
const WILDCARD: Option<Self>;
7171

7272
/// Determines how a pointer should be printed.
73-
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
73+
fn fmt_ptr(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
7474

7575
/// If `OFFSET_IS_ADDR == false`, provenance must always be able to
7676
/// identify the allocation this ptr points to (i.e., this must return `Some`).
@@ -174,7 +174,7 @@ impl Provenance for CtfeProvenance {
174174
// `CtfeProvenance` does not implement wildcard provenance.
175175
const WILDCARD: Option<Self> = None;
176176

177-
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177+
fn fmt_ptr(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
178178
// Print AllocId.
179179
fmt::Debug::fmt(&ptr.provenance.alloc_id(), f)?; // propagates `alternate` flag
180180
// Print offset only if it is non-zero.
@@ -206,7 +206,7 @@ impl Provenance for AllocId {
206206
// `AllocId` does not implement wildcard provenance.
207207
const WILDCARD: Option<Self> = None;
208208

209-
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209+
fn fmt_ptr(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
210210
// Forward `alternate` flag to `alloc_id` printing.
211211
if f.alternate() {
212212
write!(f, "{:#?}", ptr.provenance)?;
@@ -248,14 +248,14 @@ static_assert_size!(Pointer<Option<CtfeProvenance>>, 16);
248248
// all the Miri types.
249249
impl<Prov: Provenance> fmt::Debug for Pointer<Prov> {
250250
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
251-
Provenance::fmt(self, f)
251+
Provenance::fmt_ptr(self, f)
252252
}
253253
}
254254

255255
impl<Prov: Provenance> fmt::Debug for Pointer<Option<Prov>> {
256256
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
257257
match self.provenance {
258-
Some(prov) => Provenance::fmt(&Pointer::new(prov, self.offset), f),
258+
Some(prov) => Provenance::fmt_ptr(&Pointer::new(prov, self.offset), f),
259259
None => write!(f, "{:#x}[noalloc]", self.offset.bytes()),
260260
}
261261
}

library/compiler-builtins/compiler-builtins/src/int/addsub.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ trait UAddSub: DInt + Int {
2020

2121
impl UAddSub for u128 {}
2222

23+
#[allow(supertrait_item_shadowing_definition)]
2324
trait AddSub: Int
2425
where
2526
<Self as MinInt>::Unsigned: UAddSub,

library/compiler-builtins/compiler-builtins/src/int/mul.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::int::{DInt, HInt, Int};
22

3+
#[allow(supertrait_item_shadowing_definition)]
34
trait Mul: DInt + Int
45
where
56
Self::H: DInt,

library/core/src/array/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl<T: Copy, const N: usize> Copy for [T; N] {}
442442
impl<T: Clone, const N: usize> Clone for [T; N] {
443443
#[inline]
444444
fn clone(&self) -> Self {
445-
SpecArrayClone::clone(self)
445+
SpecArrayClone::spec_clone(self)
446446
}
447447

448448
#[inline]
@@ -452,19 +452,19 @@ impl<T: Clone, const N: usize> Clone for [T; N] {
452452
}
453453

454454
trait SpecArrayClone: Clone {
455-
fn clone<const N: usize>(array: &[Self; N]) -> [Self; N];
455+
fn spec_clone<const N: usize>(array: &[Self; N]) -> [Self; N];
456456
}
457457

458458
impl<T: Clone> SpecArrayClone for T {
459459
#[inline]
460-
default fn clone<const N: usize>(array: &[T; N]) -> [T; N] {
460+
default fn spec_clone<const N: usize>(array: &[T; N]) -> [T; N] {
461461
from_trusted_iterator(array.iter().cloned())
462462
}
463463
}
464464

465465
impl<T: Copy> SpecArrayClone for T {
466466
#[inline]
467-
fn clone<const N: usize>(array: &[T; N]) -> [T; N] {
467+
fn spec_clone<const N: usize>(array: &[T; N]) -> [T; N] {
468468
*array
469469
}
470470
}

library/core/src/iter/adapters/array_chunks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ where
104104
Self: Sized,
105105
F: FnMut(B, Self::Item) -> B,
106106
{
107-
<Self as SpecFold>::fold(self, init, f)
107+
<Self as SpecFold>::spec_fold(self, init, f)
108108
}
109109
}
110110

@@ -196,7 +196,7 @@ where
196196
}
197197

198198
trait SpecFold: Iterator {
199-
fn fold<B, F>(self, init: B, f: F) -> B
199+
fn spec_fold<B, F>(self, init: B, f: F) -> B
200200
where
201201
Self: Sized,
202202
F: FnMut(B, Self::Item) -> B;
@@ -207,7 +207,7 @@ where
207207
I: Iterator,
208208
{
209209
#[inline]
210-
default fn fold<B, F>(mut self, init: B, f: F) -> B
210+
default fn spec_fold<B, F>(mut self, init: B, f: F) -> B
211211
where
212212
Self: Sized,
213213
F: FnMut(B, Self::Item) -> B,
@@ -221,7 +221,7 @@ where
221221
I: Iterator + TrustedRandomAccessNoCoerce,
222222
{
223223
#[inline]
224-
fn fold<B, F>(mut self, init: B, mut f: F) -> B
224+
fn spec_fold<B, F>(mut self, init: B, mut f: F) -> B
225225
where
226226
Self: Sized,
227227
F: FnMut(B, Self::Item) -> B,

src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ fn issue11880() {
144144
type U;
145145
}
146146
trait Y: X {
147+
#[allow(supertrait_item_shadowing_definition)]
147148
type T;
148149
type V;
149150
}

0 commit comments

Comments
 (0)