1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6 rt::<ast::ItemConst>("const value = #{}");
7}
8
9#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
11#[rune(parse = "meta_only")]
12#[non_exhaustive]
13pub struct ItemConst {
14 #[rune(iter, meta)]
16 pub attributes: Vec<ast::Attribute>,
17 #[rune(option, meta)]
19 pub visibility: ast::Visibility,
20 #[rune(meta)]
22 pub const_token: T![const],
23 pub name: ast::Ident,
25 pub eq: T![=],
27 pub expr: ast::Expr,
29 #[rune(skip)]
31 pub(crate) id: ItemId,
32}
33
34impl ItemConst {
35 pub(crate) fn descriptive_span(&self) -> Span {
38 self.const_token.span().join(self.name.span())
39 }
40}
41
42item_parse!(Const, ItemConst, "constant item");