|
13 | 13 | //! - [`FnDecl`], [`FnHeader`] and [`Param`]: Metadata associated with a function declaration.
|
14 | 14 | //! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters.
|
15 | 15 | //! - [`EnumDef`] and [`Variant`]: Enum declaration.
|
16 |
| -//! - [`Lit`] and [`LitKind`]: Literal expressions. |
| 16 | +//! - [`MetaItemLit`] and [`LitKind`]: Literal expressions. |
17 | 17 | //! - [`MacroDef`], [`MacStmtStyle`], [`MacCall`], [`MacDelimiter`]: Macro definition and invocation.
|
18 | 18 | //! - [`Attribute`]: Metadata associated with item.
|
19 | 19 | //! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
|
@@ -489,7 +489,7 @@ pub enum NestedMetaItem {
|
489 | 489 | /// A literal.
|
490 | 490 | ///
|
491 | 491 | /// E.g., `"foo"`, `64`, `true`.
|
492 |
| - Literal(Lit), |
| 492 | + Literal(MetaItemLit), |
493 | 493 | }
|
494 | 494 |
|
495 | 495 | /// A spanned compile-time attribute item.
|
@@ -518,7 +518,7 @@ pub enum MetaItemKind {
|
518 | 518 | /// Name value meta item.
|
519 | 519 | ///
|
520 | 520 | /// E.g., `feature = "foo"` as in `#[feature = "foo"]`.
|
521 |
| - NameValue(Lit), |
| 521 | + NameValue(MetaItemLit), |
522 | 522 | }
|
523 | 523 |
|
524 | 524 | /// A block (`{ .. }`).
|
@@ -1599,12 +1599,12 @@ pub enum AttrArgs {
|
1599 | 1599 | }
|
1600 | 1600 |
|
1601 | 1601 | // The RHS of an `AttrArgs::Eq` starts out as an expression. Once macro
|
1602 |
| -// expansion is completed, all cases end up either as a literal, which is the |
1603 |
| -// form used after lowering to HIR, or as an error. |
| 1602 | +// expansion is completed, all cases end up either as a meta item literal, |
| 1603 | +// which is the form used after lowering to HIR, or as an error. |
1604 | 1604 | #[derive(Clone, Encodable, Decodable, Debug)]
|
1605 | 1605 | pub enum AttrArgsEq {
|
1606 | 1606 | Ast(P<Expr>),
|
1607 |
| - Hir(Lit), |
| 1607 | + Hir(MetaItemLit), |
1608 | 1608 | }
|
1609 | 1609 |
|
1610 | 1610 | impl AttrArgs {
|
@@ -1726,14 +1726,13 @@ pub enum StrStyle {
|
1726 | 1726 | Raw(u8),
|
1727 | 1727 | }
|
1728 | 1728 |
|
1729 |
| -/// An AST literal. |
| 1729 | +/// A literal in a meta item. |
1730 | 1730 | #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
|
1731 |
| -pub struct Lit { |
| 1731 | +pub struct MetaItemLit { |
1732 | 1732 | /// The original literal token as written in source code.
|
1733 | 1733 | pub token_lit: token::Lit,
|
1734 | 1734 | /// The "semantic" representation of the literal lowered from the original tokens.
|
1735 | 1735 | /// Strings are unescaped, hexadecimal forms are eliminated, etc.
|
1736 |
| - /// FIXME: Remove this and only create the semantic representation during lowering to HIR. |
1737 | 1736 | pub kind: LitKind,
|
1738 | 1737 | pub span: Span,
|
1739 | 1738 | }
|
@@ -1783,6 +1782,8 @@ pub enum LitFloatType {
|
1783 | 1782 | Unsuffixed,
|
1784 | 1783 | }
|
1785 | 1784 |
|
| 1785 | +/// This type is used within both `ast::MetaItemLit` and `hir::Lit`. |
| 1786 | +/// |
1786 | 1787 | /// Note that the entire literal (including the suffix) is considered when
|
1787 | 1788 | /// deciding the `LitKind`. This means that float literals like `1f32` are
|
1788 | 1789 | /// classified by this type as `Float`. This is different to `token::LitKind`
|
@@ -3096,9 +3097,9 @@ mod size_asserts {
|
3096 | 3097 | static_assert_size!(Impl, 184);
|
3097 | 3098 | static_assert_size!(Item, 184);
|
3098 | 3099 | static_assert_size!(ItemKind, 112);
|
3099 |
| - static_assert_size!(Lit, 48); |
3100 | 3100 | static_assert_size!(LitKind, 24);
|
3101 | 3101 | static_assert_size!(Local, 72);
|
| 3102 | + static_assert_size!(MetaItemLit, 48); |
3102 | 3103 | static_assert_size!(Param, 40);
|
3103 | 3104 | static_assert_size!(Pat, 88);
|
3104 | 3105 | static_assert_size!(Path, 24);
|
|
0 commit comments