gcc/rust/ChangeLog:
* checks/errors/rust-ast-validation.cc
(ASTValidation::visit): Allow constant items lacking expressions
if and only if they're associated with a trait definition, not a
trait implementation.
gcc/testsuite/ChangeLog:
* rust/compile/issue-3541-1.rs: New test.
* rust/compile/issue-3541-2.rs: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
void
ASTValidation::visit (AST::ConstantItem &const_item)
{
- if (!const_item.has_expr () && ctx.peek () != Kind::TRAIT_IMPL)
+ if (!const_item.has_expr () && ctx.peek () != Kind::TRAIT)
{
rust_error_at (const_item.get_locus (),
"associated constant in %<impl%> without body");
--- /dev/null
+impl B for u32 {
+ const BAR: i32; // { dg-error "associated constant in .impl." }
+}
+
+trait B {}
--- /dev/null
+trait B {
+ const BAR: i32;
+}