Add bound_impl_subject and bound_return_ty
This commit is contained in:
parent
96a69dce2c
commit
955fcad758
8 changed files with 26 additions and 21 deletions
|
@ -32,7 +32,7 @@ use rustc_middle::traits::select::OverflowError;
|
|||
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable};
|
||||
use rustc_middle::ty::{self, EarlyBinder, Term, ToPredicate, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Term, ToPredicate, Ty, TyCtxt};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -2005,16 +2005,16 @@ fn confirm_impl_candidate<'cx, 'tcx>(
|
|||
let substs = obligation.predicate.substs.rebase_onto(tcx, trait_def_id, substs);
|
||||
let substs =
|
||||
translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.defining_node);
|
||||
let ty = tcx.type_of(assoc_ty.item.def_id);
|
||||
let ty = tcx.bound_type_of(assoc_ty.item.def_id);
|
||||
let is_const = matches!(tcx.def_kind(assoc_ty.item.def_id), DefKind::AssocConst);
|
||||
let term: ty::Term<'tcx> = if is_const {
|
||||
let term: ty::EarlyBinder<ty::Term<'tcx>> = if is_const {
|
||||
let identity_substs =
|
||||
crate::traits::InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
|
||||
let did = ty::WithOptConstParam::unknown(assoc_ty.item.def_id);
|
||||
let kind = ty::ConstKind::Unevaluated(ty::Unevaluated::new(did, identity_substs));
|
||||
tcx.mk_const(ty::ConstS { ty, kind }).into()
|
||||
ty.map_bound(|ty| tcx.mk_const(ty::ConstS { ty, kind }).into())
|
||||
} else {
|
||||
ty.into()
|
||||
ty.map_bound(|ty| ty.into())
|
||||
};
|
||||
if substs.len() != tcx.generics_of(assoc_ty.item.def_id).count() {
|
||||
let err = tcx.ty_error_with_message(
|
||||
|
@ -2024,7 +2024,7 @@ fn confirm_impl_candidate<'cx, 'tcx>(
|
|||
Progress { term: err.into(), obligations: nested }
|
||||
} else {
|
||||
assoc_ty_own_obligations(selcx, obligation, &mut nested);
|
||||
Progress { term: EarlyBinder(term).subst(tcx, substs), obligations: nested }
|
||||
Progress { term: term.subst(tcx, substs), obligations: nested }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue