[−][src]Enum rustc_ast_lowering::ImplTraitContext

pub(crate) enum ImplTraitContext<'b, 'a> {
    Universal(&'b mut Vec<GenericParam<'a>>),
    ReturnPositionOpaqueTy {
        fn_def_id: DefId,
        origin: OpaqueTyOrigin,
    },
    OtherOpaqueTy {
        capturable_lifetimes: &'b mut FxHashSet<LifetimeName>,
        origin: OpaqueTyOrigin,
    },
    Disallowed(ImplTraitPosition),
}

Context of impl Trait in code, which determines whether it is allowed in an HIR subtree, and if so, what meaning it has.

Variants

Universal(&'b mut Vec<GenericParam<'a>>)

Treat impl Trait as shorthand for a new universal generic parameter. Example: fn foo(x: impl Debug), where impl Debug is conceptually equivalent to a fresh universal parameter like fn foo<T: Debug>(x: T).

Newly generated parameters should be inserted into the given Vec.

ReturnPositionOpaqueTy

Treat impl Trait as shorthand for a new opaque type. Example: fn foo() -> impl Debug, where impl Debug is conceptually equivalent to a new opaque type like type T = impl Debug; fn foo() -> T.

Fields of ReturnPositionOpaqueTy

fn_def_id: DefId

DefId for the parent function, used to look up necessary information later.

origin: OpaqueTyOrigin

Origin: Either OpaqueTyOrigin::FnReturn or OpaqueTyOrigin::AsyncFn,

OtherOpaqueTy

Impl trait in type aliases, consts and statics.

Fields of OtherOpaqueTy

capturable_lifetimes: &'b mut FxHashSet<LifetimeName>

Set of lifetimes that this opaque type can capture, if it uses them. This includes lifetimes bound since we entered this context. For example, in

type A<'b> = impl for<'a> Trait<'a, Out = impl Sized + 'a>;

the inner opaque type captures 'a because it uses it. It doesn't need to capture 'b because it already inherits the lifetime parameter from A.

origin: OpaqueTyOrigin

Origin: Either OpaqueTyOrigin::Misc or OpaqueTyOrigin::Binding,

Disallowed(ImplTraitPosition)

impl Trait is not accepted in this position.

Implementations

impl<'a, '_> ImplTraitContext<'_, 'a>[src]

pub(crate) fn disallowed() -> Self[src]

pub(crate) fn reborrow<'this>(&'this mut self) -> ImplTraitContext<'this, 'a>[src]

Trait Implementations

impl<'b, 'a> Debug for ImplTraitContext<'b, 'a>[src]

Auto Trait Implementations

impl<'b, 'a> !RefUnwindSafe for ImplTraitContext<'b, 'a>

impl<'b, 'a> !Send for ImplTraitContext<'b, 'a>

impl<'b, 'a> !Sync for ImplTraitContext<'b, 'a>

impl<'b, 'a> Unpin for ImplTraitContext<'b, 'a> where
    'a: 'b, 

impl<'b, 'a> !UnwindSafe for ImplTraitContext<'b, 'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.