Skip to main content

rustc_ast/
token.rs

1use std::borrow::Cow;
2use std::fmt;
3
4pub use LitKind::*;
5pub use NtExprKind::*;
6pub use NtPatKind::*;
7pub use TokenKind::*;
8use rustc_macros::{Decodable, Encodable, StableHash};
9use rustc_span::edition::Edition;
10use rustc_span::symbol::IdentPrintMode;
11use rustc_span::{self as sp, DUMMY_SP, ErrorGuaranteed, Span, Symbol, kw, sym};
12
13use crate::ast;
14use crate::util::case::Case;
15
16/// Represents the kind of doc comment it is, ie `///` or `#[doc = ""]`.
17#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for DocFragmentKind {
}
#[automatically_derived]impl ::core::clone::Clone for DocFragmentKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<CommentKind>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for DocFragmentKind { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    DocFragmentKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for DocFragmentKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Sugared(__self_0), Self::Sugared(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Raw(__self_0), Self::Raw(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for DocFragmentKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<CommentKind>;
        let _: ::core::cmp::AssertParamIsEq<Span>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for DocFragmentKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        DocFragmentKind::Sugared(ref __binding_0) => { 0usize }
                        DocFragmentKind::Raw(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    DocFragmentKind::Sugared(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    DocFragmentKind::Raw(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for DocFragmentKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        DocFragmentKind::Sugared(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        DocFragmentKind::Raw(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `DocFragmentKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::fmt::Debug for DocFragmentKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Sugared(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Sugared", &__self_0),
            Self::Raw(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Raw",
                    &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            DocFragmentKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    DocFragmentKind::Sugared(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    DocFragmentKind::Raw(ref __binding_0) =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    DocFragmentKind::Sugared(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    DocFragmentKind::Raw(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
18pub enum DocFragmentKind {
19    /// A sugared doc comment: `///` or `//!` or `/**` or `/*!`.
20    Sugared(CommentKind),
21    /// A "raw" doc comment: `#[doc = ""]`. The `Span` represents the string literal.
22    Raw(Span),
23}
24
25impl DocFragmentKind {
26    pub fn is_sugared(self) -> bool {
27        #[allow(non_exhaustive_omitted_patterns)] match self {
    Self::Sugared(_) => true,
    _ => false,
}matches!(self, Self::Sugared(_))
28    }
29
30    /// If it is `Sugared`, it will return its associated `CommentKind`, otherwise it will return
31    /// `CommentKind::Line`.
32    pub fn comment_kind(self) -> CommentKind {
33        match self {
34            Self::Sugared(kind) => kind,
35            Self::Raw(_) => CommentKind::Line,
36        }
37    }
38}
39
40#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for CommentKind {
}
#[automatically_derived]impl ::core::clone::Clone for CommentKind {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for CommentKind { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    CommentKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CommentKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for CommentKind { }Eq, #[automatically_derived]impl ::core::hash::Hash for CommentKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CommentKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        CommentKind::Line => { 0usize }
                        CommentKind::Block => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CommentKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { CommentKind::Line }
                    1usize => { CommentKind::Block }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CommentKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::fmt::Debug for CommentKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CommentKind::Line => "Line",
                CommentKind::Block => "Block",
            })
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for CommentKind
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CommentKind::Line => 0u8.stable_hash(__hcx, __hasher),
                    CommentKind::Block => 1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    CommentKind::Line => {}
                    CommentKind::Block => {}
                }
            }
        }
    };StableHash)]
41pub enum CommentKind {
42    Line,
43    Block,
44}
45
46#[derive(#[automatically_derived]impl ::core::marker::Copy for InvisibleOrigin { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for InvisibleOrigin {
}
#[automatically_derived]impl ::core::clone::Clone for InvisibleOrigin {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<MetaVarKind>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    InvisibleOrigin {
}
#[automatically_derived]impl ::core::cmp::PartialEq for InvisibleOrigin {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::MetaVar(__self_0), Self::MetaVar(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for InvisibleOrigin {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<MetaVarKind>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for InvisibleOrigin {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::MetaVar(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, #[automatically_derived]impl ::core::fmt::Debug for InvisibleOrigin {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::MetaVar(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "MetaVar", &__self_0),
            Self::ProcMacro =>
                ::core::fmt::Formatter::write_str(f, "ProcMacro"),
        }
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for InvisibleOrigin {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        InvisibleOrigin::MetaVar(ref __binding_0) => { 0usize }
                        InvisibleOrigin::ProcMacro => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    InvisibleOrigin::MetaVar(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InvisibleOrigin::ProcMacro => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for InvisibleOrigin {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        InvisibleOrigin::MetaVar(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => { InvisibleOrigin::ProcMacro }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `InvisibleOrigin`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            InvisibleOrigin {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    InvisibleOrigin::MetaVar(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    InvisibleOrigin::ProcMacro =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    InvisibleOrigin::MetaVar(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    InvisibleOrigin::ProcMacro => {}
                }
            }
        }
    };StableHash)]
47pub enum InvisibleOrigin {
48    // From the expansion of a metavariable in a declarative macro.
49    MetaVar(MetaVarKind),
50
51    // Converted from `proc_macro::Delimiter` in
52    // `proc_macro::Delimiter::to_internal`, i.e. returned by a proc macro.
53    ProcMacro,
54}
55
56impl InvisibleOrigin {
57    // Should the parser skip these invisible delimiters? Ideally this function
58    // will eventually disappear and no invisible delimiters will be skipped.
59    #[inline]
60    pub fn skip(&self) -> bool {
61        match self {
62            InvisibleOrigin::MetaVar(_) => false,
63            InvisibleOrigin::ProcMacro => true,
64        }
65    }
66}
67
68/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
69#[derive(#[automatically_derived]impl ::core::fmt::Debug for MetaVarKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Item => ::core::fmt::Formatter::write_str(f, "Item"),
            Self::Block => ::core::fmt::Formatter::write_str(f, "Block"),
            Self::Stmt => ::core::fmt::Formatter::write_str(f, "Stmt"),
            Self::Pat(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Pat",
                    &__self_0),
            Self::Expr {
                kind: __self_0,
                can_begin_literal_maybe_minus: __self_1,
                can_begin_string_literal: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "Expr kind can_begin_literal_maybe_minus can_begin_string_literal",
                    __self_0, __self_1, &__self_2),
            Self::Ty { is_path: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Ty is_path", &__self_0),
            Self::Ident => ::core::fmt::Formatter::write_str(f, "Ident"),
            Self::Lifetime =>
                ::core::fmt::Formatter::write_str(f, "Lifetime"),
            Self::Literal => ::core::fmt::Formatter::write_str(f, "Literal"),
            Self::Meta { has_meta_form: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Meta has_meta_form", &__self_0),
            Self::Path => ::core::fmt::Formatter::write_str(f, "Path"),
            Self::Vis => ::core::fmt::Formatter::write_str(f, "Vis"),
            Self::Guard => ::core::fmt::Formatter::write_str(f, "Guard"),
            Self::TT => ::core::fmt::Formatter::write_str(f, "TT"),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::Copy for MetaVarKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for MetaVarKind {
}
#[automatically_derived]impl ::core::clone::Clone for MetaVarKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<NtPatKind>;
        let _: ::core::clone::AssertParamIsClone<NtExprKind>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    MetaVarKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for MetaVarKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Pat(__self_0), Self::Pat(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Expr {
                    kind: __self_0,
                    can_begin_literal_maybe_minus: __self_1,
                    can_begin_string_literal: __self_2 }, Self::Expr {
                    kind: __arg1_0,
                    can_begin_literal_maybe_minus: __arg1_1,
                    can_begin_string_literal: __arg1_2 }) =>
                    __self_1 == __arg1_1 && __self_2 == __arg1_2 &&
                        __self_0 == __arg1_0,
                (Self::Ty { is_path: __self_0 }, Self::Ty { is_path: __arg1_0
                    }) => __self_0 == __arg1_0,
                (Self::Meta { has_meta_form: __self_0 }, Self::Meta {
                    has_meta_form: __arg1_0 }) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for MetaVarKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<NtPatKind>;
        let _: ::core::cmp::AssertParamIsEq<NtExprKind>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for MetaVarKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        MetaVarKind::Item => { 0usize }
                        MetaVarKind::Block => { 1usize }
                        MetaVarKind::Stmt => { 2usize }
                        MetaVarKind::Pat(ref __binding_0) => { 3usize }
                        MetaVarKind::Expr {
                            kind: ref __binding_0,
                            can_begin_literal_maybe_minus: ref __binding_1,
                            can_begin_string_literal: ref __binding_2 } => {
                            4usize
                        }
                        MetaVarKind::Ty { is_path: ref __binding_0 } => { 5usize }
                        MetaVarKind::Ident => { 6usize }
                        MetaVarKind::Lifetime => { 7usize }
                        MetaVarKind::Literal => { 8usize }
                        MetaVarKind::Meta { has_meta_form: ref __binding_0 } => {
                            9usize
                        }
                        MetaVarKind::Path => { 10usize }
                        MetaVarKind::Vis => { 11usize }
                        MetaVarKind::Guard => { 12usize }
                        MetaVarKind::TT => { 13usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    MetaVarKind::Item => {}
                    MetaVarKind::Block => {}
                    MetaVarKind::Stmt => {}
                    MetaVarKind::Pat(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    MetaVarKind::Expr {
                        kind: ref __binding_0,
                        can_begin_literal_maybe_minus: ref __binding_1,
                        can_begin_string_literal: ref __binding_2 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                    }
                    MetaVarKind::Ty { is_path: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    MetaVarKind::Ident => {}
                    MetaVarKind::Lifetime => {}
                    MetaVarKind::Literal => {}
                    MetaVarKind::Meta { has_meta_form: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    MetaVarKind::Path => {}
                    MetaVarKind::Vis => {}
                    MetaVarKind::Guard => {}
                    MetaVarKind::TT => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for MetaVarKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { MetaVarKind::Item }
                    1usize => { MetaVarKind::Block }
                    2usize => { MetaVarKind::Stmt }
                    3usize => {
                        MetaVarKind::Pat(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    4usize => {
                        MetaVarKind::Expr {
                            kind: ::rustc_serialize::Decodable::decode(__decoder),
                            can_begin_literal_maybe_minus: ::rustc_serialize::Decodable::decode(__decoder),
                            can_begin_string_literal: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    5usize => {
                        MetaVarKind::Ty {
                            is_path: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    6usize => { MetaVarKind::Ident }
                    7usize => { MetaVarKind::Lifetime }
                    8usize => { MetaVarKind::Literal }
                    9usize => {
                        MetaVarKind::Meta {
                            has_meta_form: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    10usize => { MetaVarKind::Path }
                    11usize => { MetaVarKind::Vis }
                    12usize => { MetaVarKind::Guard }
                    13usize => { MetaVarKind::TT }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `MetaVarKind`, expected 0..14, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::hash::Hash for MetaVarKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Pat(__self_0) => ::core::hash::Hash::hash(__self_0, state),
            Self::Expr {
                kind: __self_0,
                can_begin_literal_maybe_minus: __self_1,
                can_begin_string_literal: __self_2 } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state);
                ::core::hash::Hash::hash(__self_2, state)
            }
            Self::Ty { is_path: __self_0 } =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::Meta { has_meta_form: __self_0 } =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for MetaVarKind
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    MetaVarKind::Item => 0u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Block => 1u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Stmt => 2u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Pat(ref __binding_0) =>
                        3u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Expr {
                        kind: ref __binding_0,
                        can_begin_literal_maybe_minus: ref __binding_1,
                        can_begin_string_literal: ref __binding_2 } =>
                        4u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Ty { is_path: ref __binding_0 } =>
                        5u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Ident => 6u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Lifetime => 7u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Literal => 8u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Meta { has_meta_form: ref __binding_0 } =>
                        9u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Path => 10u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Vis => 11u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::Guard => 12u8.stable_hash(__hcx, __hasher),
                    MetaVarKind::TT => 13u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    MetaVarKind::Item => {}
                    MetaVarKind::Block => {}
                    MetaVarKind::Stmt => {}
                    MetaVarKind::Pat(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    MetaVarKind::Expr {
                        kind: ref __binding_0,
                        can_begin_literal_maybe_minus: ref __binding_1,
                        can_begin_string_literal: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                    MetaVarKind::Ty { is_path: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    MetaVarKind::Ident => {}
                    MetaVarKind::Lifetime => {}
                    MetaVarKind::Literal => {}
                    MetaVarKind::Meta { has_meta_form: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    MetaVarKind::Path => {}
                    MetaVarKind::Vis => {}
                    MetaVarKind::Guard => {}
                    MetaVarKind::TT => {}
                }
            }
        }
    };StableHash)]
70pub enum MetaVarKind {
71    Item,
72    Block,
73    Stmt,
74    Pat(NtPatKind),
75    Expr {
76        kind: NtExprKind,
77        // This field is needed for `Token::can_begin_literal_maybe_minus`.
78        can_begin_literal_maybe_minus: bool,
79        // This field is needed for `Token::can_begin_string_literal`.
80        can_begin_string_literal: bool,
81    },
82    Ty {
83        is_path: bool,
84    },
85    Ident,
86    Lifetime,
87    Literal,
88    Meta {
89        /// Will `AttrItem::meta` succeed on this, if reparsed?
90        has_meta_form: bool,
91    },
92    Path,
93    Vis,
94    Guard,
95    TT,
96}
97
98impl fmt::Display for MetaVarKind {
99    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
100        let sym = match self {
101            MetaVarKind::Item => sym::item,
102            MetaVarKind::Block => sym::block,
103            MetaVarKind::Stmt => sym::stmt,
104            MetaVarKind::Pat(PatParam { inferred: true } | PatWithOr) => sym::pat,
105            MetaVarKind::Pat(PatParam { inferred: false }) => sym::pat_param,
106            MetaVarKind::Expr { kind: Expr2021 { inferred: true } | Expr, .. } => sym::expr,
107            MetaVarKind::Expr { kind: Expr2021 { inferred: false }, .. } => sym::expr_2021,
108            MetaVarKind::Ty { .. } => sym::ty,
109            MetaVarKind::Ident => sym::ident,
110            MetaVarKind::Lifetime => sym::lifetime,
111            MetaVarKind::Literal => sym::literal,
112            MetaVarKind::Meta { .. } => sym::meta,
113            MetaVarKind::Path => sym::path,
114            MetaVarKind::Vis => sym::vis,
115            MetaVarKind::Guard => sym::guard,
116            MetaVarKind::TT => sym::tt,
117        };
118        f.write_fmt(format_args!("{0}", sym))write!(f, "{sym}")
119    }
120}
121
122/// Describes how a sequence of token trees is delimited.
123/// Cannot use `proc_macro::Delimiter` directly because this
124/// structure should implement some additional traits.
125#[derive(#[automatically_derived]impl ::core::marker::Copy for Delimiter { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Delimiter {
}
#[automatically_derived]impl ::core::clone::Clone for Delimiter {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<InvisibleOrigin>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Delimiter {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Parenthesis =>
                ::core::fmt::Formatter::write_str(f, "Parenthesis"),
            Self::Brace => ::core::fmt::Formatter::write_str(f, "Brace"),
            Self::Bracket => ::core::fmt::Formatter::write_str(f, "Bracket"),
            Self::Invisible(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Invisible", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Delimiter
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for Delimiter {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Invisible(__self_0), Self::Invisible(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for Delimiter {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<InvisibleOrigin>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for Delimiter {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Invisible(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Delimiter {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Delimiter::Parenthesis => { 0usize }
                        Delimiter::Brace => { 1usize }
                        Delimiter::Bracket => { 2usize }
                        Delimiter::Invisible(ref __binding_0) => { 3usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Delimiter::Parenthesis => {}
                    Delimiter::Brace => {}
                    Delimiter::Bracket => {}
                    Delimiter::Invisible(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Delimiter {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Delimiter::Parenthesis }
                    1usize => { Delimiter::Brace }
                    2usize => { Delimiter::Bracket }
                    3usize => {
                        Delimiter::Invisible(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Delimiter`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Delimiter {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Delimiter::Parenthesis => 0u8.stable_hash(__hcx, __hasher),
                    Delimiter::Brace => 1u8.stable_hash(__hcx, __hasher),
                    Delimiter::Bracket => 2u8.stable_hash(__hcx, __hasher),
                    Delimiter::Invisible(ref __binding_0) =>
                        3u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    Delimiter::Parenthesis => {}
                    Delimiter::Brace => {}
                    Delimiter::Bracket => {}
                    Delimiter::Invisible(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
126pub enum Delimiter {
127    /// `( ... )`
128    Parenthesis,
129    /// `{ ... }`
130    Brace,
131    /// `[ ... ]`
132    Bracket,
133    /// `∅ ... ∅`
134    /// An invisible delimiter, that may, for example, appear around tokens coming from a
135    /// "macro variable" `$var`. It is important to preserve operator priorities in cases like
136    /// `$var * 3` where `$var` is `1 + 2`.
137    /// Invisible delimiters might not survive roundtrip of a token stream through a string.
138    Invisible(InvisibleOrigin),
139}
140
141impl Delimiter {
142    // Should the parser skip these delimiters? Only happens for certain kinds
143    // of invisible delimiters. Ideally this function will eventually disappear
144    // and no invisible delimiters will be skipped.
145    #[inline]
146    pub fn skip(&self) -> bool {
147        match self {
148            Delimiter::Parenthesis | Delimiter::Bracket | Delimiter::Brace => false,
149            Delimiter::Invisible(origin) => origin.skip(),
150        }
151    }
152
153    // This exists because `InvisibleOrigin`s should not be compared. It is only used for
154    // assertions.
155    pub fn eq_ignoring_invisible_origin(&self, other: &Delimiter) -> bool {
156        match (self, other) {
157            (Delimiter::Parenthesis, Delimiter::Parenthesis) => true,
158            (Delimiter::Brace, Delimiter::Brace) => true,
159            (Delimiter::Bracket, Delimiter::Bracket) => true,
160            (Delimiter::Invisible(_), Delimiter::Invisible(_)) => true,
161            _ => false,
162        }
163    }
164
165    pub fn as_open_token_kind(&self) -> TokenKind {
166        match *self {
167            Delimiter::Parenthesis => OpenParen,
168            Delimiter::Brace => OpenBrace,
169            Delimiter::Bracket => OpenBracket,
170            Delimiter::Invisible(origin) => OpenInvisible(origin),
171        }
172    }
173
174    pub fn as_close_token_kind(&self) -> TokenKind {
175        match *self {
176            Delimiter::Parenthesis => CloseParen,
177            Delimiter::Brace => CloseBrace,
178            Delimiter::Bracket => CloseBracket,
179            Delimiter::Invisible(origin) => CloseInvisible(origin),
180        }
181    }
182}
183
184// Note that the suffix is *not* considered when deciding the `LitKind` in this
185// type. This means that float literals like `1f32` are classified by this type
186// as `Int`. Only upon conversion to `ast::LitKind` will such a literal be
187// given the `Float` kind.
188#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for LitKind {
}
#[automatically_derived]impl ::core::clone::Clone for LitKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<u8>;
        let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for LitKind { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for LitKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LitKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::StrRaw(__self_0), Self::StrRaw(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::ByteStrRaw(__self_0), Self::ByteStrRaw(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::CStrRaw(__self_0), Self::CStrRaw(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Err(__self_0), Self::Err(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for LitKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u8>;
        let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for LitKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::StrRaw(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::ByteStrRaw(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::CStrRaw(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::Err(__self_0) => ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for LitKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        LitKind::Bool => { 0usize }
                        LitKind::Byte => { 1usize }
                        LitKind::Char => { 2usize }
                        LitKind::Integer => { 3usize }
                        LitKind::Float => { 4usize }
                        LitKind::Str => { 5usize }
                        LitKind::StrRaw(ref __binding_0) => { 6usize }
                        LitKind::ByteStr => { 7usize }
                        LitKind::ByteStrRaw(ref __binding_0) => { 8usize }
                        LitKind::CStr => { 9usize }
                        LitKind::CStrRaw(ref __binding_0) => { 10usize }
                        LitKind::Err(ref __binding_0) => { 11usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    LitKind::Bool => {}
                    LitKind::Byte => {}
                    LitKind::Char => {}
                    LitKind::Integer => {}
                    LitKind::Float => {}
                    LitKind::Str => {}
                    LitKind::StrRaw(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    LitKind::ByteStr => {}
                    LitKind::ByteStrRaw(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    LitKind::CStr => {}
                    LitKind::CStrRaw(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    LitKind::Err(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for LitKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { LitKind::Bool }
                    1usize => { LitKind::Byte }
                    2usize => { LitKind::Char }
                    3usize => { LitKind::Integer }
                    4usize => { LitKind::Float }
                    5usize => { LitKind::Str }
                    6usize => {
                        LitKind::StrRaw(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    7usize => { LitKind::ByteStr }
                    8usize => {
                        LitKind::ByteStrRaw(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    9usize => { LitKind::CStr }
                    10usize => {
                        LitKind::CStrRaw(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    11usize => {
                        LitKind::Err(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `LitKind`, expected 0..12, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::fmt::Debug for LitKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Bool => ::core::fmt::Formatter::write_str(f, "Bool"),
            Self::Byte => ::core::fmt::Formatter::write_str(f, "Byte"),
            Self::Char => ::core::fmt::Formatter::write_str(f, "Char"),
            Self::Integer => ::core::fmt::Formatter::write_str(f, "Integer"),
            Self::Float => ::core::fmt::Formatter::write_str(f, "Float"),
            Self::Str => ::core::fmt::Formatter::write_str(f, "Str"),
            Self::StrRaw(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "StrRaw", &__self_0),
            Self::ByteStr => ::core::fmt::Formatter::write_str(f, "ByteStr"),
            Self::ByteStrRaw(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "ByteStrRaw", &__self_0),
            Self::CStr => ::core::fmt::Formatter::write_str(f, "CStr"),
            Self::CStrRaw(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "CStrRaw", &__self_0),
            Self::Err(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Err",
                    &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for LitKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    LitKind::Bool => 0u8.stable_hash(__hcx, __hasher),
                    LitKind::Byte => 1u8.stable_hash(__hcx, __hasher),
                    LitKind::Char => 2u8.stable_hash(__hcx, __hasher),
                    LitKind::Integer => 3u8.stable_hash(__hcx, __hasher),
                    LitKind::Float => 4u8.stable_hash(__hcx, __hasher),
                    LitKind::Str => 5u8.stable_hash(__hcx, __hasher),
                    LitKind::StrRaw(ref __binding_0) =>
                        6u8.stable_hash(__hcx, __hasher),
                    LitKind::ByteStr => 7u8.stable_hash(__hcx, __hasher),
                    LitKind::ByteStrRaw(ref __binding_0) =>
                        8u8.stable_hash(__hcx, __hasher),
                    LitKind::CStr => 9u8.stable_hash(__hcx, __hasher),
                    LitKind::CStrRaw(ref __binding_0) =>
                        10u8.stable_hash(__hcx, __hasher),
                    LitKind::Err(ref __binding_0) =>
                        11u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    LitKind::Bool => {}
                    LitKind::Byte => {}
                    LitKind::Char => {}
                    LitKind::Integer => {}
                    LitKind::Float => {}
                    LitKind::Str => {}
                    LitKind::StrRaw(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    LitKind::ByteStr => {}
                    LitKind::ByteStrRaw(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    LitKind::CStr => {}
                    LitKind::CStrRaw(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    LitKind::Err(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
189pub enum LitKind {
190    Bool, // AST only, must never appear in a `Token`
191    Byte,
192    Char,
193    Integer, // e.g. `1`, `1u8`, `1f32`
194    Float,   // e.g. `1.`, `1.0`, `1e3f32`
195    Str,
196    StrRaw(u8), // raw string delimited by `n` hash symbols
197    ByteStr,
198    ByteStrRaw(u8), // raw byte string delimited by `n` hash symbols
199    CStr,
200    CStrRaw(u8),
201    Err(ErrorGuaranteed),
202}
203
204/// A literal token.
205#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Lit {
}
#[automatically_derived]impl ::core::clone::Clone for Lit {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<LitKind>;
        let _: ::core::clone::AssertParamIsClone<Symbol>;
        let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Lit { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Lit { }
#[automatically_derived]impl ::core::cmp::PartialEq for Lit {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.kind == other.kind && self.symbol == other.symbol &&
            self.suffix == other.suffix
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for Lit {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<LitKind>;
        let _: ::core::cmp::AssertParamIsEq<Symbol>;
        let _: ::core::cmp::AssertParamIsEq<Option<Symbol>>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for Lit {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.kind, state);
        ::core::hash::Hash::hash(&self.symbol, state);
        ::core::hash::Hash::hash(&self.suffix, state)
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Lit {
            fn encode(&self, __encoder: &mut __E) {
                let Lit {
                        kind: ref __binding_0,
                        symbol: ref __binding_1,
                        suffix: ref __binding_2 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Lit {
            fn decode(__decoder: &mut __D) -> Self {
                Lit {
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    symbol: ::rustc_serialize::Decodable::decode(__decoder),
                    suffix: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::fmt::Debug for Lit {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "Lit kind symbol suffix", &self.kind, &self.symbol, &&self.suffix)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Lit {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Lit {
                        kind: ref __binding_0,
                        symbol: ref __binding_1,
                        suffix: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
206pub struct Lit {
207    pub kind: LitKind,
208    pub symbol: Symbol,
209    pub suffix: Option<Symbol>,
210}
211
212impl Lit {
213    pub fn new(kind: LitKind, symbol: Symbol, suffix: Option<Symbol>) -> Lit {
214        Lit { kind, symbol, suffix }
215    }
216
217    /// Returns `true` if this is semantically a float literal. This includes
218    /// ones like `1f32` that have an `Integer` kind but a float suffix.
219    pub fn is_semantic_float(&self) -> bool {
220        match self.kind {
221            LitKind::Float => true,
222            LitKind::Integer => match self.suffix {
223                Some(sym) => sym == sym::f32 || sym == sym::f64,
224                None => false,
225            },
226            _ => false,
227        }
228    }
229
230    /// Keep this in sync with `Token::can_begin_literal_maybe_minus` and
231    /// `Parser::eat_token_lit` (excluding unary negation).
232    pub fn from_token(token: &Token) -> Option<Lit> {
233        match token.uninterpolate().kind {
234            Ident(name, IdentKind::Normal | IdentKind::ForcedKeyword) if name.is_bool_lit() => {
235                Some(Lit::new(Bool, name, None))
236            }
237            Literal(token_lit) => Some(token_lit),
238            OpenInvisible(InvisibleOrigin::MetaVar(
239                MetaVarKind::Literal | MetaVarKind::Expr { .. },
240            )) => {
241                // Unreachable with the current test suite.
242                { ::core::panicking::panic_fmt(format_args!("from_token metavar")); };panic!("from_token metavar");
243            }
244            _ => None,
245        }
246    }
247}
248
249impl fmt::Display for Lit {
250    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
251        let Lit { kind, symbol, suffix } = *self;
252        match kind {
253            Byte => f.write_fmt(format_args!("b\'{0}\'", symbol))write!(f, "b'{symbol}'")?,
254            Char => f.write_fmt(format_args!("\'{0}\'", symbol))write!(f, "'{symbol}'")?,
255            Str => f.write_fmt(format_args!("\"{0}\"", symbol))write!(f, "\"{symbol}\"")?,
256            StrRaw(n) => f.write_fmt(format_args!("r{0}\"{1}\"{0}", "#".repeat(n as usize), symbol))write!(
257                f,
258                "r{delim}\"{string}\"{delim}",
259                delim = "#".repeat(n as usize),
260                string = symbol
261            )?,
262            ByteStr => f.write_fmt(format_args!("b\"{0}\"", symbol))write!(f, "b\"{symbol}\"")?,
263            ByteStrRaw(n) => f.write_fmt(format_args!("br{0}\"{1}\"{0}", "#".repeat(n as usize), symbol))write!(
264                f,
265                "br{delim}\"{string}\"{delim}",
266                delim = "#".repeat(n as usize),
267                string = symbol
268            )?,
269            CStr => f.write_fmt(format_args!("c\"{0}\"", symbol))write!(f, "c\"{symbol}\"")?,
270            CStrRaw(n) => {
271                f.write_fmt(format_args!("cr{0}\"{1}\"{0}", "#".repeat(n as usize), symbol))write!(f, "cr{delim}\"{symbol}\"{delim}", delim = "#".repeat(n as usize))?
272            }
273            Integer | Float | Bool | Err(_) => f.write_fmt(format_args!("{0}", symbol))write!(f, "{symbol}")?,
274        }
275
276        if let Some(suffix) = suffix {
277            f.write_fmt(format_args!("{0}", suffix))write!(f, "{suffix}")?;
278        }
279
280        Ok(())
281    }
282}
283
284impl LitKind {
285    /// An English article for the literal token kind.
286    pub fn article(self) -> &'static str {
287        match self {
288            Integer | Err(_) => "an",
289            _ => "a",
290        }
291    }
292
293    pub fn descr(self) -> &'static str {
294        match self {
295            Bool => "boolean",
296            Byte => "byte",
297            Char => "char",
298            Integer => "integer",
299            Float => "float",
300            Str | StrRaw(..) => "string",
301            ByteStr | ByteStrRaw(..) => "byte string",
302            CStr | CStrRaw(..) => "C string",
303            Err(_) => "error",
304        }
305    }
306
307    pub(crate) fn may_have_suffix(self) -> bool {
308        #[allow(non_exhaustive_omitted_patterns)] match self {
    Integer | Float | Err(_) => true,
    _ => false,
}matches!(self, Integer | Float | Err(_))
309    }
310}
311
312pub fn ident_can_begin_expr(name: Symbol, span: Span, kind: IdentKind) -> bool {
313    // WARNING: Take care when modifying this function! It will change the stable(!) set of
314    //          tokens that are allowed to match an `expr` nonterminal which is user observable.
315
316    // NOTE: We don't care about forced keywords that are gated behind `internal_syntax`.
317
318    let ident_token = Token::new(Ident(name, kind), span);
319
320    // FIXME: Remove `box` from this list given we officially no longer support box expressions
321    //        (#108471) (needs lang FCP as it affects stable macro matching behavior).
322    !ident_token.is_reserved_ident()
323        || ident_token.is_path_segment_keyword()
324        || [
325            kw::Async,
326            kw::Do,
327            kw::Box,
328            kw::Break,
329            kw::Const,
330            kw::Continue,
331            kw::False,
332            kw::For,
333            kw::Gen,
334            kw::If,
335            kw::Let,
336            kw::Loop,
337            kw::Match,
338            kw::Move,
339            kw::Return,
340            kw::True,
341            kw::Try,
342            kw::Unsafe,
343            kw::While,
344            kw::Yield,
345            kw::Safe,
346            kw::Static,
347        ]
348        .contains(&name)
349}
350
351fn ident_can_begin_type(name: Symbol, span: Span, kind: IdentKind) -> bool {
352    // WARNING: Take care when modifying this function! It will change the stable(!) set of
353    //          tokens that are allowed to match an `ty` nonterminal which is user observable.
354
355    // NOTE: We don't care about forced keywords that are gated behind `internal_syntax`.
356
357    let ident_token = Token::new(Ident(name, kind), span);
358
359    !ident_token.is_reserved_ident()
360        || ident_token.is_path_segment_keyword()
361        || [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Typeof, kw::Dyn]
362            .contains(&name)
363}
364
365#[derive(#[automatically_derived]impl ::core::marker::StructuralPartialEq for IdentKind
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for IdentKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for IdentKind { }Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for IdentKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        IdentKind::Normal => { 0usize }
                        IdentKind::Raw => { 1usize }
                        IdentKind::ForcedKeyword => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for IdentKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { IdentKind::Normal }
                    1usize => { IdentKind::Raw }
                    2usize => { IdentKind::ForcedKeyword }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IdentKind`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::hash::Hash for IdentKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]impl ::core::fmt::Debug for IdentKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                IdentKind::Normal => "Normal",
                IdentKind::Raw => "Raw",
                IdentKind::ForcedKeyword => "ForcedKeyword",
            })
    }
}Debug, #[automatically_derived]impl ::core::marker::Copy for IdentKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for IdentKind {
}
#[automatically_derived]impl ::core::clone::Clone for IdentKind {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for IdentKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    IdentKind::Normal => 0u8.stable_hash(__hcx, __hasher),
                    IdentKind::Raw => 1u8.stable_hash(__hcx, __hasher),
                    IdentKind::ForcedKeyword =>
                        2u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    IdentKind::Normal => {}
                    IdentKind::Raw => {}
                    IdentKind::ForcedKeyword => {}
                }
            }
        }
    };StableHash)]
366pub enum IdentKind {
367    Normal,
368    Raw,
369    ForcedKeyword,
370}
371
372impl IdentKind {
373    pub fn to_print_mode_ident(self) -> IdentPrintMode {
374        match self {
375            IdentKind::Normal => IdentPrintMode::Normal,
376            IdentKind::Raw => IdentPrintMode::RawIdent,
377            IdentKind::ForcedKeyword => IdentPrintMode::ForcedKeywordIdent,
378        }
379    }
380
381    pub fn to_print_mode_lifetime(self) -> IdentPrintMode {
382        match self {
383            IdentKind::Normal => IdentPrintMode::Normal,
384            IdentKind::Raw => IdentPrintMode::RawLifetime,
385            IdentKind::ForcedKeyword => ::core::panicking::unreachable_default_msg()unreachable!(),
386        }
387    }
388}
389
390#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for TokenKind {
}
#[automatically_derived]impl ::core::clone::Clone for TokenKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<InvisibleOrigin>;
        let _: ::core::clone::AssertParamIsClone<Lit>;
        let _: ::core::clone::AssertParamIsClone<Symbol>;
        let _: ::core::clone::AssertParamIsClone<IdentKind>;
        let _: ::core::clone::AssertParamIsClone<sp::Ident>;
        let _: ::core::clone::AssertParamIsClone<sp::Ident>;
        let _: ::core::clone::AssertParamIsClone<CommentKind>;
        let _: ::core::clone::AssertParamIsClone<ast::AttrStyle>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for TokenKind { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for TokenKind
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for TokenKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::OpenInvisible(__self_0), Self::OpenInvisible(__arg1_0))
                    => __self_0 == __arg1_0,
                (Self::CloseInvisible(__self_0),
                    Self::CloseInvisible(__arg1_0)) => __self_0 == __arg1_0,
                (Self::Literal(__self_0), Self::Literal(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Ident(__self_0, __self_1),
                    Self::Ident(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::NtIdent(__self_0, __self_1),
                    Self::NtIdent(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::Lifetime(__self_0, __self_1),
                    Self::Lifetime(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::NtLifetime(__self_0, __self_1),
                    Self::NtLifetime(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::DocComment(__self_0, __self_1, __self_2),
                    Self::DocComment(__arg1_0, __arg1_1, __arg1_2)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1 &&
                        __self_2 == __arg1_2,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for TokenKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<InvisibleOrigin>;
        let _: ::core::cmp::AssertParamIsEq<Lit>;
        let _: ::core::cmp::AssertParamIsEq<Symbol>;
        let _: ::core::cmp::AssertParamIsEq<IdentKind>;
        let _: ::core::cmp::AssertParamIsEq<sp::Ident>;
        let _: ::core::cmp::AssertParamIsEq<sp::Ident>;
        let _: ::core::cmp::AssertParamIsEq<CommentKind>;
        let _: ::core::cmp::AssertParamIsEq<ast::AttrStyle>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for TokenKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::OpenInvisible(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::CloseInvisible(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::Literal(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::Ident(__self_0, __self_1) => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            Self::NtIdent(__self_0, __self_1) => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            Self::Lifetime(__self_0, __self_1) => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            Self::NtLifetime(__self_0, __self_1) => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            Self::DocComment(__self_0, __self_1, __self_2) => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state);
                ::core::hash::Hash::hash(__self_2, state)
            }
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for TokenKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        TokenKind::Eq => { 0usize }
                        TokenKind::Lt => { 1usize }
                        TokenKind::Le => { 2usize }
                        TokenKind::EqEq => { 3usize }
                        TokenKind::Ne => { 4usize }
                        TokenKind::Ge => { 5usize }
                        TokenKind::Gt => { 6usize }
                        TokenKind::AndAnd => { 7usize }
                        TokenKind::OrOr => { 8usize }
                        TokenKind::Bang => { 9usize }
                        TokenKind::Tilde => { 10usize }
                        TokenKind::Plus => { 11usize }
                        TokenKind::Minus => { 12usize }
                        TokenKind::Star => { 13usize }
                        TokenKind::Slash => { 14usize }
                        TokenKind::Percent => { 15usize }
                        TokenKind::Caret => { 16usize }
                        TokenKind::And => { 17usize }
                        TokenKind::Or => { 18usize }
                        TokenKind::Shl => { 19usize }
                        TokenKind::Shr => { 20usize }
                        TokenKind::PlusEq => { 21usize }
                        TokenKind::MinusEq => { 22usize }
                        TokenKind::StarEq => { 23usize }
                        TokenKind::SlashEq => { 24usize }
                        TokenKind::PercentEq => { 25usize }
                        TokenKind::CaretEq => { 26usize }
                        TokenKind::AndEq => { 27usize }
                        TokenKind::OrEq => { 28usize }
                        TokenKind::ShlEq => { 29usize }
                        TokenKind::ShrEq => { 30usize }
                        TokenKind::At => { 31usize }
                        TokenKind::Dot => { 32usize }
                        TokenKind::DotDot => { 33usize }
                        TokenKind::DotDotDot => { 34usize }
                        TokenKind::DotDotEq => { 35usize }
                        TokenKind::Comma => { 36usize }
                        TokenKind::Semi => { 37usize }
                        TokenKind::Colon => { 38usize }
                        TokenKind::PathSep => { 39usize }
                        TokenKind::RArrow => { 40usize }
                        TokenKind::LArrow => { 41usize }
                        TokenKind::FatArrow => { 42usize }
                        TokenKind::Pound => { 43usize }
                        TokenKind::Dollar => { 44usize }
                        TokenKind::Question => { 45usize }
                        TokenKind::SingleQuote => { 46usize }
                        TokenKind::OpenParen => { 47usize }
                        TokenKind::CloseParen => { 48usize }
                        TokenKind::OpenBrace => { 49usize }
                        TokenKind::CloseBrace => { 50usize }
                        TokenKind::OpenBracket => { 51usize }
                        TokenKind::CloseBracket => { 52usize }
                        TokenKind::OpenInvisible(ref __binding_0) => { 53usize }
                        TokenKind::CloseInvisible(ref __binding_0) => { 54usize }
                        TokenKind::Literal(ref __binding_0) => { 55usize }
                        TokenKind::Ident(ref __binding_0, ref __binding_1) => {
                            56usize
                        }
                        TokenKind::NtIdent(ref __binding_0, ref __binding_1) => {
                            57usize
                        }
                        TokenKind::Lifetime(ref __binding_0, ref __binding_1) => {
                            58usize
                        }
                        TokenKind::NtLifetime(ref __binding_0, ref __binding_1) => {
                            59usize
                        }
                        TokenKind::DocComment(ref __binding_0, ref __binding_1,
                            ref __binding_2) => {
                            60usize
                        }
                        TokenKind::Eof => { 61usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    TokenKind::Eq => {}
                    TokenKind::Lt => {}
                    TokenKind::Le => {}
                    TokenKind::EqEq => {}
                    TokenKind::Ne => {}
                    TokenKind::Ge => {}
                    TokenKind::Gt => {}
                    TokenKind::AndAnd => {}
                    TokenKind::OrOr => {}
                    TokenKind::Bang => {}
                    TokenKind::Tilde => {}
                    TokenKind::Plus => {}
                    TokenKind::Minus => {}
                    TokenKind::Star => {}
                    TokenKind::Slash => {}
                    TokenKind::Percent => {}
                    TokenKind::Caret => {}
                    TokenKind::And => {}
                    TokenKind::Or => {}
                    TokenKind::Shl => {}
                    TokenKind::Shr => {}
                    TokenKind::PlusEq => {}
                    TokenKind::MinusEq => {}
                    TokenKind::StarEq => {}
                    TokenKind::SlashEq => {}
                    TokenKind::PercentEq => {}
                    TokenKind::CaretEq => {}
                    TokenKind::AndEq => {}
                    TokenKind::OrEq => {}
                    TokenKind::ShlEq => {}
                    TokenKind::ShrEq => {}
                    TokenKind::At => {}
                    TokenKind::Dot => {}
                    TokenKind::DotDot => {}
                    TokenKind::DotDotDot => {}
                    TokenKind::DotDotEq => {}
                    TokenKind::Comma => {}
                    TokenKind::Semi => {}
                    TokenKind::Colon => {}
                    TokenKind::PathSep => {}
                    TokenKind::RArrow => {}
                    TokenKind::LArrow => {}
                    TokenKind::FatArrow => {}
                    TokenKind::Pound => {}
                    TokenKind::Dollar => {}
                    TokenKind::Question => {}
                    TokenKind::SingleQuote => {}
                    TokenKind::OpenParen => {}
                    TokenKind::CloseParen => {}
                    TokenKind::OpenBrace => {}
                    TokenKind::CloseBrace => {}
                    TokenKind::OpenBracket => {}
                    TokenKind::CloseBracket => {}
                    TokenKind::OpenInvisible(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TokenKind::CloseInvisible(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TokenKind::Literal(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TokenKind::Ident(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TokenKind::NtIdent(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TokenKind::Lifetime(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TokenKind::NtLifetime(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TokenKind::DocComment(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                    }
                    TokenKind::Eof => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for TokenKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { TokenKind::Eq }
                    1usize => { TokenKind::Lt }
                    2usize => { TokenKind::Le }
                    3usize => { TokenKind::EqEq }
                    4usize => { TokenKind::Ne }
                    5usize => { TokenKind::Ge }
                    6usize => { TokenKind::Gt }
                    7usize => { TokenKind::AndAnd }
                    8usize => { TokenKind::OrOr }
                    9usize => { TokenKind::Bang }
                    10usize => { TokenKind::Tilde }
                    11usize => { TokenKind::Plus }
                    12usize => { TokenKind::Minus }
                    13usize => { TokenKind::Star }
                    14usize => { TokenKind::Slash }
                    15usize => { TokenKind::Percent }
                    16usize => { TokenKind::Caret }
                    17usize => { TokenKind::And }
                    18usize => { TokenKind::Or }
                    19usize => { TokenKind::Shl }
                    20usize => { TokenKind::Shr }
                    21usize => { TokenKind::PlusEq }
                    22usize => { TokenKind::MinusEq }
                    23usize => { TokenKind::StarEq }
                    24usize => { TokenKind::SlashEq }
                    25usize => { TokenKind::PercentEq }
                    26usize => { TokenKind::CaretEq }
                    27usize => { TokenKind::AndEq }
                    28usize => { TokenKind::OrEq }
                    29usize => { TokenKind::ShlEq }
                    30usize => { TokenKind::ShrEq }
                    31usize => { TokenKind::At }
                    32usize => { TokenKind::Dot }
                    33usize => { TokenKind::DotDot }
                    34usize => { TokenKind::DotDotDot }
                    35usize => { TokenKind::DotDotEq }
                    36usize => { TokenKind::Comma }
                    37usize => { TokenKind::Semi }
                    38usize => { TokenKind::Colon }
                    39usize => { TokenKind::PathSep }
                    40usize => { TokenKind::RArrow }
                    41usize => { TokenKind::LArrow }
                    42usize => { TokenKind::FatArrow }
                    43usize => { TokenKind::Pound }
                    44usize => { TokenKind::Dollar }
                    45usize => { TokenKind::Question }
                    46usize => { TokenKind::SingleQuote }
                    47usize => { TokenKind::OpenParen }
                    48usize => { TokenKind::CloseParen }
                    49usize => { TokenKind::OpenBrace }
                    50usize => { TokenKind::CloseBrace }
                    51usize => { TokenKind::OpenBracket }
                    52usize => { TokenKind::CloseBracket }
                    53usize => {
                        TokenKind::OpenInvisible(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    54usize => {
                        TokenKind::CloseInvisible(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    55usize => {
                        TokenKind::Literal(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    56usize => {
                        TokenKind::Ident(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    57usize => {
                        TokenKind::NtIdent(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    58usize => {
                        TokenKind::Lifetime(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    59usize => {
                        TokenKind::NtLifetime(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    60usize => {
                        TokenKind::DocComment(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    61usize => { TokenKind::Eof }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `TokenKind`, expected 0..62, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::fmt::Debug for TokenKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Eq => ::core::fmt::Formatter::write_str(f, "Eq"),
            Self::Lt => ::core::fmt::Formatter::write_str(f, "Lt"),
            Self::Le => ::core::fmt::Formatter::write_str(f, "Le"),
            Self::EqEq => ::core::fmt::Formatter::write_str(f, "EqEq"),
            Self::Ne => ::core::fmt::Formatter::write_str(f, "Ne"),
            Self::Ge => ::core::fmt::Formatter::write_str(f, "Ge"),
            Self::Gt => ::core::fmt::Formatter::write_str(f, "Gt"),
            Self::AndAnd => ::core::fmt::Formatter::write_str(f, "AndAnd"),
            Self::OrOr => ::core::fmt::Formatter::write_str(f, "OrOr"),
            Self::Bang => ::core::fmt::Formatter::write_str(f, "Bang"),
            Self::Tilde => ::core::fmt::Formatter::write_str(f, "Tilde"),
            Self::Plus => ::core::fmt::Formatter::write_str(f, "Plus"),
            Self::Minus => ::core::fmt::Formatter::write_str(f, "Minus"),
            Self::Star => ::core::fmt::Formatter::write_str(f, "Star"),
            Self::Slash => ::core::fmt::Formatter::write_str(f, "Slash"),
            Self::Percent => ::core::fmt::Formatter::write_str(f, "Percent"),
            Self::Caret => ::core::fmt::Formatter::write_str(f, "Caret"),
            Self::And => ::core::fmt::Formatter::write_str(f, "And"),
            Self::Or => ::core::fmt::Formatter::write_str(f, "Or"),
            Self::Shl => ::core::fmt::Formatter::write_str(f, "Shl"),
            Self::Shr => ::core::fmt::Formatter::write_str(f, "Shr"),
            Self::PlusEq => ::core::fmt::Formatter::write_str(f, "PlusEq"),
            Self::MinusEq => ::core::fmt::Formatter::write_str(f, "MinusEq"),
            Self::StarEq => ::core::fmt::Formatter::write_str(f, "StarEq"),
            Self::SlashEq => ::core::fmt::Formatter::write_str(f, "SlashEq"),
            Self::PercentEq =>
                ::core::fmt::Formatter::write_str(f, "PercentEq"),
            Self::CaretEq => ::core::fmt::Formatter::write_str(f, "CaretEq"),
            Self::AndEq => ::core::fmt::Formatter::write_str(f, "AndEq"),
            Self::OrEq => ::core::fmt::Formatter::write_str(f, "OrEq"),
            Self::ShlEq => ::core::fmt::Formatter::write_str(f, "ShlEq"),
            Self::ShrEq => ::core::fmt::Formatter::write_str(f, "ShrEq"),
            Self::At => ::core::fmt::Formatter::write_str(f, "At"),
            Self::Dot => ::core::fmt::Formatter::write_str(f, "Dot"),
            Self::DotDot => ::core::fmt::Formatter::write_str(f, "DotDot"),
            Self::DotDotDot =>
                ::core::fmt::Formatter::write_str(f, "DotDotDot"),
            Self::DotDotEq =>
                ::core::fmt::Formatter::write_str(f, "DotDotEq"),
            Self::Comma => ::core::fmt::Formatter::write_str(f, "Comma"),
            Self::Semi => ::core::fmt::Formatter::write_str(f, "Semi"),
            Self::Colon => ::core::fmt::Formatter::write_str(f, "Colon"),
            Self::PathSep => ::core::fmt::Formatter::write_str(f, "PathSep"),
            Self::RArrow => ::core::fmt::Formatter::write_str(f, "RArrow"),
            Self::LArrow => ::core::fmt::Formatter::write_str(f, "LArrow"),
            Self::FatArrow =>
                ::core::fmt::Formatter::write_str(f, "FatArrow"),
            Self::Pound => ::core::fmt::Formatter::write_str(f, "Pound"),
            Self::Dollar => ::core::fmt::Formatter::write_str(f, "Dollar"),
            Self::Question =>
                ::core::fmt::Formatter::write_str(f, "Question"),
            Self::SingleQuote =>
                ::core::fmt::Formatter::write_str(f, "SingleQuote"),
            Self::OpenParen =>
                ::core::fmt::Formatter::write_str(f, "OpenParen"),
            Self::CloseParen =>
                ::core::fmt::Formatter::write_str(f, "CloseParen"),
            Self::OpenBrace =>
                ::core::fmt::Formatter::write_str(f, "OpenBrace"),
            Self::CloseBrace =>
                ::core::fmt::Formatter::write_str(f, "CloseBrace"),
            Self::OpenBracket =>
                ::core::fmt::Formatter::write_str(f, "OpenBracket"),
            Self::CloseBracket =>
                ::core::fmt::Formatter::write_str(f, "CloseBracket"),
            Self::OpenInvisible(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "OpenInvisible", &__self_0),
            Self::CloseInvisible(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "CloseInvisible", &__self_0),
            Self::Literal(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Literal", &__self_0),
            Self::Ident(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Ident",
                    __self_0, &__self_1),
            Self::NtIdent(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "NtIdent", __self_0, &__self_1),
            Self::Lifetime(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Lifetime", __self_0, &__self_1),
            Self::NtLifetime(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "NtLifetime", __self_0, &__self_1),
            Self::DocComment(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "DocComment", __self_0, __self_1, &__self_2),
            Self::Eof => ::core::fmt::Formatter::write_str(f, "Eof"),
        }
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for TokenKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    TokenKind::Eq => 0u8.stable_hash(__hcx, __hasher),
                    TokenKind::Lt => 1u8.stable_hash(__hcx, __hasher),
                    TokenKind::Le => 2u8.stable_hash(__hcx, __hasher),
                    TokenKind::EqEq => 3u8.stable_hash(__hcx, __hasher),
                    TokenKind::Ne => 4u8.stable_hash(__hcx, __hasher),
                    TokenKind::Ge => 5u8.stable_hash(__hcx, __hasher),
                    TokenKind::Gt => 6u8.stable_hash(__hcx, __hasher),
                    TokenKind::AndAnd => 7u8.stable_hash(__hcx, __hasher),
                    TokenKind::OrOr => 8u8.stable_hash(__hcx, __hasher),
                    TokenKind::Bang => 9u8.stable_hash(__hcx, __hasher),
                    TokenKind::Tilde => 10u8.stable_hash(__hcx, __hasher),
                    TokenKind::Plus => 11u8.stable_hash(__hcx, __hasher),
                    TokenKind::Minus => 12u8.stable_hash(__hcx, __hasher),
                    TokenKind::Star => 13u8.stable_hash(__hcx, __hasher),
                    TokenKind::Slash => 14u8.stable_hash(__hcx, __hasher),
                    TokenKind::Percent => 15u8.stable_hash(__hcx, __hasher),
                    TokenKind::Caret => 16u8.stable_hash(__hcx, __hasher),
                    TokenKind::And => 17u8.stable_hash(__hcx, __hasher),
                    TokenKind::Or => 18u8.stable_hash(__hcx, __hasher),
                    TokenKind::Shl => 19u8.stable_hash(__hcx, __hasher),
                    TokenKind::Shr => 20u8.stable_hash(__hcx, __hasher),
                    TokenKind::PlusEq => 21u8.stable_hash(__hcx, __hasher),
                    TokenKind::MinusEq => 22u8.stable_hash(__hcx, __hasher),
                    TokenKind::StarEq => 23u8.stable_hash(__hcx, __hasher),
                    TokenKind::SlashEq => 24u8.stable_hash(__hcx, __hasher),
                    TokenKind::PercentEq => 25u8.stable_hash(__hcx, __hasher),
                    TokenKind::CaretEq => 26u8.stable_hash(__hcx, __hasher),
                    TokenKind::AndEq => 27u8.stable_hash(__hcx, __hasher),
                    TokenKind::OrEq => 28u8.stable_hash(__hcx, __hasher),
                    TokenKind::ShlEq => 29u8.stable_hash(__hcx, __hasher),
                    TokenKind::ShrEq => 30u8.stable_hash(__hcx, __hasher),
                    TokenKind::At => 31u8.stable_hash(__hcx, __hasher),
                    TokenKind::Dot => 32u8.stable_hash(__hcx, __hasher),
                    TokenKind::DotDot => 33u8.stable_hash(__hcx, __hasher),
                    TokenKind::DotDotDot => 34u8.stable_hash(__hcx, __hasher),
                    TokenKind::DotDotEq => 35u8.stable_hash(__hcx, __hasher),
                    TokenKind::Comma => 36u8.stable_hash(__hcx, __hasher),
                    TokenKind::Semi => 37u8.stable_hash(__hcx, __hasher),
                    TokenKind::Colon => 38u8.stable_hash(__hcx, __hasher),
                    TokenKind::PathSep => 39u8.stable_hash(__hcx, __hasher),
                    TokenKind::RArrow => 40u8.stable_hash(__hcx, __hasher),
                    TokenKind::LArrow => 41u8.stable_hash(__hcx, __hasher),
                    TokenKind::FatArrow => 42u8.stable_hash(__hcx, __hasher),
                    TokenKind::Pound => 43u8.stable_hash(__hcx, __hasher),
                    TokenKind::Dollar => 44u8.stable_hash(__hcx, __hasher),
                    TokenKind::Question => 45u8.stable_hash(__hcx, __hasher),
                    TokenKind::SingleQuote => 46u8.stable_hash(__hcx, __hasher),
                    TokenKind::OpenParen => 47u8.stable_hash(__hcx, __hasher),
                    TokenKind::CloseParen => 48u8.stable_hash(__hcx, __hasher),
                    TokenKind::OpenBrace => 49u8.stable_hash(__hcx, __hasher),
                    TokenKind::CloseBrace => 50u8.stable_hash(__hcx, __hasher),
                    TokenKind::OpenBracket => 51u8.stable_hash(__hcx, __hasher),
                    TokenKind::CloseBracket =>
                        52u8.stable_hash(__hcx, __hasher),
                    TokenKind::OpenInvisible(ref __binding_0) =>
                        53u8.stable_hash(__hcx, __hasher),
                    TokenKind::CloseInvisible(ref __binding_0) =>
                        54u8.stable_hash(__hcx, __hasher),
                    TokenKind::Literal(ref __binding_0) =>
                        55u8.stable_hash(__hcx, __hasher),
                    TokenKind::Ident(ref __binding_0, ref __binding_1) =>
                        56u8.stable_hash(__hcx, __hasher),
                    TokenKind::NtIdent(ref __binding_0, ref __binding_1) =>
                        57u8.stable_hash(__hcx, __hasher),
                    TokenKind::Lifetime(ref __binding_0, ref __binding_1) =>
                        58u8.stable_hash(__hcx, __hasher),
                    TokenKind::NtLifetime(ref __binding_0, ref __binding_1) =>
                        59u8.stable_hash(__hcx, __hasher),
                    TokenKind::DocComment(ref __binding_0, ref __binding_1,
                        ref __binding_2) => 60u8.stable_hash(__hcx, __hasher),
                    TokenKind::Eof => 61u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    TokenKind::Eq => {}
                    TokenKind::Lt => {}
                    TokenKind::Le => {}
                    TokenKind::EqEq => {}
                    TokenKind::Ne => {}
                    TokenKind::Ge => {}
                    TokenKind::Gt => {}
                    TokenKind::AndAnd => {}
                    TokenKind::OrOr => {}
                    TokenKind::Bang => {}
                    TokenKind::Tilde => {}
                    TokenKind::Plus => {}
                    TokenKind::Minus => {}
                    TokenKind::Star => {}
                    TokenKind::Slash => {}
                    TokenKind::Percent => {}
                    TokenKind::Caret => {}
                    TokenKind::And => {}
                    TokenKind::Or => {}
                    TokenKind::Shl => {}
                    TokenKind::Shr => {}
                    TokenKind::PlusEq => {}
                    TokenKind::MinusEq => {}
                    TokenKind::StarEq => {}
                    TokenKind::SlashEq => {}
                    TokenKind::PercentEq => {}
                    TokenKind::CaretEq => {}
                    TokenKind::AndEq => {}
                    TokenKind::OrEq => {}
                    TokenKind::ShlEq => {}
                    TokenKind::ShrEq => {}
                    TokenKind::At => {}
                    TokenKind::Dot => {}
                    TokenKind::DotDot => {}
                    TokenKind::DotDotDot => {}
                    TokenKind::DotDotEq => {}
                    TokenKind::Comma => {}
                    TokenKind::Semi => {}
                    TokenKind::Colon => {}
                    TokenKind::PathSep => {}
                    TokenKind::RArrow => {}
                    TokenKind::LArrow => {}
                    TokenKind::FatArrow => {}
                    TokenKind::Pound => {}
                    TokenKind::Dollar => {}
                    TokenKind::Question => {}
                    TokenKind::SingleQuote => {}
                    TokenKind::OpenParen => {}
                    TokenKind::CloseParen => {}
                    TokenKind::OpenBrace => {}
                    TokenKind::CloseBrace => {}
                    TokenKind::OpenBracket => {}
                    TokenKind::CloseBracket => {}
                    TokenKind::OpenInvisible(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::CloseInvisible(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::Literal(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::Ident(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::NtIdent(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::Lifetime(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::NtLifetime(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::DocComment(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                    TokenKind::Eof => {}
                }
            }
        }
    };StableHash)]
391pub enum TokenKind {
392    /* Expression-operator symbols. */
393    /// `=`
394    Eq,
395    /// `<`
396    Lt,
397    /// `<=`
398    Le,
399    /// `==`
400    EqEq,
401    /// `!=`
402    Ne,
403    /// `>=`
404    Ge,
405    /// `>`
406    Gt,
407    /// `&&`
408    AndAnd,
409    /// `||`
410    OrOr,
411    /// `!`
412    Bang,
413    /// `~`
414    Tilde,
415    // `+`
416    Plus,
417    // `-`
418    Minus,
419    // `*`
420    Star,
421    // `/`
422    Slash,
423    // `%`
424    Percent,
425    // `^`
426    Caret,
427    // `&`
428    And,
429    // `|`
430    Or,
431    // `<<`
432    Shl,
433    // `>>`
434    Shr,
435    // `+=`
436    PlusEq,
437    // `-=`
438    MinusEq,
439    // `*=`
440    StarEq,
441    // `/=`
442    SlashEq,
443    // `%=`
444    PercentEq,
445    // `^=`
446    CaretEq,
447    // `&=`
448    AndEq,
449    // `|=`
450    OrEq,
451    // `<<=`
452    ShlEq,
453    // `>>=`
454    ShrEq,
455
456    /* Structural symbols */
457    /// `@`
458    At,
459    /// `.`
460    Dot,
461    /// `..`
462    DotDot,
463    /// `...`
464    DotDotDot,
465    /// `..=`
466    DotDotEq,
467    /// `,`
468    Comma,
469    /// `;`
470    Semi,
471    /// `:`
472    Colon,
473    /// `::`
474    PathSep,
475    /// `->`
476    RArrow,
477    /// `<-`
478    LArrow,
479    /// `=>`
480    FatArrow,
481    /// `#`
482    Pound,
483    /// `$`
484    Dollar,
485    /// `?`
486    Question,
487    /// Used by proc macros for representing lifetimes, not generated by lexer right now.
488    SingleQuote,
489    /// `(`
490    OpenParen,
491    /// `)`
492    CloseParen,
493    /// `{`
494    OpenBrace,
495    /// `}`
496    CloseBrace,
497    /// `[`
498    OpenBracket,
499    /// `]`
500    CloseBracket,
501    /// Invisible opening delimiter, produced by a macro.
502    OpenInvisible(InvisibleOrigin),
503    /// Invisible closing delimiter, produced by a macro.
504    CloseInvisible(InvisibleOrigin),
505
506    /* Literals */
507    Literal(Lit),
508
509    /// Identifier token.
510    /// Do not forget about `NtIdent` when you want to match on identifiers.
511    /// It's recommended to use `Token::{ident,uninterpolate}` and
512    /// `Parser::token_uninterpolated_span` to treat regular and interpolated
513    /// identifiers in the same way.
514    Ident(Symbol, IdentKind),
515    /// This identifier (and its span) is the identifier passed to the
516    /// declarative macro. The span in the surrounding `Token` is the span of
517    /// the `ident` metavariable in the macro's RHS.
518    NtIdent(sp::Ident, IdentKind),
519
520    /// Lifetime identifier token.
521    /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
522    /// It's recommended to use `Token::{ident,uninterpolate}` and
523    /// `Parser::token_uninterpolated_span` to treat regular and interpolated
524    /// identifiers in the same way.
525    Lifetime(Symbol, IdentKind),
526    /// This identifier (and its span) is the lifetime passed to the
527    /// declarative macro. The span in the surrounding `Token` is the span of
528    /// the `lifetime` metavariable in the macro's RHS.
529    NtLifetime(sp::Ident, IdentKind),
530
531    /// A doc comment token.
532    /// `Symbol` is the doc comment's data excluding its "quotes" (`///`, `/**`, etc)
533    /// similarly to symbols in string literal tokens.
534    DocComment(CommentKind, ast::AttrStyle, Symbol),
535
536    /// End Of File
537    Eof,
538}
539
540#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Token {
}
#[automatically_derived]impl ::core::clone::Clone for Token {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<TokenKind>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Token { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Token { }
#[automatically_derived]impl ::core::cmp::PartialEq for Token {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.kind == other.kind && self.span == other.span
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for Token {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TokenKind>;
        let _: ::core::cmp::AssertParamIsEq<Span>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for Token {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.kind, state);
        ::core::hash::Hash::hash(&self.span, state)
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Token {
            fn encode(&self, __encoder: &mut __E) {
                let Token { kind: ref __binding_0, span: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Token {
            fn decode(__decoder: &mut __D) -> Self {
                Token {
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::fmt::Debug for Token {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "Token kind span", &self.kind, &&self.span)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Token {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Token { kind: ref __binding_0, span: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
541pub struct Token {
542    pub kind: TokenKind,
543    pub span: Span,
544}
545
546impl TokenKind {
547    pub fn lit(kind: LitKind, symbol: Symbol, suffix: Option<Symbol>) -> TokenKind {
548        Literal(Lit::new(kind, symbol, suffix))
549    }
550
551    /// An approximation to proc-macro-style single-character operators used by
552    /// rustc parser. If the operator token can be broken into two tokens, the
553    /// first of which has `n` (1 or 2) chars, then this function performs that
554    /// operation, otherwise it returns `None`.
555    pub fn break_two_token_op(&self, n: u32) -> Option<(TokenKind, TokenKind)> {
556        if !(n == 1 || n == 2) {
    ::core::panicking::panic("assertion failed: n == 1 || n == 2")
};assert!(n == 1 || n == 2);
557        Some(match (self, n) {
558            (Le, 1) => (Lt, Eq),
559            (EqEq, 1) => (Eq, Eq),
560            (Ne, 1) => (Bang, Eq),
561            (Ge, 1) => (Gt, Eq),
562            (AndAnd, 1) => (And, And),
563            (OrOr, 1) => (Or, Or),
564            (Shl, 1) => (Lt, Lt),
565            (Shr, 1) => (Gt, Gt),
566            (PlusEq, 1) => (Plus, Eq),
567            (MinusEq, 1) => (Minus, Eq),
568            (StarEq, 1) => (Star, Eq),
569            (SlashEq, 1) => (Slash, Eq),
570            (PercentEq, 1) => (Percent, Eq),
571            (CaretEq, 1) => (Caret, Eq),
572            (AndEq, 1) => (And, Eq),
573            (OrEq, 1) => (Or, Eq),
574            (ShlEq, 1) => (Lt, Le),  // `<` + `<=`
575            (ShlEq, 2) => (Shl, Eq), // `<<` + `=`
576            (ShrEq, 1) => (Gt, Ge),  // `>` + `>=`
577            (ShrEq, 2) => (Shr, Eq), // `>>` + `=`
578            (DotDot, 1) => (Dot, Dot),
579            (DotDotDot, 1) => (Dot, DotDot), // `.` + `..`
580            (DotDotDot, 2) => (DotDot, Dot), // `..` + `.`
581            (DotDotEq, 2) => (DotDot, Eq),
582            (PathSep, 1) => (Colon, Colon),
583            (RArrow, 1) => (Minus, Gt),
584            (LArrow, 1) => (Lt, Minus),
585            (FatArrow, 1) => (Eq, Gt),
586            _ => return None,
587        })
588    }
589
590    /// Returns tokens that are likely to be typed accidentally instead of the current token.
591    /// Enables better error recovery when the wrong token is found.
592    pub fn similar_tokens(&self) -> &[TokenKind] {
593        match self {
594            Comma => &[Dot, Lt, Semi],
595            Semi => &[Colon, Comma],
596            Colon => &[Semi],
597            FatArrow => &[Eq, RArrow, Ge, Gt],
598            _ => &[],
599        }
600    }
601
602    pub fn should_end_const_arg(&self) -> bool {
603        #[allow(non_exhaustive_omitted_patterns)] match self {
    Gt | Ge | Shr | ShrEq => true,
    _ => false,
}matches!(self, Gt | Ge | Shr | ShrEq)
604    }
605
606    pub fn is_delim(&self) -> bool {
607        self.open_delim().is_some() || self.close_delim().is_some()
608    }
609
610    pub fn open_delim(&self) -> Option<Delimiter> {
611        match *self {
612            OpenParen => Some(Delimiter::Parenthesis),
613            OpenBrace => Some(Delimiter::Brace),
614            OpenBracket => Some(Delimiter::Bracket),
615            OpenInvisible(origin) => Some(Delimiter::Invisible(origin)),
616            _ => None,
617        }
618    }
619
620    pub fn close_delim(&self) -> Option<Delimiter> {
621        match *self {
622            CloseParen => Some(Delimiter::Parenthesis),
623            CloseBrace => Some(Delimiter::Brace),
624            CloseBracket => Some(Delimiter::Bracket),
625            CloseInvisible(origin) => Some(Delimiter::Invisible(origin)),
626            _ => None,
627        }
628    }
629
630    pub fn is_close_delim_or_eof(&self) -> bool {
631        match self {
632            CloseParen | CloseBrace | CloseBracket | CloseInvisible(_) | Eof => true,
633            _ => false,
634        }
635    }
636}
637
638impl Token {
639    pub const fn new(kind: TokenKind, span: Span) -> Self {
640        Token { kind, span }
641    }
642
643    /// Some token that will be thrown away later.
644    pub const fn dummy() -> Self {
645        Token::new(TokenKind::Question, DUMMY_SP)
646    }
647
648    /// Recovers a `Token` from an `Ident`.
649    ///
650    /// This creates a raw identifier if necessary.
651    /// It will never create a forced keyword.
652    pub fn from_ast_ident(ident: sp::Ident) -> Self {
653        let kind = if ident.is_raw_guess() { IdentKind::Raw } else { IdentKind::Normal };
654        Token::new(Ident(ident.name, kind), ident.span)
655    }
656
657    pub fn is_range_separator(&self) -> bool {
658        [DotDot, DotDotDot, DotDotEq].contains(&self.kind)
659    }
660
661    pub fn is_punct(&self) -> bool {
662        match self.kind {
663            Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Bang | Tilde | Plus | Minus
664            | Star | Slash | Percent | Caret | And | Or | Shl | Shr | PlusEq | MinusEq | StarEq
665            | SlashEq | PercentEq | CaretEq | AndEq | OrEq | ShlEq | ShrEq | At | Dot | DotDot
666            | DotDotDot | DotDotEq | Comma | Semi | Colon | PathSep | RArrow | LArrow
667            | FatArrow | Pound | Dollar | Question | SingleQuote => true,
668
669            OpenParen | CloseParen | OpenBrace | CloseBrace | OpenBracket | CloseBracket
670            | OpenInvisible(_) | CloseInvisible(_) | Literal(..) | DocComment(..) | Ident(..)
671            | NtIdent(..) | Lifetime(..) | NtLifetime(..) | Eof => false,
672        }
673    }
674
675    pub fn is_like_plus(&self) -> bool {
676        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    Plus | PlusEq => true,
    _ => false,
}matches!(self.kind, Plus | PlusEq)
677    }
678
679    /// Returns `true` if the token can appear at the start of an expression.
680    pub fn can_begin_expr(&self) -> bool {
681        // WARNING: Take care when modifying this function! It will change the stable(!) set of
682        //          tokens that are allowed to match an `expr` nonterminal which is user observable.
683
684        match self.uninterpolate().kind {
685            Ident(name, kind)                 =>
686                ident_can_begin_expr(name, self.span, kind), // value name or keyword
687            OpenParen                         | // tuple
688            OpenBrace                         | // block
689            OpenBracket                       | // array
690            Literal(..)                       | // literal
691            Bang                              | // operator not
692            Minus                             | // unary minus
693            Star                              | // dereference
694            Or | OrOr                         | // closure
695            And                               | // reference
696            AndAnd                            | // double reference
697            // DotDotDot is no longer supported, but we need some way to display the error
698            DotDot | DotDotDot | DotDotEq     | // range notation
699            Lt | Shl                          | // associated path
700            PathSep                           | // global path
701            Lifetime(..)                      | // labeled loop
702            Pound                             => true, // expression attributes
703            OpenInvisible(InvisibleOrigin::MetaVar(
704                MetaVarKind::Block
705                | MetaVarKind::Expr { .. }
706                | MetaVarKind::Literal
707                | MetaVarKind::Path,
708            )) => true,
709            _ => false,
710        }
711    }
712
713    /// Returns `true` if the token can appear at the start of a pattern.
714    pub fn can_begin_pattern(&self, pat_kind: NtPatKind) -> bool {
715        // WARNING: Take care when modifying this function! It will change the stable(!) set of
716        //          tokens that are allowed to match an `pat` nonterminal which is user observable.
717
718        match &self.uninterpolate().kind {
719            // box, ref, mut, and other identifiers (can stricten)
720            Ident(..) | NtIdent(..) |
721            OpenParen |                          // tuple pattern
722            OpenBracket |                        // slice pattern
723            And |                                // reference
724            Minus |                              // negative literal
725            AndAnd |                             // double reference
726            Literal(_) |                         // literal
727            DotDot |                             // range pattern (future compat)
728            DotDotDot |                          // range pattern (future compat)
729            PathSep |                            // path
730            Lt |                                 // path (UFCS constant)
731            Shl => true,                         // path (double UFCS)
732            Or => #[allow(non_exhaustive_omitted_patterns)] match pat_kind {
    PatWithOr => true,
    _ => false,
}matches!(pat_kind, PatWithOr), // leading vert `|` or-pattern
733            OpenInvisible(InvisibleOrigin::MetaVar(
734                MetaVarKind::Expr { .. }
735                | MetaVarKind::Literal
736                | MetaVarKind::Meta { .. }
737                | MetaVarKind::Pat(_)
738                | MetaVarKind::Path
739                | MetaVarKind::Ty { .. },
740            )) => true,
741            _ => false,
742        }
743    }
744
745    /// Returns `true` if the token can appear at the start of a type.
746    pub fn can_begin_type(&self) -> bool {
747        // WARNING: Take care when modifying this function! It will change the stable(!) set of
748        //          tokens that are allowed to match an `ty` nonterminal which is user observable.
749
750        // FIXME: Arguably, `use` should be included in this list since it can begin bare trait
751        //        object types (consider `use<>+` and `use<T> + Trait` for example).
752
753        match self.uninterpolate().kind {
754            Ident(name, kind) =>
755                ident_can_begin_type(name, self.span, kind), // type name or keyword
756            OpenParen          // tuple
757            | OpenBracket      // array
758            | Bang             // never
759            | Star             // raw pointer
760            | And              // reference
761            | AndAnd           // double reference
762            | Question         // maybe bound in trait object
763            | Lifetime(..)     // lifetime bound in trait object
764            | Lt | Shl         // associated path
765            | PathSep => true, // global path
766            OpenInvisible(InvisibleOrigin::MetaVar(MetaVarKind::Ty { .. } | MetaVarKind::Path)) => {
767                true
768            }
769            _ => false,
770        }
771    }
772
773    /// Returns `true` if the token can appear at the start of a const param.
774    pub fn can_begin_const_arg(&self) -> bool {
775        match self.kind {
776            OpenBrace | Literal(..) | Minus => true,
777            Ident(name, IdentKind::Normal | IdentKind::ForcedKeyword) if name.is_bool_lit() => true,
778            OpenInvisible(InvisibleOrigin::MetaVar(
779                MetaVarKind::Expr { .. } | MetaVarKind::Block | MetaVarKind::Literal,
780            )) => true,
781            _ => false,
782        }
783    }
784
785    /// Returns `true` if the token can appear at the start of an item.
786    pub fn can_begin_item(&self) -> bool {
787        match self.kind {
788            Ident(name, _) => [
789                kw::Fn,
790                kw::Use,
791                kw::Struct,
792                kw::Enum,
793                kw::Pub,
794                kw::Trait,
795                kw::Extern,
796                kw::Impl,
797                kw::Unsafe,
798                kw::Const,
799                kw::Safe,
800                kw::Static,
801                kw::Union,
802                kw::Macro,
803                kw::Mod,
804                kw::Type,
805            ]
806            .contains(&name),
807            _ => false,
808        }
809    }
810
811    /// Returns `true` if the token is any literal.
812    pub fn is_lit(&self) -> bool {
813        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    Literal(..) => true,
    _ => false,
}matches!(self.kind, Literal(..))
814    }
815
816    /// Returns `true` if the token is any literal, a minus (which can prefix a literal,
817    /// for example a '-42', or one of the boolean idents).
818    ///
819    /// In other words, would this token be a valid start of `parse_literal_maybe_minus`?
820    ///
821    /// Keep this in sync with `Lit::from_token` and `Parser::eat_token_lit`
822    /// (excluding unary negation).
823    pub fn can_begin_literal_maybe_minus(&self) -> bool {
824        match self.uninterpolate().kind {
825            Literal(..) | Minus => true,
826            Ident(name, IdentKind::Normal | IdentKind::ForcedKeyword) if name.is_bool_lit() => true,
827            OpenInvisible(InvisibleOrigin::MetaVar(mv_kind)) => match mv_kind {
828                MetaVarKind::Literal => true,
829                MetaVarKind::Expr { can_begin_literal_maybe_minus, .. } => {
830                    can_begin_literal_maybe_minus
831                }
832                _ => false,
833            },
834            _ => false,
835        }
836    }
837
838    pub fn can_begin_string_literal(&self) -> bool {
839        match self.uninterpolate().kind {
840            Literal(..) => true,
841            OpenInvisible(InvisibleOrigin::MetaVar(mv_kind)) => match mv_kind {
842                MetaVarKind::Literal => true,
843                MetaVarKind::Expr { can_begin_string_literal, .. } => can_begin_string_literal,
844                _ => false,
845            },
846            _ => false,
847        }
848    }
849
850    /// A convenience function for matching on identifiers during parsing.
851    /// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
852    /// into the regular identifier or lifetime token it refers to,
853    /// otherwise returns the original token.
854    pub fn uninterpolate(&self) -> Cow<'_, Token> {
855        match self.kind {
856            NtIdent(ident, kind) => Cow::Owned(Token::new(Ident(ident.name, kind), ident.span)),
857            NtLifetime(ident, kind) => {
858                Cow::Owned(Token::new(Lifetime(ident.name, kind), ident.span))
859            }
860            _ => Cow::Borrowed(self),
861        }
862    }
863
864    /// Returns an identifier if this token is an identifier.
865    #[inline]
866    pub fn ident(&self) -> Option<(sp::Ident, IdentKind)> {
867        // We avoid using `Token::uninterpolate` here because it's slow.
868        match self.kind {
869            Ident(name, kind) => Some((sp::Ident::new(name, self.span), kind)),
870            NtIdent(ident, kind) => Some((ident, kind)),
871            _ => None,
872        }
873    }
874
875    /// Returns a lifetime identifier if this token is a lifetime.
876    #[inline]
877    pub fn lifetime(&self) -> Option<(sp::Ident, IdentKind)> {
878        // We avoid using `Token::uninterpolate` here because it's slow.
879        match self.kind {
880            Lifetime(name, kind) => Some((sp::Ident::new(name, self.span), kind)),
881            NtLifetime(ident, kind) => Some((ident, kind)),
882            _ => None,
883        }
884    }
885
886    /// Returns `true` if the token is an identifier.
887    pub fn is_ident(&self) -> bool {
888        self.ident().is_some()
889    }
890
891    /// Returns `true` if the token is a lifetime.
892    pub fn is_lifetime(&self) -> bool {
893        self.lifetime().is_some()
894    }
895
896    /// Returns `true` if the token is an identifier whose name is the given
897    /// string slice.
898    pub fn is_ident_named(&self, name: Symbol) -> bool {
899        self.ident().is_some_and(|(ident, _)| ident.name == name)
900    }
901
902    /// Is this a pre-parsed expression dropped into the token stream
903    /// (which happens while parsing the result of macro expansion)?
904    pub fn is_metavar_expr(&self) -> bool {
905        #[allow(non_exhaustive_omitted_patterns)] match self.is_metavar_seq() {
    Some(MetaVarKind::Expr { .. } | MetaVarKind::Literal | MetaVarKind::Path |
        MetaVarKind::Block) => true,
    _ => false,
}matches!(
906            self.is_metavar_seq(),
907            Some(
908                MetaVarKind::Expr { .. }
909                    | MetaVarKind::Literal
910                    | MetaVarKind::Path
911                    | MetaVarKind::Block
912            )
913        )
914    }
915
916    /// Are we at a block from a metavar (`$b:block`)?
917    pub fn is_metavar_block(&self) -> bool {
918        #[allow(non_exhaustive_omitted_patterns)] match self.is_metavar_seq() {
    Some(MetaVarKind::Block) => true,
    _ => false,
}matches!(self.is_metavar_seq(), Some(MetaVarKind::Block))
919    }
920
921    /// Returns `true` if the token is either the `mut` or `const` keyword.
922    pub fn is_mutability(&self) -> bool {
923        self.is_keyword(kw::Mut) || self.is_keyword(kw::Const)
924    }
925
926    pub fn is_qpath_start(&self) -> bool {
927        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    Lt | Shl => true,
    _ => false,
}matches!(self.kind, Lt | Shl)
928    }
929
930    pub fn is_path_start(&self) -> bool {
931        self.kind == PathSep
932            || self.is_qpath_start()
933            || #[allow(non_exhaustive_omitted_patterns)] match self.is_metavar_seq() {
    Some(MetaVarKind::Path) => true,
    _ => false,
}matches!(self.is_metavar_seq(), Some(MetaVarKind::Path))
934            || self.is_path_segment_keyword()
935            || self.is_non_reserved_ident()
936    }
937
938    /// Returns `true` if the token is a given keyword, `kw`.
939    pub fn is_keyword(&self, kw: Symbol) -> bool {
940        self.non_raw_ident().is_some_and(|id| id.name == kw)
941    }
942
943    pub fn is_forced_keyword(&self, kw: Symbol) -> bool {
944        self.ident().is_some_and(|(id, kind)| kind == IdentKind::ForcedKeyword && id.name == kw)
945    }
946
947    /// Returns `true` if the token is a given keyword, `kw` or if `case` is `Insensitive` and this
948    /// token is an identifier equal to `kw` ignoring the case.
949    pub fn is_keyword_case(&self, kw: Symbol, case: Case) -> bool {
950        self.is_keyword(kw)
951            || (case == Case::Insensitive
952                && self.non_raw_ident().is_some_and(|id| {
953                    // Do an ASCII case-insensitive match, because all keywords are ASCII.
954                    id.name.as_str().eq_ignore_ascii_case(kw.as_str())
955                }))
956    }
957
958    pub fn is_path_segment_keyword(&self) -> bool {
959        self.non_raw_ident().is_some_and(sp::Ident::is_path_segment_keyword)
960    }
961
962    /// Returns true for reserved identifiers used internally for elided lifetimes,
963    /// unnamed method parameters, crate root module, error recovery etc.
964    pub fn is_special_ident(&self) -> bool {
965        self.non_raw_ident().is_some_and(sp::Ident::is_special)
966    }
967
968    /// Returns `true` if the token is a keyword used in the language.
969    pub fn is_used_keyword(&self) -> bool {
970        self.non_raw_ident().is_some_and(sp::Ident::is_used_keyword)
971    }
972
973    /// Returns `true` if the token is a keyword reserved for possible future use.
974    pub fn is_unused_keyword(&self) -> bool {
975        self.non_raw_ident().is_some_and(sp::Ident::is_unused_keyword)
976    }
977
978    /// Returns `true` if the token is either a special identifier or a keyword.
979    pub fn is_reserved_ident(&self) -> bool {
980        self.ident().is_some_and(|(id, kind)| ident_of_kind_is_reserved(id, kind))
981    }
982
983    pub fn is_non_reserved_ident(&self) -> bool {
984        self.non_reserved_ident().is_some()
985    }
986
987    pub fn non_reserved_ident(&self) -> Option<sp::Ident> {
988        self.ident().filter(|&(id, kind)| !ident_of_kind_is_reserved(id, kind)).map(|(id, _)| id)
989    }
990
991    /// If this token is a non-raw identifier, return the identifier in question.
992    pub fn non_raw_ident(&self) -> Option<sp::Ident> {
993        match self.ident() {
994            Some((id, IdentKind::Normal | IdentKind::ForcedKeyword)) => Some(id),
995            _ => None,
996        }
997    }
998
999    /// Returns `true` if the token is the identifier `true` or `false`.
1000    pub fn is_bool_lit(&self) -> bool {
1001        self.non_raw_ident().is_some_and(|id| id.name.is_bool_lit())
1002    }
1003
1004    pub fn is_numeric_lit(&self) -> bool {
1005        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    Literal(Lit { kind: LitKind::Integer, .. }) |
        Literal(Lit { kind: LitKind::Float, .. }) => true,
    _ => false,
}matches!(
1006            self.kind,
1007            Literal(Lit { kind: LitKind::Integer, .. }) | Literal(Lit { kind: LitKind::Float, .. })
1008        )
1009    }
1010
1011    /// Returns `true` if the token is the integer literal.
1012    pub fn is_integer_lit(&self) -> bool {
1013        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    Literal(Lit { kind: LitKind::Integer, .. }) => true,
    _ => false,
}matches!(self.kind, Literal(Lit { kind: LitKind::Integer, .. }))
1014    }
1015
1016    /// Is this an invisible open delimiter at the start of a token sequence
1017    /// from an expanded metavar?
1018    pub fn is_metavar_seq(&self) -> Option<MetaVarKind> {
1019        match self.kind {
1020            OpenInvisible(InvisibleOrigin::MetaVar(kind)) => Some(kind),
1021            _ => None,
1022        }
1023    }
1024
1025    pub fn glue(&self, joint: &Token) -> Option<Token> {
1026        let kind = match (&self.kind, &joint.kind) {
1027            (Eq, Eq) => EqEq,
1028            (Eq, Gt) => FatArrow,
1029            (Eq, _) => return None,
1030
1031            (Lt, Eq) => Le,
1032            (Lt, Lt) => Shl,
1033            (Lt, Le) => ShlEq,
1034            (Lt, Minus) => LArrow,
1035            (Lt, _) => return None,
1036
1037            (Gt, Eq) => Ge,
1038            (Gt, Gt) => Shr,
1039            (Gt, Ge) => ShrEq,
1040            (Gt, _) => return None,
1041
1042            (Bang, Eq) => Ne,
1043            (Bang, _) => return None,
1044
1045            (Plus, Eq) => PlusEq,
1046            (Plus, _) => return None,
1047
1048            (Minus, Eq) => MinusEq,
1049            (Minus, Gt) => RArrow,
1050            (Minus, _) => return None,
1051
1052            (Star, Eq) => StarEq,
1053            (Star, _) => return None,
1054
1055            (Slash, Eq) => SlashEq,
1056            (Slash, _) => return None,
1057
1058            (Percent, Eq) => PercentEq,
1059            (Percent, _) => return None,
1060
1061            (Caret, Eq) => CaretEq,
1062            (Caret, _) => return None,
1063
1064            (And, Eq) => AndEq,
1065            (And, And) => AndAnd,
1066            (And, _) => return None,
1067
1068            (Or, Eq) => OrEq,
1069            (Or, Or) => OrOr,
1070            (Or, _) => return None,
1071
1072            (Shl, Eq) => ShlEq,
1073            (Shl, _) => return None,
1074
1075            (Shr, Eq) => ShrEq,
1076            (Shr, _) => return None,
1077
1078            (Dot, Dot) => DotDot,
1079            (Dot, DotDot) => DotDotDot,
1080            (Dot, _) => return None,
1081
1082            (DotDot, Dot) => DotDotDot,
1083            (DotDot, Eq) => DotDotEq,
1084            (DotDot, _) => return None,
1085
1086            (Colon, Colon) => PathSep,
1087            (Colon, _) => return None,
1088
1089            (SingleQuote, Ident(name, kind)) => {
1090                Lifetime(Symbol::intern(&::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("\'{0}", name))
    })format!("'{name}")), *kind)
1091            }
1092            (SingleQuote, _) => return None,
1093
1094            (
1095                Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | PlusEq | MinusEq | StarEq | SlashEq
1096                | PercentEq | CaretEq | AndEq | OrEq | ShlEq | ShrEq | At | DotDotDot | DotDotEq
1097                | Comma | Semi | PathSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question
1098                | OpenParen | CloseParen | OpenBrace | CloseBrace | OpenBracket | CloseBracket
1099                | OpenInvisible(_) | CloseInvisible(_) | Literal(..) | Ident(..) | NtIdent(..)
1100                | Lifetime(..) | NtLifetime(..) | DocComment(..) | Eof,
1101                _,
1102            ) => {
1103                return None;
1104            }
1105        };
1106
1107        Some(Token::new(kind, self.span.to(joint.span)))
1108    }
1109}
1110
1111impl PartialEq<TokenKind> for Token {
1112    #[inline]
1113    fn eq(&self, rhs: &TokenKind) -> bool {
1114        self.kind == *rhs
1115    }
1116}
1117
1118pub fn ident_of_kind_is_reserved(id: sp::Ident, kind: IdentKind) -> bool {
1119    match kind {
1120        IdentKind::Normal => id.is_reserved(),
1121        IdentKind::Raw => false,
1122        IdentKind::ForcedKeyword => true,
1123    }
1124}
1125
1126#[derive(#[automatically_derived]impl ::core::fmt::Debug for NtPatKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::PatWithOr =>
                ::core::fmt::Formatter::write_str(f, "PatWithOr"),
            Self::PatParam { inferred: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "PatParam inferred", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::Copy for NtPatKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for NtPatKind {
}
#[automatically_derived]impl ::core::clone::Clone for NtPatKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for NtPatKind
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for NtPatKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::PatParam { inferred: __self_0 }, Self::PatParam {
                    inferred: __arg1_0 }) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for NtPatKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for NtPatKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        NtPatKind::PatWithOr => { 0usize }
                        NtPatKind::PatParam { inferred: ref __binding_0 } => {
                            1usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    NtPatKind::PatWithOr => {}
                    NtPatKind::PatParam { inferred: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for NtPatKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { NtPatKind::PatWithOr }
                    1usize => {
                        NtPatKind::PatParam {
                            inferred: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `NtPatKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::hash::Hash for NtPatKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::PatParam { inferred: __self_0 } =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for NtPatKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    NtPatKind::PatWithOr => 0u8.stable_hash(__hcx, __hasher),
                    NtPatKind::PatParam { inferred: ref __binding_0 } =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    NtPatKind::PatWithOr => {}
                    NtPatKind::PatParam { inferred: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
1127pub enum NtPatKind {
1128    // Matches or-patterns. Was written using `pat` in edition 2021 or later.
1129    PatWithOr,
1130    // Doesn't match or-patterns.
1131    // - `inferred`: was written using `pat` in edition 2015 or 2018.
1132    // - `!inferred`: was written using `pat_param`.
1133    PatParam { inferred: bool },
1134}
1135
1136#[derive(#[automatically_derived]impl ::core::fmt::Debug for NtExprKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Expr => ::core::fmt::Formatter::write_str(f, "Expr"),
            Self::Expr2021 { inferred: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Expr2021 inferred", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::Copy for NtExprKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for NtExprKind {
}
#[automatically_derived]impl ::core::clone::Clone for NtExprKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    NtExprKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for NtExprKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Expr2021 { inferred: __self_0 }, Self::Expr2021 {
                    inferred: __arg1_0 }) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for NtExprKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for NtExprKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        NtExprKind::Expr => { 0usize }
                        NtExprKind::Expr2021 { inferred: ref __binding_0 } => {
                            1usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    NtExprKind::Expr => {}
                    NtExprKind::Expr2021 { inferred: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for NtExprKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { NtExprKind::Expr }
                    1usize => {
                        NtExprKind::Expr2021 {
                            inferred: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `NtExprKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::hash::Hash for NtExprKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Expr2021 { inferred: __self_0 } =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for NtExprKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    NtExprKind::Expr => 0u8.stable_hash(__hcx, __hasher),
                    NtExprKind::Expr2021 { inferred: ref __binding_0 } =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    NtExprKind::Expr => {}
                    NtExprKind::Expr2021 { inferred: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
1137pub enum NtExprKind {
1138    // Matches expressions using the post-edition 2024. Was written using
1139    // `expr` in edition 2024 or later.
1140    Expr,
1141    // Matches expressions using the pre-edition 2024 rules.
1142    // - `inferred`: was written using `expr` in edition 2021 or earlier.
1143    // - `!inferred`: was written using `expr_2021`.
1144    Expr2021 { inferred: bool },
1145}
1146
1147/// A macro nonterminal, known in documentation as a fragment specifier.
1148#[derive(#[automatically_derived]impl ::core::fmt::Debug for NonterminalKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Item => ::core::fmt::Formatter::write_str(f, "Item"),
            Self::Block => ::core::fmt::Formatter::write_str(f, "Block"),
            Self::Stmt => ::core::fmt::Formatter::write_str(f, "Stmt"),
            Self::Pat(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Pat",
                    &__self_0),
            Self::Expr(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Expr",
                    &__self_0),
            Self::Ty => ::core::fmt::Formatter::write_str(f, "Ty"),
            Self::Ident => ::core::fmt::Formatter::write_str(f, "Ident"),
            Self::Lifetime =>
                ::core::fmt::Formatter::write_str(f, "Lifetime"),
            Self::Literal => ::core::fmt::Formatter::write_str(f, "Literal"),
            Self::Meta => ::core::fmt::Formatter::write_str(f, "Meta"),
            Self::Path => ::core::fmt::Formatter::write_str(f, "Path"),
            Self::Vis => ::core::fmt::Formatter::write_str(f, "Vis"),
            Self::Guard => ::core::fmt::Formatter::write_str(f, "Guard"),
            Self::TT => ::core::fmt::Formatter::write_str(f, "TT"),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::Copy for NonterminalKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for NonterminalKind {
}
#[automatically_derived]impl ::core::clone::Clone for NonterminalKind {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<NtPatKind>;
        let _: ::core::clone::AssertParamIsClone<NtExprKind>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    NonterminalKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for NonterminalKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Pat(__self_0), Self::Pat(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Expr(__self_0), Self::Expr(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for NonterminalKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<NtPatKind>;
        let _: ::core::cmp::AssertParamIsEq<NtExprKind>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for NonterminalKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        NonterminalKind::Item => { 0usize }
                        NonterminalKind::Block => { 1usize }
                        NonterminalKind::Stmt => { 2usize }
                        NonterminalKind::Pat(ref __binding_0) => { 3usize }
                        NonterminalKind::Expr(ref __binding_0) => { 4usize }
                        NonterminalKind::Ty => { 5usize }
                        NonterminalKind::Ident => { 6usize }
                        NonterminalKind::Lifetime => { 7usize }
                        NonterminalKind::Literal => { 8usize }
                        NonterminalKind::Meta => { 9usize }
                        NonterminalKind::Path => { 10usize }
                        NonterminalKind::Vis => { 11usize }
                        NonterminalKind::Guard => { 12usize }
                        NonterminalKind::TT => { 13usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    NonterminalKind::Item => {}
                    NonterminalKind::Block => {}
                    NonterminalKind::Stmt => {}
                    NonterminalKind::Pat(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    NonterminalKind::Expr(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    NonterminalKind::Ty => {}
                    NonterminalKind::Ident => {}
                    NonterminalKind::Lifetime => {}
                    NonterminalKind::Literal => {}
                    NonterminalKind::Meta => {}
                    NonterminalKind::Path => {}
                    NonterminalKind::Vis => {}
                    NonterminalKind::Guard => {}
                    NonterminalKind::TT => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for NonterminalKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { NonterminalKind::Item }
                    1usize => { NonterminalKind::Block }
                    2usize => { NonterminalKind::Stmt }
                    3usize => {
                        NonterminalKind::Pat(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    4usize => {
                        NonterminalKind::Expr(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    5usize => { NonterminalKind::Ty }
                    6usize => { NonterminalKind::Ident }
                    7usize => { NonterminalKind::Lifetime }
                    8usize => { NonterminalKind::Literal }
                    9usize => { NonterminalKind::Meta }
                    10usize => { NonterminalKind::Path }
                    11usize => { NonterminalKind::Vis }
                    12usize => { NonterminalKind::Guard }
                    13usize => { NonterminalKind::TT }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `NonterminalKind`, expected 0..14, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::hash::Hash for NonterminalKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Pat(__self_0) => ::core::hash::Hash::hash(__self_0, state),
            Self::Expr(__self_0) => ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            NonterminalKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    NonterminalKind::Item => 0u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Block => 1u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Stmt => 2u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Pat(ref __binding_0) =>
                        3u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Expr(ref __binding_0) =>
                        4u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Ty => 5u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Ident => 6u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Lifetime =>
                        7u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Literal =>
                        8u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Meta => 9u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Path => 10u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Vis => 11u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::Guard => 12u8.stable_hash(__hcx, __hasher),
                    NonterminalKind::TT => 13u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    NonterminalKind::Item => {}
                    NonterminalKind::Block => {}
                    NonterminalKind::Stmt => {}
                    NonterminalKind::Pat(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    NonterminalKind::Expr(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    NonterminalKind::Ty => {}
                    NonterminalKind::Ident => {}
                    NonterminalKind::Lifetime => {}
                    NonterminalKind::Literal => {}
                    NonterminalKind::Meta => {}
                    NonterminalKind::Path => {}
                    NonterminalKind::Vis => {}
                    NonterminalKind::Guard => {}
                    NonterminalKind::TT => {}
                }
            }
        }
    };StableHash)]
1149pub enum NonterminalKind {
1150    Item,
1151    Block,
1152    Stmt,
1153    Pat(NtPatKind),
1154    Expr(NtExprKind),
1155    Ty,
1156    Ident,
1157    Lifetime,
1158    Literal,
1159    Meta,
1160    Path,
1161    Vis,
1162    Guard,
1163    TT,
1164}
1165
1166impl NonterminalKind {
1167    /// The `edition` closure is used to get the edition for the given symbol. Doing
1168    /// `span.edition()` is expensive, so we do it lazily.
1169    pub fn from_symbol(
1170        symbol: Symbol,
1171        edition: impl FnOnce() -> Edition,
1172    ) -> Option<NonterminalKind> {
1173        Some(match symbol {
1174            sym::item => NonterminalKind::Item,
1175            sym::block => NonterminalKind::Block,
1176            sym::stmt => NonterminalKind::Stmt,
1177            sym::pat => {
1178                if edition().at_least_rust_2021() {
1179                    NonterminalKind::Pat(PatWithOr)
1180                } else {
1181                    NonterminalKind::Pat(PatParam { inferred: true })
1182                }
1183            }
1184            sym::pat_param => NonterminalKind::Pat(PatParam { inferred: false }),
1185            sym::expr => {
1186                if edition().at_least_rust_2024() {
1187                    NonterminalKind::Expr(Expr)
1188                } else {
1189                    NonterminalKind::Expr(Expr2021 { inferred: true })
1190                }
1191            }
1192            sym::expr_2021 => NonterminalKind::Expr(Expr2021 { inferred: false }),
1193            sym::ty => NonterminalKind::Ty,
1194            sym::ident => NonterminalKind::Ident,
1195            sym::lifetime => NonterminalKind::Lifetime,
1196            sym::literal => NonterminalKind::Literal,
1197            sym::meta => NonterminalKind::Meta,
1198            sym::path => NonterminalKind::Path,
1199            sym::vis => NonterminalKind::Vis,
1200            sym::guard => NonterminalKind::Guard,
1201            sym::tt => NonterminalKind::TT,
1202            _ => return None,
1203        })
1204    }
1205
1206    fn symbol(self) -> Symbol {
1207        match self {
1208            NonterminalKind::Item => sym::item,
1209            NonterminalKind::Block => sym::block,
1210            NonterminalKind::Stmt => sym::stmt,
1211            NonterminalKind::Pat(PatParam { inferred: true } | PatWithOr) => sym::pat,
1212            NonterminalKind::Pat(PatParam { inferred: false }) => sym::pat_param,
1213            NonterminalKind::Expr(Expr2021 { inferred: true } | Expr) => sym::expr,
1214            NonterminalKind::Expr(Expr2021 { inferred: false }) => sym::expr_2021,
1215            NonterminalKind::Ty => sym::ty,
1216            NonterminalKind::Ident => sym::ident,
1217            NonterminalKind::Lifetime => sym::lifetime,
1218            NonterminalKind::Literal => sym::literal,
1219            NonterminalKind::Meta => sym::meta,
1220            NonterminalKind::Path => sym::path,
1221            NonterminalKind::Vis => sym::vis,
1222            NonterminalKind::Guard => sym::guard,
1223            NonterminalKind::TT => sym::tt,
1224        }
1225    }
1226}
1227
1228impl fmt::Display for NonterminalKind {
1229    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1230        f.write_fmt(format_args!("{0}", self.symbol()))write!(f, "{}", self.symbol())
1231    }
1232}
1233
1234// Some types are used a lot. Make sure they don't unintentionally get bigger.
1235#[cfg(target_pointer_width = "64")]
1236mod size_asserts {
1237    use rustc_data_structures::static_assert_size;
1238
1239    use super::*;
1240    // tidy-alphabetical-start
1241    const _: [(); 12] = [(); ::std::mem::size_of::<Lit>()];static_assert_size!(Lit, 12);
1242    const _: [(); 2] = [(); ::std::mem::size_of::<LitKind>()];static_assert_size!(LitKind, 2);
1243    const _: [(); 24] = [(); ::std::mem::size_of::<Token>()];static_assert_size!(Token, 24);
1244    const _: [(); 16] = [(); ::std::mem::size_of::<TokenKind>()];static_assert_size!(TokenKind, 16);
1245    // tidy-alphabetical-end
1246}