Skip to content

Commit 49e31cc

Browse files
authored
Rollup merge of rust-lang#149532 - Amanieu:supertrait-shadowing-lints, r=lqd
Rename supertrait item shadowing lints This follows the lang team decision [here](rust-lang#148605 (comment)) and renames: - `supertrait_item_shadowing_definition` to `shadowing_supertrait_items` - `supertrait_item_shadowing_usage` to `resolving_to_items_shadowing_supertrait_items` The lint levels are left unchanged as allow-by-default until stabilization.
2 parents 1d3d73e + e833f24 commit 49e31cc

File tree

13 files changed

+47
-43
lines changed

13 files changed

+47
-43
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::lang_items::LangItem;
1313
use rustc_hir::{AmbigArg, ItemKind, find_attr};
1414
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
1515
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin, TyCtxtInferExt};
16-
use rustc_lint_defs::builtin::SUPERTRAIT_ITEM_SHADOWING_DEFINITION;
16+
use rustc_lint_defs::builtin::SHADOWING_SUPERTRAIT_ITEMS;
1717
use rustc_macros::LintDiagnostic;
1818
use rustc_middle::mir::interpret::ErrorHandled;
1919
use rustc_middle::traits::solve::NoSolution;
@@ -797,7 +797,7 @@ fn lint_item_shadowing_supertrait_item<'tcx>(tcx: TyCtxt<'tcx>, trait_item_def_i
797797
};
798798

799799
tcx.emit_node_span_lint(
800-
SUPERTRAIT_ITEM_SHADOWING_DEFINITION,
800+
SHADOWING_SUPERTRAIT_ITEMS,
801801
tcx.local_def_id_to_hir_id(trait_item_def_id),
802802
tcx.def_span(trait_item_def_id),
803803
errors::SupertraitItemShadowing {

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir_analysis::hir_ty_lowering::{
1212
use rustc_infer::infer::{
1313
BoundRegionConversionTime, DefineOpaqueTypes, InferOk, RegionVariableOrigin,
1414
};
15-
use rustc_lint::builtin::SUPERTRAIT_ITEM_SHADOWING_USAGE;
15+
use rustc_lint::builtin::RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS;
1616
use rustc_middle::traits::ObligationCauseCode;
1717
use rustc_middle::ty::adjustment::{
1818
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion,
@@ -709,7 +709,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
709709
};
710710

711711
self.tcx.emit_node_span_lint(
712-
SUPERTRAIT_ITEM_SHADOWING_USAGE,
712+
RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS,
713713
segment.hir_id,
714714
segment.ident.span,
715715
SupertraitItemShadowing { shadower, shadowee, item: segment.ident.name, subtrait },

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ declare_lint_pass! {
8888
RENAMED_AND_REMOVED_LINTS,
8989
REPR_C_ENUMS_LARGER_THAN_INT,
9090
REPR_TRANSPARENT_NON_ZST_FIELDS,
91+
RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS,
9192
RTSAN_NONBLOCKING_ASYNC,
9293
RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
9394
RUST_2021_INCOMPATIBLE_OR_PATTERNS,
@@ -98,11 +99,10 @@ declare_lint_pass! {
9899
RUST_2024_PRELUDE_COLLISIONS,
99100
SELF_CONSTRUCTOR_FROM_OUTER_ITEM,
100101
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
102+
SHADOWING_SUPERTRAIT_ITEMS,
101103
SINGLE_USE_LIFETIMES,
102104
SOFT_UNSTABLE,
103105
STABLE_FEATURES,
104-
SUPERTRAIT_ITEM_SHADOWING_DEFINITION,
105-
SUPERTRAIT_ITEM_SHADOWING_USAGE,
106106
TAIL_EXPR_DROP_ORDER,
107107
TEST_UNSTABLE_LINT,
108108
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
@@ -4922,15 +4922,16 @@ declare_lint! {
49224922
}
49234923

49244924
declare_lint! {
4925-
/// The `supertrait_item_shadowing_usage` lint detects when the
4925+
/// The `resolving_to_items_shadowing_supertrait_items` lint detects when the
49264926
/// usage of an item that is provided by both a subtrait and supertrait
49274927
/// is shadowed, preferring the subtrait.
49284928
///
49294929
/// ### Example
49304930
///
4931-
/// ```rust,compile_fail
4931+
#[cfg_attr(bootstrap, doc = "```ignore")]
4932+
#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")]
49324933
/// #![feature(supertrait_item_shadowing)]
4933-
/// #![deny(supertrait_item_shadowing_usage)]
4934+
/// #![deny(resolving_to_items_shadowing_supertrait_items)]
49344935
///
49354936
/// trait Upstream {
49364937
/// fn hello(&self) {}
@@ -4944,7 +4945,8 @@ declare_lint! {
49444945
///
49454946
/// struct MyType;
49464947
/// MyType.hello();
4947-
/// ```
4948+
#[cfg_attr(bootstrap, doc = "```")]
4949+
#[cfg_attr(not(bootstrap), doc = "```")]
49484950
///
49494951
/// {{produces}}
49504952
///
@@ -4955,7 +4957,7 @@ declare_lint! {
49554957
/// selection. In order to mitigate side-effects of this happening
49564958
/// silently, this lint detects these cases when users want to deny them
49574959
/// or fix the call sites.
4958-
pub SUPERTRAIT_ITEM_SHADOWING_USAGE,
4960+
pub RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS,
49594961
// FIXME(supertrait_item_shadowing): It is not decided if this should
49604962
// warn by default at the call site.
49614963
Allow,
@@ -4964,15 +4966,16 @@ declare_lint! {
49644966
}
49654967

49664968
declare_lint! {
4967-
/// The `supertrait_item_shadowing_definition` lint detects when the
4969+
/// The `shadowing_supertrait_items` lint detects when the
49684970
/// definition of an item that is provided by both a subtrait and
49694971
/// supertrait is shadowed, preferring the subtrait.
49704972
///
49714973
/// ### Example
49724974
///
4973-
/// ```rust,compile_fail
4975+
#[cfg_attr(bootstrap, doc = "```ignore")]
4976+
#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")]
49744977
/// #![feature(supertrait_item_shadowing)]
4975-
/// #![deny(supertrait_item_shadowing_definition)]
4978+
/// #![deny(shadowing_supertrait_items)]
49764979
///
49774980
/// trait Upstream {
49784981
/// fn hello(&self) {}
@@ -4983,7 +4986,8 @@ declare_lint! {
49834986
/// fn hello(&self) {}
49844987
/// }
49854988
/// impl<T> Downstream for T {}
4986-
/// ```
4989+
#[cfg_attr(bootstrap, doc = "```")]
4990+
#[cfg_attr(not(bootstrap), doc = "```")]
49874991
///
49884992
/// {{produces}}
49894993
///
@@ -4994,7 +4998,7 @@ declare_lint! {
49944998
/// selection. In order to mitigate side-effects of this happening
49954999
/// silently, this lint detects these cases when users want to deny them
49965000
/// or fix their trait definitions.
4997-
pub SUPERTRAIT_ITEM_SHADOWING_DEFINITION,
5001+
pub SHADOWING_SUPERTRAIT_ITEMS,
49985002
// FIXME(supertrait_item_shadowing): It is not decided if this should
49995003
// warn by default at the usage site.
50005004
Allow,

tests/ui/methods/supertrait-shadowing/common-ancestor-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//@ check-run-results
33

44
#![feature(supertrait_item_shadowing)]
5-
#![warn(supertrait_item_shadowing_usage)]
6-
#![warn(supertrait_item_shadowing_definition)]
5+
#![warn(resolving_to_items_shadowing_supertrait_items)]
6+
#![warn(shadowing_supertrait_items)]
77
#![allow(dead_code)]
88

99
trait A {

tests/ui/methods/supertrait-shadowing/common-ancestor-2.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ LL | fn hello(&self) {
1515
note: the lint level is defined here
1616
--> $DIR/common-ancestor-2.rs:6:9
1717
|
18-
LL | #![warn(supertrait_item_shadowing_definition)]
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
LL | #![warn(shadowing_supertrait_items)]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
warning: trait item `hello` from `C` shadows identically named item from supertrait
2222
--> $DIR/common-ancestor-2.rs:32:8
@@ -40,8 +40,8 @@ LL | fn hello(&self) {
4040
note: the lint level is defined here
4141
--> $DIR/common-ancestor-2.rs:5:9
4242
|
43-
LL | #![warn(supertrait_item_shadowing_usage)]
44-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
LL | #![warn(resolving_to_items_shadowing_supertrait_items)]
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545

4646
warning: 2 warnings emitted
4747

tests/ui/methods/supertrait-shadowing/common-ancestor-3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//@ check-run-results
33

44
#![feature(supertrait_item_shadowing)]
5-
#![warn(supertrait_item_shadowing_usage)]
6-
#![warn(supertrait_item_shadowing_definition)]
5+
#![warn(resolving_to_items_shadowing_supertrait_items)]
6+
#![warn(shadowing_supertrait_items)]
77
#![allow(dead_code)]
88

99
trait A {

tests/ui/methods/supertrait-shadowing/common-ancestor-3.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ LL | fn hello(&self) {
1515
note: the lint level is defined here
1616
--> $DIR/common-ancestor-3.rs:6:9
1717
|
18-
LL | #![warn(supertrait_item_shadowing_definition)]
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
LL | #![warn(shadowing_supertrait_items)]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
warning: trait item `hello` from `D` shadows identically named item from supertrait
2222
--> $DIR/common-ancestor-3.rs:34:5
@@ -61,8 +61,8 @@ LL | fn hello(&self) {
6161
note: the lint level is defined here
6262
--> $DIR/common-ancestor-3.rs:5:9
6363
|
64-
LL | #![warn(supertrait_item_shadowing_usage)]
65-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64+
LL | #![warn(resolving_to_items_shadowing_supertrait_items)]
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6666

6767
warning: 3 warnings emitted
6868

tests/ui/methods/supertrait-shadowing/common-ancestor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//@ check-run-results
33

44
#![feature(supertrait_item_shadowing)]
5-
#![warn(supertrait_item_shadowing_usage)]
6-
#![warn(supertrait_item_shadowing_definition)]
5+
#![warn(resolving_to_items_shadowing_supertrait_items)]
6+
#![warn(shadowing_supertrait_items)]
77
#![allow(dead_code)]
88

99
trait A {

tests/ui/methods/supertrait-shadowing/common-ancestor.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ LL | fn hello(&self) {
1212
note: the lint level is defined here
1313
--> $DIR/common-ancestor.rs:6:9
1414
|
15-
LL | #![warn(supertrait_item_shadowing_definition)]
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
LL | #![warn(shadowing_supertrait_items)]
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1717

1818
warning: trait item `hello` from `B` shadows identically named item from supertrait
1919
--> $DIR/common-ancestor.rs:25:8
@@ -34,8 +34,8 @@ LL | fn hello(&self) {
3434
note: the lint level is defined here
3535
--> $DIR/common-ancestor.rs:5:9
3636
|
37-
LL | #![warn(supertrait_item_shadowing_usage)]
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37+
LL | #![warn(resolving_to_items_shadowing_supertrait_items)]
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939

4040
warning: 2 warnings emitted
4141

tests/ui/methods/supertrait-shadowing/definition-site.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(supertrait_item_shadowing)]
2-
#![deny(supertrait_item_shadowing_definition)]
2+
#![deny(shadowing_supertrait_items)]
33

44
trait SuperSuper {
55
fn method();

0 commit comments

Comments
 (0)