From 7f5ea92bbbcd92aab3ea0692d12527eb7cac30db Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Fri, 24 Jun 2022 15:14:50 +0200 Subject: parser: Disambiguate default expressions for const generics --- gcc/rust/parse/rust-parse-impl.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 708140a..a36107b 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2892,9 +2892,11 @@ Parser::parse_generic_param (EndTokenPred is_end_token) "% or %, got %qs", token_id_to_str (tok->get_id ())); - // TODO: At this point, we *know* that we are parsing a const - // expression. We should figure out how to disambiguate the default - // expr in the case of `const N: usize = M` + // At this point, we *know* that we are parsing a const + // expression + if (default_expr.get_kind () + == AST::ConstGenericArg::Kind::Ambiguous) + default_expr = default_expr.disambiguate_to_const (); } param = std::unique_ptr ( -- cgit v1.1