## DEREF_INTO_DYN_SUPERTRAIT

# Static DEREF_INTO_DYN_SUPERTRAIT

Source

    pub static DEREF_INTO_DYN_SUPERTRAIT: &Lint

Expand description

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 trait upcasting (stabilized since 1.86.0). The `deref` functions is no longer called implicitly, which might change behavior compared to previous rustc versions.

#### §Example

ⓘ

    #![deny(deref_into_dyn_supertrait)]
    #![allow(dead_code)]

    use core::ops::Deref;

    trait A {}
    trait B: A {}
    impl<'a> Deref for dyn 'a + B {
        type Target = dyn A;
        fn deref(&self) -> &Self::Target {
            todo!()
        }
    }

    fn take_a(_: &dyn A) { }

    fn take_b(b: &dyn B) {
        take_a(b);
    }

{{produces}}

#### §Explanation

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).