Pack Term
in the same way as GenericArg
.
This shrinks the `PredicateS` type, which is instanted frequently.
This commit is contained in:
parent
d565d51071
commit
79db32b64e
20 changed files with 191 additions and 108 deletions
|
@ -1183,11 +1183,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// `<T as Iterator>::Item = u32`
|
||||
let assoc_item_def_id = projection_ty.skip_binder().item_def_id;
|
||||
let def_kind = tcx.def_kind(assoc_item_def_id);
|
||||
match (def_kind, term) {
|
||||
(hir::def::DefKind::AssocTy, ty::Term::Ty(_))
|
||||
| (hir::def::DefKind::AssocConst, ty::Term::Const(_)) => (),
|
||||
match (def_kind, term.unpack()) {
|
||||
(hir::def::DefKind::AssocTy, ty::TermKind::Ty(_))
|
||||
| (hir::def::DefKind::AssocConst, ty::TermKind::Const(_)) => (),
|
||||
(_, _) => {
|
||||
let got = if let ty::Term::Ty(_) = term { "type" } else { "constant" };
|
||||
let got = if let Some(_) = term.ty() { "type" } else { "constant" };
|
||||
let expected = def_kind.descr(assoc_item_def_id);
|
||||
tcx.sess
|
||||
.struct_span_err(
|
||||
|
@ -1375,9 +1375,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let pred = bound_predicate.rebind(pred);
|
||||
// A `Self` within the original bound will be substituted with a
|
||||
// `trait_object_dummy_self`, so check for that.
|
||||
let references_self = match pred.skip_binder().term {
|
||||
ty::Term::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
|
||||
ty::Term::Const(c) => c.ty().walk().any(|arg| arg == dummy_self.into()),
|
||||
let references_self = match pred.skip_binder().term.unpack() {
|
||||
ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
|
||||
ty::TermKind::Const(c) => {
|
||||
c.ty().walk().any(|arg| arg == dummy_self.into())
|
||||
}
|
||||
};
|
||||
|
||||
// If the projection output contains `Self`, force the user to
|
||||
|
|
|
@ -21,7 +21,7 @@ use rustc_infer::infer::{self, InferOk};
|
|||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
|
||||
use rustc_middle::ty::{
|
||||
self, AssocKind, DefIdTree, GenericParamDefKind, ProjectionPredicate, ProjectionTy, Term,
|
||||
self, AssocKind, DefIdTree, GenericParamDefKind, ProjectionPredicate, ProjectionTy,
|
||||
ToPredicate, Ty, TypeVisitable,
|
||||
};
|
||||
use rustc_span::symbol::Ident;
|
||||
|
@ -349,7 +349,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
opt_output_ty.zip(opt_output_assoc_item).map(|(output_ty, output_assoc_item)| {
|
||||
ty::Binder::dummy(ty::PredicateKind::Projection(ProjectionPredicate {
|
||||
projection_ty: ProjectionTy { substs, item_def_id: output_assoc_item.def_id },
|
||||
term: Term::Ty(output_ty),
|
||||
term: output_ty.into(),
|
||||
}))
|
||||
.to_predicate(self.tcx)
|
||||
});
|
||||
|
|
|
@ -271,11 +271,11 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
for projection in data.projection_bounds() {
|
||||
match projection.skip_binder().term {
|
||||
ty::Term::Ty(ty) => {
|
||||
match projection.skip_binder().term.unpack() {
|
||||
ty::TermKind::Ty(ty) => {
|
||||
self.add_constraints_from_ty(current, ty, self.invariant);
|
||||
}
|
||||
ty::Term::Const(c) => {
|
||||
ty::TermKind::Const(c) => {
|
||||
self.add_constraints_from_const(current, c, self.invariant)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue