Stabilize RFC3324 dyn upcasting coercion

Aka trait_upcasting feature.

And also adjust the `deref_into_dyn_supertrait` lint.
This commit is contained in:
Urgau
2023-11-21 13:58:01 +01:00
parent 855c6836b7
commit 4c2d6de70e
69 changed files with 107 additions and 357 deletions

View File

@@ -5,7 +5,6 @@ use crate::{
use rustc_hir as hir;
use rustc_middle::ty;
use rustc_session::lint::FutureIncompatibilityReason;
use rustc_span::sym;
use rustc_trait_selection::traits::supertraits;
@@ -13,9 +12,6 @@ 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`.
///
/// These implementations will become shadowed when the `trait_upcasting` feature is stabilized.
/// The `deref` functions will no longer be called implicitly, so there might be behavior change.
///
/// ### Example
///
/// ```rust,compile_fail
@@ -44,15 +40,10 @@ declare_lint! {
///
/// ### Explanation
///
/// The dyn upcasting coercion feature adds new coercion rules, taking priority
/// over certain other coercion rules, which will cause some behavior change.
/// The implicit dyn upcasting coercion take priority over those `Deref` impls.
pub DEREF_INTO_DYN_SUPERTRAIT,
Warn,
"`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",
};
"`Deref` implementation usage with a supertrait trait object for output are shadow by implicit coercion",
}
declare_lint_pass!(DerefIntoDynSupertrait => [DEREF_INTO_DYN_SUPERTRAIT]);
@@ -90,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait {
cx.emit_spanned_lint(
DEREF_INTO_DYN_SUPERTRAIT,
tcx.def_span(item.owner_id.def_id),
SupertraitAsDerefTarget { t, target_principal, label },
SupertraitAsDerefTarget { t, label },
);
}
}