Begin to implement type system layer of unsafe binders
This commit is contained in:
@@ -545,6 +545,7 @@ where
|
||||
| ty::Ref(_, _, _)
|
||||
| ty::FnDef(_, _)
|
||||
| ty::FnPtr(..)
|
||||
| ty::UnsafeBinder(_)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::CoroutineClosure(..)
|
||||
@@ -634,6 +635,7 @@ where
|
||||
| ty::Ref(_, _, _)
|
||||
| ty::FnDef(_, _)
|
||||
| ty::FnPtr(..)
|
||||
| ty::UnsafeBinder(_)
|
||||
| ty::Alias(..)
|
||||
| ty::Closure(..)
|
||||
| ty::CoroutineClosure(..)
|
||||
|
||||
@@ -83,6 +83,8 @@ where
|
||||
.map(|bty| bty.instantiate(cx, args))
|
||||
.collect()),
|
||||
|
||||
ty::UnsafeBinder(bound_ty) => Ok(vec![bound_ty.into()]),
|
||||
|
||||
// For `PhantomData<T>`, we pass `T`.
|
||||
ty::Adt(def, args) if def.is_phantom_data() => Ok(vec![ty::Binder::dummy(args.type_at(0))]),
|
||||
|
||||
@@ -144,6 +146,8 @@ where
|
||||
panic!("unexpected type `{ty:?}`")
|
||||
}
|
||||
|
||||
ty::UnsafeBinder(bound_ty) => Ok(vec![bound_ty.into()]),
|
||||
|
||||
// impl Sized for ()
|
||||
// impl Sized for (T1, T2, .., Tn) where Tn: Sized if n >= 1
|
||||
ty::Tuple(tys) => Ok(tys.last().map_or_else(Vec::new, |ty| vec![ty::Binder::dummy(ty)])),
|
||||
@@ -239,6 +243,8 @@ where
|
||||
}
|
||||
},
|
||||
|
||||
ty::UnsafeBinder(_) => Err(NoSolution),
|
||||
|
||||
// impl Copy/Clone for CoroutineWitness where T: Copy/Clone forall T in coroutine_hidden_types
|
||||
ty::CoroutineWitness(def_id, args) => Ok(ecx
|
||||
.cx()
|
||||
@@ -374,6 +380,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Pat(_, _)
|
||||
| ty::UnsafeBinder(_)
|
||||
| ty::Alias(_, _)
|
||||
| ty::Param(_)
|
||||
| ty::Placeholder(..)
|
||||
@@ -544,6 +551,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I:
|
||||
| ty::Coroutine(_, _)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::UnsafeBinder(_)
|
||||
| ty::Tuple(_)
|
||||
| ty::Alias(_, _)
|
||||
| ty::Param(_)
|
||||
@@ -694,7 +702,8 @@ pub(in crate::solve) fn extract_fn_def_from_const_callable<I: Interner>(
|
||||
| ty::Param(_)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
|
||||
| ty::Error(_) => return Err(NoSolution),
|
||||
| ty::Error(_)
|
||||
| ty::UnsafeBinder(_) => return Err(NoSolution),
|
||||
|
||||
ty::Bound(..)
|
||||
| ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
|
||||
@@ -764,6 +773,10 @@ pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
|
||||
| ty::Coroutine(_, _)
|
||||
| ty::CoroutineWitness(_, _) => Err(NoSolution),
|
||||
|
||||
// FIXME(unsafe_binders): Unsafe binders could implement `~const Drop`
|
||||
// if their inner type implements it.
|
||||
ty::UnsafeBinder(_) => Err(NoSolution),
|
||||
|
||||
ty::Dynamic(..) | ty::Param(_) | ty::Alias(..) | ty::Placeholder(_) | ty::Foreign(_) => {
|
||||
Err(NoSolution)
|
||||
}
|
||||
|
||||
@@ -619,6 +619,11 @@ where
|
||||
Some(tail_ty) => Ty::new_projection(cx, metadata_def_id, [tail_ty]),
|
||||
},
|
||||
|
||||
ty::UnsafeBinder(_) => {
|
||||
// FIXME(unsafe_binder): Figure out how to handle pointee for unsafe binders.
|
||||
todo!()
|
||||
}
|
||||
|
||||
ty::Infer(
|
||||
ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_),
|
||||
)
|
||||
@@ -822,6 +827,11 @@ where
|
||||
| ty::Tuple(_)
|
||||
| ty::Error(_) => self_ty.discriminant_ty(ecx.cx()),
|
||||
|
||||
ty::UnsafeBinder(_) => {
|
||||
// FIXME(unsafe_binders): instantiate this with placeholders?? i guess??
|
||||
todo!("discr subgoal...")
|
||||
}
|
||||
|
||||
// We do not call `Ty::discriminant_ty` on alias, param, or placeholder
|
||||
// types, which return `<self_ty as DiscriminantKind>::Discriminant`
|
||||
// (or ICE in the case of placeholders). Projecting a type to itself
|
||||
@@ -869,6 +879,11 @@ where
|
||||
| ty::Tuple(_)
|
||||
| ty::Error(_) => self_ty.async_destructor_ty(ecx.cx()),
|
||||
|
||||
ty::UnsafeBinder(_) => {
|
||||
// FIXME(unsafe_binders): Instantiate the binder with placeholders I guess.
|
||||
todo!()
|
||||
}
|
||||
|
||||
// We do not call `Ty::async_destructor_ty` on alias, param, or placeholder
|
||||
// types, which return `<self_ty as AsyncDestruct>::AsyncDestructor`
|
||||
// (or ICE in the case of placeholders). Projecting a type to itself
|
||||
|
||||
@@ -1100,7 +1100,8 @@ where
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Adt(_, _) => {
|
||||
| ty::Adt(_, _)
|
||||
| ty::UnsafeBinder(_) => {
|
||||
let mut disqualifying_impl = None;
|
||||
self.cx().for_each_relevant_impl(
|
||||
goal.predicate.def_id(),
|
||||
|
||||
Reference in New Issue
Block a user