]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Reject auto traits with super trait
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 20 Nov 2023 13:04:35 +0000 (14:04 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:43 +0000 (12:36 +0100)
Reject auto traits containing a super trait bound during AST validation
pass.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Reject
auto traits with super traits.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/checks/errors/rust-ast-validation.cc

index 37d3668a9e046565362a36a6de8b57ce0b915d02..aeae6035db8f708a7b69253922d31c8c23af33aa 100644 (file)
@@ -105,6 +105,10 @@ ASTValidation::visit (AST::Trait &trait)
        rust_error_at (trait.get_generic_params ()[0]->get_locus (),
                       ErrorCode::E0567,
                       "auto traits cannot have generic parameters");
+      if (trait.has_type_param_bounds ())
+       rust_error_at (trait.get_type_param_bounds ()[0]->get_locus (),
+                      ErrorCode::E0568,
+                      "auto traits cannot have super traits");
     }
 
   AST::ContextualASTVisitor::visit (trait);