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§
source§impl<'tcx> TypeVisitor<'tcx> for ConstrainedCollectorPostAstConv
impl<'tcx> TypeVisitor<'tcx> for ConstrainedCollectorPostAstConv
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<!>
fn visit_const(&mut self, _: Const<'tcx>) -> ControlFlow<!>
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<!>
type BreakTy = !
fn visit_binder<T>(
&mut self,
t: &Binder<'tcx, T>
) -> ControlFlow<Self::BreakTy, ()>where
T: TypeVisitable<'tcx>,
fn visit_predicate(
&mut self,
p: Predicate<'tcx>
) -> ControlFlow<Self::BreakTy, ()>
Auto Trait Implementations§
impl RefUnwindSafe for ConstrainedCollectorPostAstConv
impl Send for ConstrainedCollectorPostAstConv
impl Sync for ConstrainedCollectorPostAstConv
impl Unpin for ConstrainedCollectorPostAstConv
impl UnwindSafe for ConstrainedCollectorPostAstConv
Blanket Implementations§
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