Skip to content

Commit

Permalink
gccrs: [E0380] Use of auto trait with method or associated item
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_trait):
	added errorcode & updated error message.

gcc/testsuite/ChangeLog:

	* rust/compile/auto_trait_invalid.rs:
	Updated comment.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
  • Loading branch information
MahadMuhammad authored and philberty committed Aug 17, 2023
1 parent 0110145 commit 3ef836f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4923,8 +4923,8 @@ Parser<ManagedTokenSource>::parse_trait (AST::Visibility vis,

if (is_auto_trait && !trait_items.empty ())
{
add_error (
Error (locus, "associated items are forbidden within auto traits"));
add_error (Error (locus, ErrorCode::E0380,
"auto traits cannot have associated items"));

// FIXME: unsure if this should be done at parsing time or not
for (const auto &item : trait_items)
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/auto_trait_invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![feature(optin_builtin_traits)]

unsafe auto trait Invalid { // { dg-error "associated items are forbidden within auto traits" }
unsafe auto trait Invalid { // { dg-error "auto traits cannot have associated items" }
fn foo(); // { dg-message "remove this item" }

fn bar() {} // { dg-message "remove this item" }
Expand Down

0 comments on commit 3ef836f

Please sign in to comment.