Remove DynKind
This commit is contained in:
@@ -669,7 +669,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
// These may potentially implement `FnPtr`
|
||||
ty::Placeholder(..)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Dynamic(_, _)
|
||||
| ty::Alias(_, _)
|
||||
| ty::Infer(_)
|
||||
| ty::Param(..)
|
||||
@@ -991,7 +991,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
match (source.kind(), target.kind()) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
|
||||
(&ty::Dynamic(a_data, a_region, ty::Dyn), &ty::Dynamic(b_data, b_region, ty::Dyn)) => {
|
||||
(&ty::Dynamic(a_data, a_region), &ty::Dynamic(b_data, b_region)) => {
|
||||
// Upcast coercions permit several things:
|
||||
//
|
||||
// 1. Dropping auto traits, e.g., `Foo + Send` to `Foo`
|
||||
@@ -1054,7 +1054,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
// `T` -> `Trait`
|
||||
(_, &ty::Dynamic(_, _, ty::Dyn)) => {
|
||||
(_, &ty::Dynamic(_, _)) => {
|
||||
candidates.vec.push(BuiltinUnsizeCandidate);
|
||||
}
|
||||
|
||||
@@ -1327,7 +1327,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
| ty::Pat(_, _)
|
||||
| ty::FnPtr(..)
|
||||
| ty::UnsafeBinder(_)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Dynamic(_, _)
|
||||
| ty::Closure(..)
|
||||
| ty::CoroutineClosure(..)
|
||||
| ty::Coroutine(_, _)
|
||||
|
||||
@@ -1023,10 +1023,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
|
||||
let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
|
||||
|
||||
let ty::Dynamic(a_data, a_region, ty::Dyn) = *a_ty.kind() else {
|
||||
let ty::Dynamic(a_data, a_region) = *a_ty.kind() else {
|
||||
bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
|
||||
};
|
||||
let ty::Dynamic(b_data, b_region, ty::Dyn) = *b_ty.kind() else {
|
||||
let ty::Dynamic(b_data, b_region) = *b_ty.kind() else {
|
||||
bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
|
||||
};
|
||||
|
||||
@@ -1062,10 +1062,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
debug!(?source, ?target, "confirm_builtin_unsize_candidate");
|
||||
|
||||
Ok(match (source.kind(), target.kind()) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (auto traits and lifetime subtyping).
|
||||
(&ty::Dynamic(data_a, r_a, dyn_a), &ty::Dynamic(data_b, r_b, dyn_b))
|
||||
if dyn_a == dyn_b =>
|
||||
{
|
||||
// `dyn Trait + Kx + 'a` -> `dyn Trait + Ky + 'b` (auto traits and lifetime subtyping).
|
||||
(&ty::Dynamic(data_a, r_a), &ty::Dynamic(data_b, r_b)) => {
|
||||
// See `assemble_candidates_for_unsizing` for more info.
|
||||
// We already checked the compatibility of auto traits within `assemble_candidates_for_unsizing`.
|
||||
let existential_predicates = if data_b.principal().is_some() {
|
||||
@@ -1098,7 +1096,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
.map(ty::Binder::dummy),
|
||||
)
|
||||
};
|
||||
let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b, dyn_a);
|
||||
let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b);
|
||||
|
||||
// Require that the traits involved in this upcast are **equal**;
|
||||
// only the **lifetime bound** is changed.
|
||||
@@ -1122,7 +1120,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
// `T` -> `dyn Trait`
|
||||
(_, &ty::Dynamic(data, r, ty::Dyn)) => {
|
||||
(_, &ty::Dynamic(data, r)) => {
|
||||
let mut object_dids = data.auto_traits().chain(data.principal_def_id());
|
||||
if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
|
||||
return Err(SelectionError::TraitDynIncompatible(did));
|
||||
|
||||
Reference in New Issue
Block a user