Skip to content

Commit

Permalink
Add check for associated items on auto traits
Browse files Browse the repository at this point in the history
Reject rust code with associated items on auto traits.

gcc/rust/ChangeLog:

	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add auto
	trait associated item check in AST validation pass.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Nov 20, 2023
1 parent 6f90394 commit 2a995c2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gcc/rust/checks/errors/rust-ast-validation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ ASTValidation::visit (AST::Trait &trait)
rust_error_at (trait.get_type_param_bounds ()[0]->get_locus (),
ErrorCode::E0568,
"auto traits cannot have super traits");
if (trait.has_trait_items ())
rust_error_at (trait.get_locus (), ErrorCode::E0380,
"auto traits cannot have methods or associated items");
}

AST::ContextualASTVisitor::visit (trait);
Expand Down

0 comments on commit 2a995c2

Please sign in to comment.