diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 17 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/bounds.rs | 10 |
2 files changed, 27 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 ()); diff --git a/gcc/testsuite/rust/compile/bounds.rs b/gcc/testsuite/rust/compile/bounds.rs new file mode 100644 index 0000000..ecb10d8 --- /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'" } +} + |