Split item bounds and item super predicates
This commit is contained in:
parent
a128516cf9
commit
aa39dbb962
20 changed files with 186 additions and 46 deletions
|
@ -403,8 +403,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
|
||||
let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0];
|
||||
|
||||
self.tcx.explicit_item_bounds(def_id).iter_instantiated_copied(self.tcx, args).find_map(
|
||||
|(predicate, _)| {
|
||||
self.tcx
|
||||
.explicit_item_super_predicates(def_id)
|
||||
.iter_instantiated_copied(self.tcx, args)
|
||||
.find_map(|(predicate, _)| {
|
||||
predicate
|
||||
.kind()
|
||||
.map_bound(|kind| match kind {
|
||||
|
@ -417,8 +419,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
})
|
||||
.no_bound_vars()
|
||||
.flatten()
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -299,8 +299,11 @@ impl<T> Trait<T> for X {
|
|||
}
|
||||
(ty::Dynamic(t, _, ty::DynKind::Dyn), ty::Alias(ty::Opaque, alias))
|
||||
if let Some(def_id) = t.principal_def_id()
|
||||
&& tcx.explicit_item_bounds(alias.def_id).skip_binder().iter().any(
|
||||
|(pred, _span)| match pred.kind().skip_binder() {
|
||||
&& tcx
|
||||
.explicit_item_super_predicates(alias.def_id)
|
||||
.skip_binder()
|
||||
.iter()
|
||||
.any(|(pred, _span)| match pred.kind().skip_binder() {
|
||||
ty::ClauseKind::Trait(trait_predicate)
|
||||
if trait_predicate.polarity
|
||||
== ty::ImplPolarity::Positive =>
|
||||
|
@ -308,8 +311,7 @@ impl<T> Trait<T> for X {
|
|||
trait_predicate.def_id() == def_id
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
) =>
|
||||
}) =>
|
||||
{
|
||||
diag.help(format!(
|
||||
"you can box the `{}` to coerce it to `Box<{}>`, but you'll have to \
|
||||
|
@ -412,7 +414,7 @@ impl<T> Trait<T> for X {
|
|||
ty::Alias(..) => values.expected,
|
||||
_ => values.found,
|
||||
};
|
||||
let preds = tcx.explicit_item_bounds(opaque_ty.def_id);
|
||||
let preds = tcx.explicit_item_super_predicates(opaque_ty.def_id);
|
||||
for (pred, _span) in preds.skip_binder() {
|
||||
let ty::ClauseKind::Trait(trait_predicate) = pred.kind().skip_binder()
|
||||
else {
|
||||
|
|
|
@ -300,7 +300,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
|||
alias_ty: ty::AliasTy<'tcx>,
|
||||
) -> impl Iterator<Item = ty::Region<'tcx>> {
|
||||
let tcx = self.tcx;
|
||||
let bounds = tcx.item_bounds(alias_ty.def_id);
|
||||
let bounds = tcx.item_super_predicates(alias_ty.def_id);
|
||||
trace!("{:#?}", bounds.skip_binder());
|
||||
bounds
|
||||
.iter_instantiated(tcx, alias_ty.args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue