rustc_lint_defs::builtin

Static SELF_CONSTRUCTOR_FROM_OUTER_ITEM

source
pub static SELF_CONSTRUCTOR_FROM_OUTER_ITEM: &Lint
Expand description

The self_constructor_from_outer_item lint detects cases where the Self constructor was silently allowed due to a bug in the resolver, and which may produce surprising and unintended behavior.

Using a Self type alias from an outer item was never intended, but was silently allowed. This is deprecated – and is a hard error when the Self type alias references generics that are not in scope.

§Example

#![deny(self_constructor_from_outer_item)]

struct S0(usize);

impl S0 {
    fn foo() {
        const C: S0 = Self(0);
        fn bar() -> S0 {
            Self(0)
        }
    }
}

{{produces}}

§Explanation

The Self type alias should not be reachable because nested items are not associated with the scope of the parameters from the parent item.