fn match_ty<I: Interner>(
    builder: &mut ClauseBuilder<'_, I>,
    environment: &Environment<I>,
    ty: &Ty<I>,
) -> Result<(), Floundered> {
    let interner = builder.interner();
    Ok(match ty.kind(interner) {
        TyKind::Adt(adt_id, _) => builder
            .db
            .adt_datum(*adt_id)
            .to_program_clauses(builder, environment),
        TyKind::OpaqueType(opaque_ty_id, _) => builder
            .db
            .opaque_ty_data(*opaque_ty_id)
            .to_program_clauses(builder, environment),
        TyKind::Error => {}
        TyKind::AssociatedType(type_id, _) => builder
            .db
            .associated_ty_data(*type_id)
            .to_program_clauses(builder, environment),
        TyKind::FnDef(fn_def_id, _) => builder
            .db
            .fn_def_datum(*fn_def_id)
            .to_program_clauses(builder, environment),
        TyKind::Tuple(_, _)
        | TyKind::Scalar(_)
        | TyKind::Str
        | TyKind::Slice(_)
        | TyKind::Raw(_, _)
        | TyKind::Ref(_, _, _)
        | TyKind::Array(_, _)
        | TyKind::Never
        | TyKind::Closure(_, _)
        | TyKind::Foreign(_)
        | TyKind::Generator(_, _)
        | TyKind::GeneratorWitness(_, _) => builder.push_fact(WellFormed::Ty(ty.clone())),
        TyKind::Placeholder(_) => {
            builder.push_clause(WellFormed::Ty(ty.clone()), Some(FromEnv::Ty(ty.clone())));
        }
        TyKind::Alias(AliasTy::Projection(proj)) => builder
            .db
            .associated_ty_data(proj.associated_ty_id)
            .to_program_clauses(builder, environment),
        TyKind::Alias(AliasTy::Opaque(opaque_ty)) => builder
            .db
            .opaque_ty_data(opaque_ty.opaque_ty_id)
            .to_program_clauses(builder, environment),
        TyKind::Function(_quantified_ty) => {
            builder.push_fact(WellFormed::Ty(ty.clone()));
        }
        TyKind::BoundVar(_) | TyKind::InferenceVar(_, _) => return Err(Floundered),
        TyKind::Dyn(_) => {}
    })
}
/// Examine `T` and push clauses that may be relevant to proving the
/// following sorts of goals (and maybe others):
///
/// * `DomainGoal::WellFormed(T)`
/// * `DomainGoal::IsUpstream(T)`
/// * `DomainGoal::DownstreamType(T)`
/// * `DomainGoal::IsFullyVisible(T)`
/// * `DomainGoal::IsLocal(T)`
///
/// Note that the type `T` must not be an unbound inference variable;
/// earlier parts of the logic should "flounder" in that case.
Examine `T` and push clauses that may be relevant to proving the
following sorts of goals (and maybe others).



Note that the type `T` must not be an unbound inference variable;
earlier parts of the logic should "flounder" in that case.
Examine ` T ` and push clauses that may be relevant to proving the following sorts of goals ( and maybe others ) . Note that the type ` T ` must not be an unbound inference variable ; earlier parts of the logic should " flounder " in that case .
fn match_ty<I: Interner>(
    builder: &mut ClauseBuilder<'_, I>,
    environment: &Environment<I>,
    ty: &Ty<I>,
) -> Result<(), Floundered> {
    let interner = builder.interner();
    Ok(match ty.kind(interner) {
        TyKind::Adt(adt_id, _) => builder
            .db
            .adt_datum(*adt_id)
            .to_program_clauses(builder, environment),
        TyKind::OpaqueType(opaque_ty_id, _) => builder
            .db
            .opaque_ty_data(*opaque_ty_id)
            .to_program_clauses(builder, environment),
        TyKind::Error => {}
        TyKind::AssociatedType(type_id, _) => builder
            .db
            .associated_ty_data(*type_id)
            .to_program_clauses(builder, environment),
        TyKind::FnDef(fn_def_id, _) => builder
            .db
            .fn_def_datum(*fn_def_id)
            .to_program_clauses(builder, environment),
        TyKind::Tuple(_, _)
        | TyKind::Scalar(_)
        | TyKind::Str
        | TyKind::Slice(_)
        | TyKind::Raw(_, _)
        | TyKind::Ref(_, _, _)
        | TyKind::Array(_, _)
        | TyKind::Never
        | TyKind::Closure(_, _)
        | TyKind::Foreign(_)
        | TyKind::Generator(_, _)
        | TyKind::GeneratorWitness(_, _) => builder.push_fact(WellFormed::Ty(ty.clone())),
        TyKind::Placeholder(_) => {
            builder.push_clause(WellFormed::Ty(ty.clone()), Some(FromEnv::Ty(ty.clone())));
        }
        TyKind::Alias(AliasTy::Projection(proj)) => builder
            .db
            .associated_ty_data(proj.associated_ty_id)
            .to_program_clauses(builder, environment),
        TyKind::Alias(AliasTy::Opaque(opaque_ty)) => builder
            .db
            .opaque_ty_data(opaque_ty.opaque_ty_id)
            .to_program_clauses(builder, environment),
        TyKind::Function(_quantified_ty) => {
            builder.push_fact(WellFormed::Ty(ty.clone()));
        }
        TyKind::BoundVar(_) | TyKind::InferenceVar(_, _) => return Err(Floundered),
        TyKind::Dyn(_) => {}
    })
}
fn match_ty < I : Interner > ( builder : & mut ClauseBuilder < ' _ , I > , environment : & Environment < I > , ty : & Ty < I > , ) -> Result < ( ) , Floundered > { let interner = builder . interner ( ) ; Ok ( match ty . kind ( interner ) { TyKind :: Adt ( adt_id , _ ) => builder . db . adt_datum ( * adt_id ) . to_program_clauses ( builder , environment ) , TyKind :: OpaqueType ( opaque_ty_id , _ ) => builder . db . opaque_ty_data ( * opaque_ty_id ) . to_program_clauses ( builder , environment ) , TyKind :: Error => { } TyKind :: AssociatedType ( type_id , _ ) => builder . db . associated_ty_data ( * type_id ) . to_program_clauses ( builder , environment ) , TyKind :: FnDef ( fn_def_id , _ ) => builder . db . fn_def_datum ( * fn_def_id ) . to_program_clauses ( builder , environment ) , TyKind :: Tuple ( _ , _ ) | TyKind :: Scalar ( _ ) | TyKind :: Str | TyKind :: Slice ( _ ) | TyKind :: Raw ( _ , _ ) | TyKind :: Ref ( _ , _ , _ ) | TyKind :: Array ( _ , _ ) | TyKind :: Never | TyKind :: Closure ( _ , _ ) | TyKind :: Foreign ( _ ) | TyKind :: Generator ( _ , _ ) | TyKind :: GeneratorWitness ( _ , _ ) => builder . push_fact ( WellFormed :: Ty ( ty . clone ( ) ) ) , TyKind :: Placeholder ( _ ) => { builder . push_clause ( WellFormed :: Ty ( ty . clone ( ) ) , Some ( FromEnv :: Ty ( ty . clone ( ) ) ) ) ; } TyKind :: Alias ( AliasTy :: Projection ( proj ) ) => builder . db . associated_ty_data ( proj . associated_ty_id ) . to_program_clauses ( builder , environment ) , TyKind :: Alias ( AliasTy :: Opaque ( opaque_ty ) ) => builder . db . opaque_ty_data ( opaque_ty . opaque_ty_id ) . to_program_clauses ( builder , environment ) , TyKind :: Function ( _quantified_ty ) => { builder . push_fact ( WellFormed :: Ty ( ty . clone ( ) ) ) ; } TyKind :: BoundVar ( _ ) | TyKind :: InferenceVar ( _ , _ ) => return Err ( Floundered ) , TyKind :: Dyn ( _ ) => { } } ) }
Examine `T` and push clauses that may be relevant to proving the
following sorts of goals (and maybe others):
Examine ` T ` and push clauses that may be relevant to proving the following sorts of goals ( and maybe others ) :
builder
&mut ClauseBuilder<'_, I>
environment
&Environment<I>
ty
&Ty<I>