struct ConstrainedCollectorPostAstConv {
    arg_is_constrained: Box<[bool]>,
}
Expand description

Visits a ty::Ty collecting information about what generic parameters are constrained.

The visitor does not operate on hir::Ty so that it can be called on the rhs of a type Alias<...> = ...; which may live in a separate crate so there would not be any hir available. Instead we use the type_of query to obtain a ty::Ty which will be present even in cross crate scenarios. It also naturally handles cycle detection as we go through the query system.

This is necessary in the first place for the following case:

type Alias<'a, T> = <T as Trait<'a>>::Assoc;
fn foo<'a>(_: Alias<'a, ()>) -> Alias<'a, ()> { ... }

If we conservatively considered 'a unconstrained then we could break users who had written code before we started correctly handling aliases. If we considered 'a constrained then it would become late bound causing an error during astconv as the 'a is not constrained by the input type <() as Trait<'a>>::Assoc but appears in the output type <() as Trait<'a>>::Assoc.

We must therefore “look into” the Alias to see whether we should consider 'a constrained or not.

See #100508 #85533 #47511 for additional context

Fields§

§arg_is_constrained: Box<[bool]>

Trait Implementations§

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 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: 16 bytes