public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] rust: add bound parsing in parse_generic_arg. Date: Thu, 12 Jan 2023 07:44:09 +0000 (GMT) [thread overview] Message-ID: <20230112074409.369A9385B529@sourceware.org> (raw) https://gcc.gnu.org/g:2f36f38054279e66b1af55995e41dd14e56beb25 commit 2f36f38054279e66b1af55995e41dd14e56beb25 Author: mxlol233 <mxlol233@outlook.com> Date: Wed Jan 4 21:21:59 2023 +0800 rust: add bound parsing in parse_generic_arg. Signed-off-by: Xiao Ma <mxlol233@outlook.com> Diff: --- gcc/rust/parse/rust-parse-impl.h | 17 +++++++++++++++++ gcc/testsuite/rust/compile/bounds.rs | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 864fb86ce06..86124ee658e 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 ()); diff --git a/gcc/testsuite/rust/compile/bounds.rs b/gcc/testsuite/rust/compile/bounds.rs new file mode 100644 index 00000000000..ecb10d81f65 --- /dev/null +++ b/gcc/testsuite/rust/compile/bounds.rs @@ -0,0 +1,10 @@ +trait Foo { + type Bar; +} + +trait Copy {} + + +fn c<F: Foo<Bar: Foo>>() where F::Bar: Copy { // { dg-warning "function is never used: 'c'" } +} +
reply other threads:[~2023-01-12 7:44 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230112074409.369A9385B529@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).