diff options
| author | Waffle Lapkin <waffle.lapkin@gmail.com> | 2025-02-06 21:57:50 +0100 |
|---|---|---|
| committer | Waffle Lapkin <waffle.lapkin@gmail.com> | 2025-02-06 23:44:24 +0100 |
| commit | 491599569c081985d6cc3eb4ab55d692e380e938 (patch) | |
| tree | adfe56b57b4dbc0c622d5c95c7c32d3728f78862 /compiler/rustc_lint | |
| parent | bc1d68e389d000730084b8e3bfc3ba23b9450dd8 (diff) | |
| download | rust-491599569c081985d6cc3eb4ab55d692e380e938.tar.gz rust-491599569c081985d6cc3eb4ab55d692e380e938.zip | |
allow+update `deref_into_dyn_supertrait`
this commit makes `deref_into_dyn_supertrait` lint allow-by-default, removes future incompatibility (we finally live in a broken world), and changes the wording in the documentation. previously documentation erroneously said that it lints against *usage* of the deref impl, while it actually (since 104742) lints on the impl itself (oooops, my oversight, should have updated it 2+ years ago...)
Diffstat (limited to 'compiler/rustc_lint')
| -rw-r--r-- | compiler/rustc_lint/src/deref_into_dyn_supertrait.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs index 07f46aba05b..181f44fb4de 100644 --- a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs +++ b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs @@ -1,6 +1,5 @@ use rustc_hir::{self as hir, LangItem}; use rustc_middle::ty; -use rustc_session::lint::FutureIncompatibilityReason; use rustc_session::{declare_lint, declare_lint_pass}; use rustc_span::sym; use rustc_trait_selection::traits::supertraits; @@ -9,12 +8,12 @@ use crate::lints::{SupertraitAsDerefTarget, SupertraitAsDerefTargetLabel}; use crate::{LateContext, LateLintPass, LintContext}; declare_lint! { - /// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the - /// `Deref` implementation with a `dyn SuperTrait` type as `Output`. + /// The `deref_into_dyn_supertrait` lint is emitted whenever there is a `Deref` implementation + /// for `dyn SubTrait` with a `dyn SuperTrait` type as the `Output` type. /// - /// These implementations are shadowed by the `trait_upcasting` feature (stabilized since + /// These implementations are "shadowed" by trait upcasting (stabilized since /// CURRENT_RUSTC_VERSION). The `deref` functions is no longer called implicitly, which might - /// be behavior change compared to previous rustc versions. + /// change behavior compared to previous rustc versions. /// /// ### Example /// @@ -44,15 +43,14 @@ declare_lint! { /// /// ### Explanation /// - /// The dyn upcasting coercion feature added a new coercion rules, taking priority - /// over certain other coercion rules, which caused some behavior change. + /// The trait upcasting coercion added a new coercion rule, taking priority over certain other + /// coercion rules, which causes some behavior change compared to older `rustc` versions. + /// + /// `deref` can be still called explicitly, it just isn't called as part of a deref coercion + /// (since trait upcasting coercion takes priority). pub DEREF_INTO_DYN_SUPERTRAIT, - Warn, - "`Deref` implementation usage with a supertrait trait object for output is shadowed by trait upcasting", - @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange, - reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>", - }; + Allow, + "`Deref` implementation with a supertrait trait object for output is shadowed by trait upcasting", } declare_lint_pass!(DerefIntoDynSupertrait => [DEREF_INTO_DYN_SUPERTRAIT]); |
