1
Fork 0

Reject defaultness on free consts

This commit is contained in:
León Orell Valerian Liehr 2023-11-11 15:30:25 +01:00
parent 9ab0749ce3
commit df3b981a3a
No known key found for this signature in database
GPG key ID: D17A07215F68E713
3 changed files with 43 additions and 13 deletions

View file

@ -1008,12 +1008,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
_ => {}
}
}
ItemKind::Const(box ConstItem { defaultness, expr: None, .. }) => {
ItemKind::Const(box ConstItem { defaultness, expr, .. }) => {
self.check_defaultness(item.span, *defaultness);
self.session.emit_err(errors::ConstWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
if expr.is_none() {
self.session.emit_err(errors::ConstWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
}
}
ItemKind::Static(box StaticItem { expr: None, .. }) => {
self.session.emit_err(errors::StaticWithoutBody {