pub(crate) enum ImplTraitContext {
    Universal,
    ReturnPositionOpaqueTy {
        origin: OpaqueTyOrigin,
        in_trait: bool,
    },
    TypeAliasesOpaqueTy,
    FeatureGated(ImplTraitPositionSymbol),
    Disallowed(ImplTraitPosition),
}
Expand description

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

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

Fields

§origin: OpaqueTyOrigin

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

§in_trait: bool

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.

§

TypeAliasesOpaqueTy

Impl trait in type aliases.

§

FeatureGated(ImplTraitPositionSymbol)

impl Trait is unstably accepted in this position.

§

Disallowed(ImplTraitPosition)

impl Trait is not accepted in this position.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 12 bytes

Size for each variant:

  • Universal: 0 bytes
  • ReturnPositionOpaqueTy: 12 bytes
  • TypeAliasesOpaqueTy: 0 bytes
  • FeatureGated: 12 bytes
  • Disallowed: 5 bytes