1
Fork 0

Add term to ExistentialProjection

Also prevent ICE when adding a const in associated const equality.
This commit is contained in:
kadmin 2022-01-13 07:39:58 +00:00
parent f396888c4d
commit 1c1ce2fbda
35 changed files with 213 additions and 71 deletions

View file

@ -1136,9 +1136,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.associated_items(candidate.def_id())
.filter_by_name_unhygienic(assoc_ident.name)
.find(|i| {
i.kind == ty::AssocKind::Type && i.ident.normalize_to_macros_2_0() == assoc_ident
(i.kind == ty::AssocKind::Type || i.kind == ty::AssocKind::Const)
&& i.ident.normalize_to_macros_2_0() == assoc_ident
})
.expect("missing associated type");
// FIXME(associated_const_equality): need to handle assoc_consts here as well.
if assoc_ty.kind == ty::AssocKind::Const {
tcx.sess
.struct_span_err(path_span, &format!("associated const equality is incomplete"))
.span_label(path_span, "cannot yet relate associated const")
.emit();
return Err(ErrorReported);
}
if !assoc_ty.vis.is_accessible_from(def_scope, tcx) {
tcx.sess

View file

@ -308,11 +308,14 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
}
for projection in data.projection_bounds() {
self.add_constraints_from_ty(
current,
projection.skip_binder().ty,
self.invariant,
);
match projection.skip_binder().term {
ty::Term::Ty(ty) => {
self.add_constraints_from_ty(current, ty, self.invariant);
}
ty::Term::Const(c) => {
self.add_constraints_from_const(current, c, self.invariant)
}
}
}
}