Skip to main content

rustc_ast/
format.rs

1use rustc_data_structures::fx::FxHashMap;
2use rustc_macros::{Decodable, Encodable, Walkable};
3use rustc_span::{Ident, Span, Symbol};
4
5use crate::Expr;
6use crate::token::LitKind;
7
8// Definitions:
9//
10// format_args!("hello {abc:.xyz$}!!", abc="world");
11// └──────────────────────────────────────────────┘
12//                     FormatArgs
13//
14// format_args!("hello {abc:.xyz$}!!", abc="world");
15//                                     └─────────┘
16//                                      argument
17//
18// format_args!("hello {abc:.xyz$}!!", abc="world");
19//              └───────────────────┘
20//                     template
21//
22// format_args!("hello {abc:.xyz$}!!", abc="world");
23//               └────┘└─────────┘└┘
24//                      pieces
25//
26// format_args!("hello {abc:.xyz$}!!", abc="world");
27//               └────┘           └┘
28//                   literal pieces
29//
30// format_args!("hello {abc:.xyz$}!!", abc="world");
31//                     └─────────┘
32//                     placeholder
33//
34// format_args!("hello {abc:.xyz$}!!", abc="world");
35//                      └─┘  └─┘
36//                      positions (could be names, numbers, empty, or `*`)
37
38/// (Parsed) format args.
39///
40/// Basically the "AST" for a complete `format_args!()`.
41///
42/// E.g., `format_args!("hello {name}");`.
43#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatArgs {
    #[inline]
    fn clone(&self) -> FormatArgs {
        FormatArgs {
            span: ::core::clone::Clone::clone(&self.span),
            template: ::core::clone::Clone::clone(&self.template),
            arguments: ::core::clone::Clone::clone(&self.arguments),
            uncooked_fmt_str: ::core::clone::Clone::clone(&self.uncooked_fmt_str),
            is_source_literal: ::core::clone::Clone::clone(&self.is_source_literal),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArgs {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FormatArgs {
                        span: ref __binding_0,
                        template: ref __binding_1,
                        arguments: ref __binding_2,
                        uncooked_fmt_str: ref __binding_3,
                        is_source_literal: ref __binding_4 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_4,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatArgs {
            fn decode(__decoder: &mut __D) -> Self {
                FormatArgs {
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                    template: ::rustc_serialize::Decodable::decode(__decoder),
                    arguments: ::rustc_serialize::Decodable::decode(__decoder),
                    uncooked_fmt_str: ::rustc_serialize::Decodable::decode(__decoder),
                    is_source_literal: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArgs {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "FormatArgs",
            "span", &self.span, "template", &self.template, "arguments",
            &self.arguments, "uncooked_fmt_str", &self.uncooked_fmt_str,
            "is_source_literal", &&self.is_source_literal)
    }
}Debug, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for FormatArgs
            where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatArgs {
                        span: ref __binding_0,
                        template: ref __binding_1,
                        arguments: ref __binding_2,
                        uncooked_fmt_str: ref __binding_3,
                        is_source_literal: ref __binding_4 } => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_1,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_2,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_3,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_4,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatArgs where
            __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatArgs {
                        span: ref mut __binding_0,
                        template: ref mut __binding_1,
                        arguments: ref mut __binding_2,
                        uncooked_fmt_str: ref mut __binding_3,
                        is_source_literal: ref mut __binding_4 } => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_1,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_2,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_3,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_4,
                                __visitor, ())
                        }
                    }
                }
            }
        }
    };Walkable)]
44pub struct FormatArgs {
45    pub span: Span,
46    pub template: Vec<FormatArgsPiece>,
47    pub arguments: FormatArguments,
48    /// The raw, un-split format string literal, with no escaping or processing.
49    ///
50    /// Generally only useful for lints that care about the raw bytes the user wrote.
51    pub uncooked_fmt_str: (LitKind, Symbol),
52    /// Was the format literal written in the source?
53    /// - `format!("boo")` => true,
54    /// - `format!(concat!("b", "o", "o"))` => false,
55    /// - `format!(include_str!("boo.txt"))` => false,
56    ///
57    /// If it wasn't written in the source then we have to be careful with spans pointing into it
58    /// and suggestions about rewriting it.
59    pub is_source_literal: bool,
60}
61
62/// A piece of a format template string.
63///
64/// E.g. "hello" or "{name}".
65#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatArgsPiece {
    #[inline]
    fn clone(&self) -> FormatArgsPiece {
        match self {
            FormatArgsPiece::Literal(__self_0) =>
                FormatArgsPiece::Literal(::core::clone::Clone::clone(__self_0)),
            FormatArgsPiece::Placeholder(__self_0) =>
                FormatArgsPiece::Placeholder(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArgsPiece {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatArgsPiece::Literal(ref __binding_0) => { 0usize }
                        FormatArgsPiece::Placeholder(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatArgsPiece::Literal(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    FormatArgsPiece::Placeholder(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatArgsPiece {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        FormatArgsPiece::Literal(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        FormatArgsPiece::Placeholder(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatArgsPiece`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArgsPiece {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FormatArgsPiece::Literal(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Literal", &__self_0),
            FormatArgsPiece::Placeholder(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Placeholder", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for
            FormatArgsPiece where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatArgsPiece::Literal(ref __binding_0) => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    FormatArgsPiece::Placeholder(ref __binding_0) => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatArgsPiece where
            __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatArgsPiece::Literal(ref mut __binding_0) => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                    }
                    FormatArgsPiece::Placeholder(ref mut __binding_0) => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                    }
                }
            }
        }
    };Walkable)]
66pub enum FormatArgsPiece {
67    Literal(Symbol),
68    Placeholder(FormatPlaceholder),
69}
70
71/// The arguments to format_args!().
72///
73/// E.g. `1, 2, name="ferris", n=3`,
74/// but also implicit captured arguments like `x` in `format_args!("{x}")`.
75#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatArguments {
    #[inline]
    fn clone(&self) -> FormatArguments {
        FormatArguments {
            arguments: ::core::clone::Clone::clone(&self.arguments),
            num_unnamed_args: ::core::clone::Clone::clone(&self.num_unnamed_args),
            num_explicit_args: ::core::clone::Clone::clone(&self.num_explicit_args),
            names: ::core::clone::Clone::clone(&self.names),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArguments {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FormatArguments {
                        arguments: ref __binding_0,
                        num_unnamed_args: ref __binding_1,
                        num_explicit_args: ref __binding_2,
                        names: ref __binding_3 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatArguments {
            fn decode(__decoder: &mut __D) -> Self {
                FormatArguments {
                    arguments: ::rustc_serialize::Decodable::decode(__decoder),
                    num_unnamed_args: ::rustc_serialize::Decodable::decode(__decoder),
                    num_explicit_args: ::rustc_serialize::Decodable::decode(__decoder),
                    names: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArguments {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "FormatArguments", "arguments", &self.arguments,
            "num_unnamed_args", &self.num_unnamed_args, "num_explicit_args",
            &self.num_explicit_args, "names", &&self.names)
    }
}Debug, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for
            FormatArguments where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatArguments {
                        arguments: ref __binding_0,
                        num_unnamed_args: ref __binding_1,
                        num_explicit_args: ref __binding_2,
                        names: ref __binding_3 } => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_1,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_2,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_3,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatArguments where
            __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatArguments {
                        arguments: ref mut __binding_0,
                        num_unnamed_args: ref mut __binding_1,
                        num_explicit_args: ref mut __binding_2,
                        names: ref mut __binding_3 } => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_1,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_2,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_3,
                                __visitor, ())
                        }
                    }
                }
            }
        }
    };Walkable)]
76pub struct FormatArguments {
77    arguments: Vec<FormatArgument>,
78    num_unnamed_args: usize,
79    num_explicit_args: usize,
80    names: FxHashMap<Symbol, usize>,
81}
82
83impl FormatArguments {
84    pub fn new() -> Self {
85        Self {
86            arguments: Vec::new(),
87            names: FxHashMap::default(),
88            num_unnamed_args: 0,
89            num_explicit_args: 0,
90        }
91    }
92
93    pub fn add(&mut self, arg: FormatArgument) -> usize {
94        let index = self.arguments.len();
95        if let Some(name) = arg.kind.ident() {
96            self.names.insert(name.name, index);
97        } else if self.names.is_empty() {
98            // Only count the unnamed args before the first named arg.
99            // (Any later ones are errors.)
100            self.num_unnamed_args += 1;
101        }
102        if !#[allow(non_exhaustive_omitted_patterns)] match arg.kind {
    FormatArgumentKind::Captured(..) => true,
    _ => false,
}matches!(arg.kind, FormatArgumentKind::Captured(..)) {
103            // This is an explicit argument.
104            // Make sure that all arguments so far are explicit.
105            match (&self.num_explicit_args, &self.arguments.len()) {
    (left_val, right_val) => {
        if !(*left_val == *right_val) {
            let kind = ::core::panicking::AssertKind::Eq;
            ::core::panicking::assert_failed(kind, &*left_val, &*right_val,
                ::core::option::Option::Some(format_args!("captured arguments must be added last")));
        }
    }
};assert_eq!(
106                self.num_explicit_args,
107                self.arguments.len(),
108                "captured arguments must be added last"
109            );
110            self.num_explicit_args += 1;
111        }
112        self.arguments.push(arg);
113        index
114    }
115
116    pub fn by_name(&self, name: Symbol) -> Option<(usize, &FormatArgument)> {
117        let i = *self.names.get(&name)?;
118        Some((i, &self.arguments[i]))
119    }
120
121    pub fn by_index(&self, i: usize) -> Option<&FormatArgument> {
122        (i < self.num_explicit_args).then(|| &self.arguments[i])
123    }
124
125    pub fn unnamed_args(&self) -> &[FormatArgument] {
126        &self.arguments[..self.num_unnamed_args]
127    }
128
129    pub fn named_args(&self) -> &[FormatArgument] {
130        &self.arguments[self.num_unnamed_args..self.num_explicit_args]
131    }
132
133    pub fn explicit_args(&self) -> &[FormatArgument] {
134        &self.arguments[..self.num_explicit_args]
135    }
136
137    pub fn all_args(&self) -> &[FormatArgument] {
138        &self.arguments[..]
139    }
140
141    pub fn all_args_mut(&mut self) -> &mut Vec<FormatArgument> {
142        &mut self.arguments
143    }
144}
145
146#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatArgument {
    #[inline]
    fn clone(&self) -> FormatArgument {
        FormatArgument {
            kind: ::core::clone::Clone::clone(&self.kind),
            expr: ::core::clone::Clone::clone(&self.expr),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArgument {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FormatArgument {
                        kind: ref __binding_0, expr: ref __binding_1 } => {
                        ::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 FormatArgument {
            fn decode(__decoder: &mut __D) -> Self {
                FormatArgument {
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    expr: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArgument {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "FormatArgument", "kind", &self.kind, "expr", &&self.expr)
    }
}Debug, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for
            FormatArgument where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatArgument {
                        kind: ref __binding_0, expr: ref __binding_1 } => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_1,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatArgument where
            __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatArgument {
                        kind: ref mut __binding_0, expr: ref mut __binding_1 } => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_1,
                                __visitor, ())
                        }
                    }
                }
            }
        }
    };Walkable)]
147pub struct FormatArgument {
148    pub kind: FormatArgumentKind,
149    pub expr: Box<Expr>,
150}
151
152#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatArgumentKind {
    #[inline]
    fn clone(&self) -> FormatArgumentKind {
        match self {
            FormatArgumentKind::Normal => FormatArgumentKind::Normal,
            FormatArgumentKind::Named(__self_0) =>
                FormatArgumentKind::Named(::core::clone::Clone::clone(__self_0)),
            FormatArgumentKind::Captured(__self_0) =>
                FormatArgumentKind::Captured(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArgumentKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatArgumentKind::Normal => { 0usize }
                        FormatArgumentKind::Named(ref __binding_0) => { 1usize }
                        FormatArgumentKind::Captured(ref __binding_0) => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatArgumentKind::Normal => {}
                    FormatArgumentKind::Named(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    FormatArgumentKind::Captured(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatArgumentKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { FormatArgumentKind::Normal }
                    1usize => {
                        FormatArgumentKind::Named(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        FormatArgumentKind::Captured(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatArgumentKind`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArgumentKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FormatArgumentKind::Normal =>
                ::core::fmt::Formatter::write_str(f, "Normal"),
            FormatArgumentKind::Named(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Named",
                    &__self_0),
            FormatArgumentKind::Captured(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Captured", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for
            FormatArgumentKind where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatArgumentKind::Normal => {}
                    FormatArgumentKind::Named(ref __binding_0) => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    FormatArgumentKind::Captured(ref __binding_0) => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatArgumentKind
            where __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatArgumentKind::Normal => {}
                    FormatArgumentKind::Named(ref mut __binding_0) => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                    }
                    FormatArgumentKind::Captured(ref mut __binding_0) => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                    }
                }
            }
        }
    };Walkable)]
153pub enum FormatArgumentKind {
154    /// `format_args(…, arg)`
155    Normal,
156    /// `format_args(…, arg = 1)`
157    Named(Ident),
158    /// `format_args("… {arg} …")`
159    Captured(Ident),
160}
161
162impl FormatArgumentKind {
163    pub fn ident(&self) -> Option<Ident> {
164        match self {
165            &Self::Normal => None,
166            &Self::Named(id) => Some(id),
167            &Self::Captured(id) => Some(id),
168        }
169    }
170}
171
172#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatPlaceholder {
    #[inline]
    fn clone(&self) -> FormatPlaceholder {
        FormatPlaceholder {
            argument: ::core::clone::Clone::clone(&self.argument),
            span: ::core::clone::Clone::clone(&self.span),
            format_trait: ::core::clone::Clone::clone(&self.format_trait),
            format_options: ::core::clone::Clone::clone(&self.format_options),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatPlaceholder {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FormatPlaceholder {
                        argument: ref __binding_0,
                        span: ref __binding_1,
                        format_trait: ref __binding_2,
                        format_options: ref __binding_3 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatPlaceholder {
            fn decode(__decoder: &mut __D) -> Self {
                FormatPlaceholder {
                    argument: ::rustc_serialize::Decodable::decode(__decoder),
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                    format_trait: ::rustc_serialize::Decodable::decode(__decoder),
                    format_options: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatPlaceholder {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "FormatPlaceholder", "argument", &self.argument, "span",
            &self.span, "format_trait", &self.format_trait, "format_options",
            &&self.format_options)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatPlaceholder {
    #[inline]
    fn eq(&self, other: &FormatPlaceholder) -> bool {
        self.argument == other.argument && self.span == other.span &&
                self.format_trait == other.format_trait &&
            self.format_options == other.format_options
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatPlaceholder {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<FormatArgPosition>;
        let _: ::core::cmp::AssertParamIsEq<Option<Span>>;
        let _: ::core::cmp::AssertParamIsEq<FormatTrait>;
        let _: ::core::cmp::AssertParamIsEq<FormatOptions>;
    }
}Eq, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for
            FormatPlaceholder where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatPlaceholder {
                        argument: ref __binding_0,
                        span: ref __binding_1,
                        format_trait: ref __binding_2,
                        format_options: ref __binding_3 } => {
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_0,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_1,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {}
                        {}
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatPlaceholder
            where __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatPlaceholder {
                        argument: ref mut __binding_0,
                        span: ref mut __binding_1,
                        format_trait: ref mut __binding_2,
                        format_options: ref mut __binding_3 } => {
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_0,
                                __visitor, ())
                        }
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_1,
                                __visitor, ())
                        }
                        {}
                        {}
                    }
                }
            }
        }
    };Walkable)]
173pub struct FormatPlaceholder {
174    /// Index into [`FormatArgs::arguments`].
175    pub argument: FormatArgPosition,
176    /// The span inside the format string for the full `{…}` placeholder.
177    pub span: Option<Span>,
178    /// `{}`, `{:?}`, or `{:x}`, etc.
179    #[visitable(ignore)]
180    pub format_trait: FormatTrait,
181    /// `{}` or `{:.5}` or `{:-^20}`, etc.
182    #[visitable(ignore)]
183    pub format_options: FormatOptions,
184}
185
186#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatArgPosition {
    #[inline]
    fn clone(&self) -> FormatArgPosition {
        FormatArgPosition {
            index: ::core::clone::Clone::clone(&self.index),
            kind: ::core::clone::Clone::clone(&self.kind),
            span: ::core::clone::Clone::clone(&self.span),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArgPosition {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FormatArgPosition {
                        index: ref __binding_0,
                        kind: ref __binding_1,
                        span: 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);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatArgPosition {
            fn decode(__decoder: &mut __D) -> Self {
                FormatArgPosition {
                    index: ::rustc_serialize::Decodable::decode(__decoder),
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArgPosition {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "FormatArgPosition", "index", &self.index, "kind", &self.kind,
            "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatArgPosition {
    #[inline]
    fn eq(&self, other: &FormatArgPosition) -> bool {
        self.index == other.index && self.kind == other.kind &&
            self.span == other.span
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatArgPosition {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Result<usize, usize>>;
        let _: ::core::cmp::AssertParamIsEq<FormatArgPositionKind>;
        let _: ::core::cmp::AssertParamIsEq<Option<Span>>;
    }
}Eq, const _: () =
    {
        impl<'__ast, __V> crate::visit::Walkable<'__ast, __V> for
            FormatArgPosition where __V: crate::visit::Visitor<'__ast> {
            fn walk_ref(&'__ast self, __visitor: &mut __V) -> __V::Result {
                match *self {
                    FormatArgPosition {
                        index: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2 } => {
                        {}
                        {}
                        {
                            match ::rustc_ast_ir::visit::VisitorResult::branch(crate::visit::Visitable::visit(__binding_2,
                                        __visitor, ())) {
                                core::ops::ControlFlow::Continue(()) =>
                                    (),
                                    #[allow(unreachable_code)]
                                    core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as rustc_ast_ir::visit::VisitorResult>::output()
            }
        }
        impl<__V> crate::mut_visit::MutWalkable<__V> for FormatArgPosition
            where __V: crate::mut_visit::MutVisitor {
            fn walk_mut(&mut self, __visitor: &mut __V) {
                match *self {
                    FormatArgPosition {
                        index: ref mut __binding_0,
                        kind: ref mut __binding_1,
                        span: ref mut __binding_2 } => {
                        {}
                        {}
                        {
                            crate::mut_visit::MutVisitable::visit_mut(__binding_2,
                                __visitor, ())
                        }
                    }
                }
            }
        }
    };Walkable)]
187pub struct FormatArgPosition {
188    /// Which argument this position refers to (Ok),
189    /// or would've referred to if it existed (Err).
190    #[visitable(ignore)]
191    pub index: Result<usize, usize>,
192    /// What kind of position this is. See [`FormatArgPositionKind`].
193    #[visitable(ignore)]
194    pub kind: FormatArgPositionKind,
195    /// The span of the name or number.
196    pub span: Option<Span>,
197}
198
199#[derive(#[automatically_derived]
impl ::core::marker::Copy for FormatArgPositionKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FormatArgPositionKind {
    #[inline]
    fn clone(&self) -> FormatArgPositionKind { *self }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatArgPositionKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatArgPositionKind::Implicit => { 0usize }
                        FormatArgPositionKind::Number => { 1usize }
                        FormatArgPositionKind::Named => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatArgPositionKind::Implicit => {}
                    FormatArgPositionKind::Number => {}
                    FormatArgPositionKind::Named => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatArgPositionKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { FormatArgPositionKind::Implicit }
                    1usize => { FormatArgPositionKind::Number }
                    2usize => { FormatArgPositionKind::Named }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatArgPositionKind`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatArgPositionKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FormatArgPositionKind::Implicit => "Implicit",
                FormatArgPositionKind::Number => "Number",
                FormatArgPositionKind::Named => "Named",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatArgPositionKind {
    #[inline]
    fn eq(&self, other: &FormatArgPositionKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatArgPositionKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
200pub enum FormatArgPositionKind {
201    /// `{}` or `{:.*}`
202    Implicit,
203    /// `{1}` or `{:1$}` or `{:.1$}`
204    Number,
205    /// `{a}` or `{:a$}` or `{:.a$}`
206    Named,
207}
208
209#[derive(#[automatically_derived]
impl ::core::marker::Copy for FormatTrait { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FormatTrait {
    #[inline]
    fn clone(&self) -> FormatTrait { *self }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatTrait {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatTrait::Display => { 0usize }
                        FormatTrait::Debug => { 1usize }
                        FormatTrait::LowerExp => { 2usize }
                        FormatTrait::UpperExp => { 3usize }
                        FormatTrait::Octal => { 4usize }
                        FormatTrait::Pointer => { 5usize }
                        FormatTrait::Binary => { 6usize }
                        FormatTrait::LowerHex => { 7usize }
                        FormatTrait::UpperHex => { 8usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatTrait::Display => {}
                    FormatTrait::Debug => {}
                    FormatTrait::LowerExp => {}
                    FormatTrait::UpperExp => {}
                    FormatTrait::Octal => {}
                    FormatTrait::Pointer => {}
                    FormatTrait::Binary => {}
                    FormatTrait::LowerHex => {}
                    FormatTrait::UpperHex => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatTrait {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { FormatTrait::Display }
                    1usize => { FormatTrait::Debug }
                    2usize => { FormatTrait::LowerExp }
                    3usize => { FormatTrait::UpperExp }
                    4usize => { FormatTrait::Octal }
                    5usize => { FormatTrait::Pointer }
                    6usize => { FormatTrait::Binary }
                    7usize => { FormatTrait::LowerHex }
                    8usize => { FormatTrait::UpperHex }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatTrait`, expected 0..9, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatTrait {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FormatTrait::Display => "Display",
                FormatTrait::Debug => "Debug",
                FormatTrait::LowerExp => "LowerExp",
                FormatTrait::UpperExp => "UpperExp",
                FormatTrait::Octal => "Octal",
                FormatTrait::Pointer => "Pointer",
                FormatTrait::Binary => "Binary",
                FormatTrait::LowerHex => "LowerHex",
                FormatTrait::UpperHex => "UpperHex",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatTrait {
    #[inline]
    fn eq(&self, other: &FormatTrait) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatTrait {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for FormatTrait {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash)]
210pub enum FormatTrait {
211    /// `{}`
212    Display,
213    /// `{:?}`
214    Debug,
215    /// `{:e}`
216    LowerExp,
217    /// `{:E}`
218    UpperExp,
219    /// `{:o}`
220    Octal,
221    /// `{:p}`
222    Pointer,
223    /// `{:b}`
224    Binary,
225    /// `{:x}`
226    LowerHex,
227    /// `{:X}`
228    UpperHex,
229}
230
231#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatOptions {
    #[inline]
    fn clone(&self) -> FormatOptions {
        FormatOptions {
            width: ::core::clone::Clone::clone(&self.width),
            precision: ::core::clone::Clone::clone(&self.precision),
            alignment: ::core::clone::Clone::clone(&self.alignment),
            fill: ::core::clone::Clone::clone(&self.fill),
            sign: ::core::clone::Clone::clone(&self.sign),
            alternate: ::core::clone::Clone::clone(&self.alternate),
            zero_pad: ::core::clone::Clone::clone(&self.zero_pad),
            debug_hex: ::core::clone::Clone::clone(&self.debug_hex),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatOptions {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FormatOptions {
                        width: ref __binding_0,
                        precision: ref __binding_1,
                        alignment: ref __binding_2,
                        fill: ref __binding_3,
                        sign: ref __binding_4,
                        alternate: ref __binding_5,
                        zero_pad: ref __binding_6,
                        debug_hex: ref __binding_7 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_4,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_5,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_6,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_7,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatOptions {
            fn decode(__decoder: &mut __D) -> Self {
                FormatOptions {
                    width: ::rustc_serialize::Decodable::decode(__decoder),
                    precision: ::rustc_serialize::Decodable::decode(__decoder),
                    alignment: ::rustc_serialize::Decodable::decode(__decoder),
                    fill: ::rustc_serialize::Decodable::decode(__decoder),
                    sign: ::rustc_serialize::Decodable::decode(__decoder),
                    alternate: ::rustc_serialize::Decodable::decode(__decoder),
                    zero_pad: ::rustc_serialize::Decodable::decode(__decoder),
                    debug_hex: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::default::Default for FormatOptions {
    #[inline]
    fn default() -> FormatOptions {
        FormatOptions {
            width: ::core::default::Default::default(),
            precision: ::core::default::Default::default(),
            alignment: ::core::default::Default::default(),
            fill: ::core::default::Default::default(),
            sign: ::core::default::Default::default(),
            alternate: ::core::default::Default::default(),
            zero_pad: ::core::default::Default::default(),
            debug_hex: ::core::default::Default::default(),
        }
    }
}Default, #[automatically_derived]
impl ::core::fmt::Debug for FormatOptions {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["width", "precision", "alignment", "fill", "sign", "alternate",
                        "zero_pad", "debug_hex"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.width, &self.precision, &self.alignment, &self.fill,
                        &self.sign, &self.alternate, &self.zero_pad,
                        &&self.debug_hex];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "FormatOptions",
            names, values)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatOptions {
    #[inline]
    fn eq(&self, other: &FormatOptions) -> bool {
        self.alternate == other.alternate && self.zero_pad == other.zero_pad
                                && self.width == other.width &&
                            self.precision == other.precision &&
                        self.alignment == other.alignment && self.fill == other.fill
                && self.sign == other.sign &&
            self.debug_hex == other.debug_hex
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatOptions {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Option<FormatCount>>;
        let _: ::core::cmp::AssertParamIsEq<Option<FormatCount>>;
        let _: ::core::cmp::AssertParamIsEq<Option<FormatAlignment>>;
        let _: ::core::cmp::AssertParamIsEq<Option<char>>;
        let _: ::core::cmp::AssertParamIsEq<Option<FormatSign>>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
        let _: ::core::cmp::AssertParamIsEq<Option<FormatDebugHex>>;
    }
}Eq)]
232pub struct FormatOptions {
233    /// The width. E.g. `{:5}` or `{:width$}`.
234    pub width: Option<FormatCount>,
235    /// The precision. E.g. `{:.5}` or `{:.precision$}`.
236    pub precision: Option<FormatCount>,
237    /// The alignment. E.g. `{:>}` or `{:<}` or `{:^}`.
238    pub alignment: Option<FormatAlignment>,
239    /// The fill character. E.g. the `.` in `{:.>10}`.
240    pub fill: Option<char>,
241    /// The `+` or `-` flag.
242    pub sign: Option<FormatSign>,
243    /// The `#` flag.
244    pub alternate: bool,
245    /// The `0` flag. E.g. the `0` in `{:02x}`.
246    pub zero_pad: bool,
247    /// The `x` or `X` flag (for `Debug` only). E.g. the `x` in `{:x?}`.
248    pub debug_hex: Option<FormatDebugHex>,
249}
250
251#[derive(#[automatically_derived]
impl ::core::marker::Copy for FormatSign { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FormatSign {
    #[inline]
    fn clone(&self) -> FormatSign { *self }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatSign {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatSign::Plus => { 0usize }
                        FormatSign::Minus => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self { FormatSign::Plus => {} FormatSign::Minus => {} }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatSign {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { FormatSign::Plus }
                    1usize => { FormatSign::Minus }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatSign`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatSign {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FormatSign::Plus => "Plus",
                FormatSign::Minus => "Minus",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatSign {
    #[inline]
    fn eq(&self, other: &FormatSign) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatSign {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
252pub enum FormatSign {
253    /// The `+` flag.
254    Plus,
255    /// The `-` flag.
256    Minus,
257}
258
259#[derive(#[automatically_derived]
impl ::core::marker::Copy for FormatDebugHex { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FormatDebugHex {
    #[inline]
    fn clone(&self) -> FormatDebugHex { *self }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatDebugHex {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatDebugHex::Lower => { 0usize }
                        FormatDebugHex::Upper => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatDebugHex::Lower => {}
                    FormatDebugHex::Upper => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatDebugHex {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { FormatDebugHex::Lower }
                    1usize => { FormatDebugHex::Upper }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatDebugHex`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatDebugHex {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FormatDebugHex::Lower => "Lower",
                FormatDebugHex::Upper => "Upper",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatDebugHex {
    #[inline]
    fn eq(&self, other: &FormatDebugHex) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatDebugHex {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
260pub enum FormatDebugHex {
261    /// The `x` flag in `{:x?}`.
262    Lower,
263    /// The `X` flag in `{:X?}`.
264    Upper,
265}
266
267#[derive(#[automatically_derived]
impl ::core::marker::Copy for FormatAlignment { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FormatAlignment {
    #[inline]
    fn clone(&self) -> FormatAlignment { *self }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatAlignment {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatAlignment::Left => { 0usize }
                        FormatAlignment::Right => { 1usize }
                        FormatAlignment::Center => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatAlignment::Left => {}
                    FormatAlignment::Right => {}
                    FormatAlignment::Center => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatAlignment {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { FormatAlignment::Left }
                    1usize => { FormatAlignment::Right }
                    2usize => { FormatAlignment::Center }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatAlignment`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatAlignment {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FormatAlignment::Left => "Left",
                FormatAlignment::Right => "Right",
                FormatAlignment::Center => "Center",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatAlignment {
    #[inline]
    fn eq(&self, other: &FormatAlignment) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatAlignment {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
268pub enum FormatAlignment {
269    /// `{:<}`
270    Left,
271    /// `{:>}`
272    Right,
273    /// `{:^}`
274    Center,
275}
276
277#[derive(#[automatically_derived]
impl ::core::clone::Clone for FormatCount {
    #[inline]
    fn clone(&self) -> FormatCount {
        match self {
            FormatCount::Literal(__self_0) =>
                FormatCount::Literal(::core::clone::Clone::clone(__self_0)),
            FormatCount::Argument(__self_0) =>
                FormatCount::Argument(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for FormatCount {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        FormatCount::Literal(ref __binding_0) => { 0usize }
                        FormatCount::Argument(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    FormatCount::Literal(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    FormatCount::Argument(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for FormatCount {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        FormatCount::Literal(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        FormatCount::Argument(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FormatCount`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for FormatCount {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FormatCount::Literal(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Literal", &__self_0),
            FormatCount::Argument(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Argument", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FormatCount {
    #[inline]
    fn eq(&self, other: &FormatCount) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (FormatCount::Literal(__self_0),
                    FormatCount::Literal(__arg1_0)) => __self_0 == __arg1_0,
                (FormatCount::Argument(__self_0),
                    FormatCount::Argument(__arg1_0)) => __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FormatCount {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u16>;
        let _: ::core::cmp::AssertParamIsEq<FormatArgPosition>;
    }
}Eq)]
278pub enum FormatCount {
279    /// `{:5}` or `{:.5}`
280    Literal(u16),
281    /// `{:.*}`, `{:.5$}`, or `{:a$}`, etc.
282    Argument(FormatArgPosition),
283}