diff options
author | mxlol233 <mxlol233@outlook.com> | 2023-01-04 21:21:59 +0800 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-04-06 10:47:16 +0200 |
commit | ef792b9658d6bde0001d7340b10d2d3193ecbc09 (patch) | |
tree | 54a19bae05051089fda9bd9c21ded8c15412453e /gcc/rust | |
parent | d9e05700ac3085f29e95d53b3ec59c22adbc7c71 (diff) | |
download | gcc-ef792b9658d6bde0001d7340b10d2d3193ecbc09.zip gcc-ef792b9658d6bde0001d7340b10d2d3193ecbc09.tar.gz gcc-ef792b9658d6bde0001d7340b10d2d3193ecbc09.tar.bz2 |
gccrs: rust: add bound parsing in parse_generic_arg.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_generic_arg): Add proper bound parsing.
gcc/testsuite/ChangeLog:
* rust/compile/bounds.rs: New test.
Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 17 |
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 cbd40ef..959e033 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6198,6 +6198,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 ()); |