aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-01-04 20:12:07 +0000
committerGitHub <noreply@github.com>2023-01-04 20:12:07 +0000
commit8742e54052355beaa18fef9242a87fe84de51adb (patch)
treef5caa54136169a942ef603b7a6dca571516432a9 /gcc/rust/parse/rust-parse-impl.h
parent0152926ab36ba52153f3f457f6f3bb02bb274073 (diff)
parent2f36f38054279e66b1af55995e41dd14e56beb25 (diff)
downloadgcc-8742e54052355beaa18fef9242a87fe84de51adb.zip
gcc-8742e54052355beaa18fef9242a87fe84de51adb.tar.gz
gcc-8742e54052355beaa18fef9242a87fe84de51adb.tar.bz2
Merge #1716
1716: rust: add bound parsing in parse_generic_arg. r=philberty a=TuringKi This patch adds parsing for generic parameters like: <F: Foo<Bar: Foo>>. In current version, this pattern leads to endless loop. Co-authored-by: mxlol233 <mxlol233@outlook.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 864fb86..86124ee 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -6189,6 +6189,23 @@ Parser<ManagedTokenSource>::parse_generic_arg ()
else
return AST::GenericArg::create_error ();
}
+ else if (next_tok->get_id () == COLON)
+ {
+ lexer.skip_token (); // skip ident
+ lexer.skip_token (); // skip colon
+
+ auto tok = lexer.peek_token ();
+ std::vector<std::unique_ptr<AST::TypeParamBound>> bounds
+ = parse_type_param_bounds ();
+
+ auto type = std::unique_ptr<AST::TraitObjectType> (
+ new AST::TraitObjectType (std::move (bounds), tok->get_locus (),
+ false));
+ if (type)
+ return AST::GenericArg::create_type (std::move (type));
+ else
+ return AST::GenericArg::create_error ();
+ }
lexer.skip_token ();
return AST::GenericArg::create_ambiguous (tok->get_str (),
tok->get_locus ());