diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 18acc9318ae1..243bc4420219 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -4922,8 +4922,8 @@ Parser::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) diff --git a/gcc/testsuite/rust/compile/auto_trait_invalid.rs b/gcc/testsuite/rust/compile/auto_trait_invalid.rs index 16dca5718491..66e45531f5d8 100644 --- a/gcc/testsuite/rust/compile/auto_trait_invalid.rs +++ b/gcc/testsuite/rust/compile/auto_trait_invalid.rs @@ -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" }