Fully implement ConstArgHasType
This commit is contained in:
@@ -934,6 +934,30 @@ pub struct Placeholder<T> {
|
||||
pub universe: UniverseIndex,
|
||||
pub bound: T,
|
||||
}
|
||||
impl Placeholder<BoundVar> {
|
||||
pub fn find_const_ty_from_env<'tcx>(self, env: ParamEnv<'tcx>) -> Ty<'tcx> {
|
||||
let mut candidates = env.caller_bounds().iter().filter_map(|clause| {
|
||||
// `ConstArgHasType` are never desugared to be higher ranked.
|
||||
match clause.kind().skip_binder() {
|
||||
ty::ClauseKind::ConstArgHasType(placeholder_ct, ty) => {
|
||||
assert!(!(placeholder_ct, ty).has_escaping_bound_vars());
|
||||
|
||||
match placeholder_ct.kind() {
|
||||
ty::ConstKind::Placeholder(placeholder_ct) if placeholder_ct == self => {
|
||||
Some(ty)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
|
||||
let ty = candidates.next().unwrap();
|
||||
assert!(candidates.next().is_none());
|
||||
ty
|
||||
}
|
||||
}
|
||||
|
||||
pub type PlaceholderRegion = Placeholder<BoundRegion>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user