1
Fork 0

Use non-exhaustive matches for TyKind

Also no longer export noop async_drop_in_place_raw
This commit is contained in:
Daria Sukhonina 2024-04-17 20:49:53 +03:00
parent 24a24ec6ba
commit 80c0b7e90f
13 changed files with 150 additions and 182 deletions

View file

@ -819,7 +819,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx> {
let self_ty = goal.predicate.self_ty();
let discriminant_ty = match *self_ty.kind() {
let async_destructor_ty = match *self_ty.kind() {
ty::Bool
| ty::Char
| ty::Int(..)
@ -833,14 +833,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
| ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Infer(ty::IntVar(..) | ty::FloatVar(..))
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Pat(..)
| ty::Never
| ty::Adt(_, _)
| ty::Str
| ty::Slice(_)
| ty::Dynamic(_, _, _)
| ty::Tuple(_)
| ty::Error(_) => self_ty.async_destructor_ty(ecx.tcx(), goal.param_env),
@ -858,10 +854,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
"unexpected self ty `{:?}` when normalizing `<T as AsyncDestruct>::AsyncDestructor`",
goal.predicate.self_ty()
),
_ => bug!(
"`consider_builtin_async_destruct_candidate` is not yet implemented for type: {self_ty:?}"
),
};
ecx.probe_misc_candidate("builtin async destruct").enter(|ecx| {
ecx.eq(goal.param_env, goal.predicate.term, discriminant_ty.into())
ecx.eq(goal.param_env, goal.predicate.term, async_destructor_ty.into())
.expect("expected goal term to be fully unconstrained");
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})

View file

@ -1100,14 +1100,14 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
| ty::Infer(ty::InferTy::IntVar(_) | ty::InferTy::FloatVar(..)) => true,
// type parameters, opaques, and unnormalized projections don't have
// a known discriminant and may need to be normalized further or rely
// a known async destructor and may need to be normalized further or rely
// on param env for async destructor projections
ty::Param(_)
| ty::Foreign(_)
| ty::Alias(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..)
| ty::Infer(_)
| ty::Error(_) => false,
}
} else if lang_items.pointee_trait() == Some(trait_ref.def_id) {