Struct rustc_trait_selection::opaque_types::OpaqueTypeDecl[−][src]

pub struct OpaqueTypeDecl<'tcx> {
    pub opaque_type: Ty<'tcx>,
    pub substs: SubstsRef<'tcx>,
    pub definition_span: Span,
    pub concrete_ty: Ty<'tcx>,
    pub has_required_region_bounds: bool,
    pub origin: OpaqueTyOrigin,
}
Expand description

Information about the opaque types whose values we are inferring in this function (these are the impl Trait that appear in the return type).

Fields

opaque_type: Ty<'tcx>
Expand description

The opaque type (ty::Opaque) for this declaration.

substs: SubstsRef<'tcx>
Expand description

The substitutions that we apply to the opaque type that this impl Trait desugars to. e.g., if:

fn foo<'a, 'b, T>() -> impl Trait<'a>

winds up desugared to:

type Foo<'x, X> = impl Trait<'x>
fn foo<'a, 'b, T>() -> Foo<'a, T>

then substs would be ['a, T].

definition_span: Span
Expand description

The span of this particular definition of the opaque type. So for example:

ⓘ
type Foo = impl Baz;
fn bar() -> Foo {
//          ^^^ This is the span we are looking for!

In cases where the fn returns (impl Trait, impl Trait) or other such combinations, the result is currently over-approximated, but better than nothing.

concrete_ty: Ty<'tcx>
Expand description

The type variable that represents the value of the opaque type that we require. In other words, after we compile this function, we will be created a constraint like:

Foo<'a, T> = ?C

where ?C is the value of this type variable. =) It may naturally refer to the type and lifetime parameters in scope in this function, though ultimately it should only reference those that are arguments to Foo in the constraint above. (In other words, ?C should not include 'b, even though it’s a lifetime parameter on foo.)

has_required_region_bounds: bool
Expand description

Returns true if the impl Trait bounds include region bounds. For example, this would be true for:

fn foo<'a, 'b, 'c>() -> impl Trait<'c> + 'a + 'b

but false for:

fn foo<'c>() -> impl Trait<'c>

unless Trait was declared like:

trait Trait<'c>: 'c

in which case it would be true.

This is used during regionck to decide whether we need to impose any additional constraints to ensure that region variables in concrete_ty wind up being constrained to something from substs (or, at minimum, things that outlive the fn body). (Ultimately, writeback is responsible for this check.)

origin: OpaqueTyOrigin
Expand description

The origin of the opaque type.

Trait Implementations

impl<'tcx> Clone for OpaqueTypeDecl<'tcx>[src]

fn clone(&self) -> OpaqueTypeDecl<'tcx>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'tcx> Debug for OpaqueTypeDecl<'tcx>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'tcx> Copy for OpaqueTypeDecl<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for OpaqueTypeDecl<'tcx>

impl<'tcx> !Send for OpaqueTypeDecl<'tcx>

impl<'tcx> !Sync for OpaqueTypeDecl<'tcx>

impl<'tcx> Unpin for OpaqueTypeDecl<'tcx>

impl<'tcx> !UnwindSafe for OpaqueTypeDecl<'tcx>

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
    T: Copy, 
[src]

pub fn allocate_on(self, arena: &'a Arena<'tcx>) -> &'a mut T[src]

pub fn allocate_from_iter(
    arena: &'a Arena<'tcx>,
    iter: impl IntoIterator<Item = T>
) -> &'a mut [T]
[src]

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> WithConstness for T[src]

fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]

fn with_const(self) -> ConstnessAnd<Self>[src]

fn without_const(self) -> ConstnessAnd<Self>[src]