From 67f56671d0384bdb2d92dddebfbf42510b16e0f7 Mon Sep 17 00:00:00 2001 From: kadmin Date: Sat, 8 Jan 2022 09:28:12 +0000 Subject: 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. --- compiler/rustc_parse/src/parser/path.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'compiler/rustc_parse') diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 8f272820015..531cac1f57e 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -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: -- cgit 1.4.1-3-g733a5