[COMMITTED 018/101] gccrs: Reject auto traits with super trait

arthur.cohen@embecosm.com arthur.cohen@embecosm.com
Tue Jan 30 12:06:34 GMT 2024


From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc
index 37d3668a9e0..aeae6035db8 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -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);
-- 
2.42.1



More information about the Gcc-rust mailing list