Skip to content

Commit da965d3

Browse files
committed
Also visit FormatOptions in AST.
1 parent 2f2cb6d commit da965d3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compiler/rustc_ast/src/format.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ pub struct FormatPlaceholder {
180180
#[visitable(ignore)]
181181
pub format_trait: FormatTrait,
182182
/// `{}` or `{:.5}` or `{:-^20}`, etc.
183-
#[visitable(ignore)]
184183
pub format_options: FormatOptions,
185184
}
186185

@@ -229,23 +228,26 @@ pub enum FormatTrait {
229228
UpperHex,
230229
}
231230

232-
#[derive(Clone, Encodable, Decodable, Default, Debug, PartialEq, Eq)]
231+
#[derive(Clone, Encodable, Decodable, Default, Debug, PartialEq, Eq, Walkable)]
233232
pub struct FormatOptions {
234233
/// The width. E.g. `{:5}` or `{:width$}`.
235234
pub width: Option<FormatCount>,
236235
/// The precision. E.g. `{:.5}` or `{:.precision$}`.
237236
pub precision: Option<FormatCount>,
238237
/// The alignment. E.g. `{:>}` or `{:<}` or `{:^}`.
238+
#[visitable(ignore)]
239239
pub alignment: Option<FormatAlignment>,
240240
/// The fill character. E.g. the `.` in `{:.>10}`.
241241
pub fill: Option<char>,
242242
/// The `+` or `-` flag.
243+
#[visitable(ignore)]
243244
pub sign: Option<FormatSign>,
244245
/// The `#` flag.
245246
pub alternate: bool,
246247
/// The `0` flag. E.g. the `0` in `{:02x}`.
247248
pub zero_pad: bool,
248249
/// The `x` or `X` flag (for `Debug` only). E.g. the `x` in `{:x?}`.
250+
#[visitable(ignore)]
249251
pub debug_hex: Option<FormatDebugHex>,
250252
}
251253

@@ -275,7 +277,7 @@ pub enum FormatAlignment {
275277
Center,
276278
}
277279

278-
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
280+
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, Walkable)]
279281
pub enum FormatCount {
280282
/// `{:5}` or `{:.5}`
281283
Literal(u16),

compiler/rustc_ast/src/visit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ macro_rules! common_visitor_and_walkers {
375375
std::borrow::Cow<'_, str>,
376376
Symbol,
377377
u8,
378+
u16,
378379
usize,
379380
);
380381
// `Span` is only a no-op for the non-mutable visitor.
@@ -436,6 +437,8 @@ macro_rules! common_visitor_and_walkers {
436437
FormatArgument,
437438
FormatArgumentKind,
438439
FormatArguments,
440+
FormatCount,
441+
FormatOptions,
439442
FormatPlaceholder,
440443
GenericParamKind,
441444
Impl,

0 commit comments

Comments
 (0)