Use Term in ProjectionPredicate

ProjectionPredicate should be able to handle both associated types and consts so this adds the
first step of that. It mainly just pipes types all the way down, not entirely sure how to handle
consts, but hopefully that'll come with time.
This commit is contained in:
kadmin 2022-01-08 09:28:12 +00:00
parent fb57b7518d
commit 67f56671d0
51 changed files with 274 additions and 259 deletions

View file

@ -503,17 +503,15 @@ impl<'a> Parser<'a> {
) -> PResult<'a, AssocConstraintKind> {
let arg = self.parse_generic_arg(None)?;
let span = ident.span.to(self.prev_token.span);
let ty = match arg {
Some(GenericArg::Type(ty)) => ty,
Some(GenericArg::Const(c)) => {
return Ok(AssocConstraintKind::Equality { term: c.into() });
}
let term = match arg {
Some(GenericArg::Type(ty)) => ty.into(),
Some(GenericArg::Const(c)) => c.into(),
Some(GenericArg::Lifetime(lt)) => {
self.struct_span_err(span, "associated lifetimes are not supported")
.span_label(lt.ident.span, "the lifetime is given here")
.help("if you meant to specify a trait object, write `dyn Trait + 'lifetime`")
.emit();
self.mk_ty(span, ast::TyKind::Err)
self.mk_ty(span, ast::TyKind::Err).into()
}
None => {
let after_eq = eq.shrink_to_hi();
@ -542,7 +540,7 @@ impl<'a> Parser<'a> {
return Err(err);
}
};
Ok(AssocConstraintKind::Equality { term: ty.into() })
Ok(AssocConstraintKind::Equality { term })
}
/// We do not permit arbitrary expressions as const arguments. They must be one of: