Skip to content

Commit 338bfb7

Browse files
Update AST pretty printing
1 parent 0a9988e commit 338bfb7

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3786,10 +3786,10 @@ pub struct TraitAlias {
37863786

37873787
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
37883788
pub struct Trait {
3789+
pub impl_restriction: ImplRestriction,
37893790
pub constness: Const,
37903791
pub safety: Safety,
37913792
pub is_auto: IsAuto,
3792-
pub impl_restriction: ImplRestriction,
37933793
pub ident: Ident,
37943794
pub generics: Generics,
37953795
#[visitable(extra = BoundKind::SuperTraits)]

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
543543
})
544544
}
545545
ItemKind::Trait(box Trait {
546+
impl_restriction,
546547
constness,
547548
is_auto,
548549
safety,
549-
impl_restriction,
550550
ident,
551551
generics,
552552
bounds,

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,21 +371,21 @@ impl<'a> State<'a> {
371371
self.bclose(item.span, empty, cb);
372372
}
373373
ast::ItemKind::Trait(box ast::Trait {
374+
impl_restriction,
374375
constness,
375376
safety,
376377
is_auto,
377-
impl_restriction,
378378
ident,
379379
generics,
380380
bounds,
381381
items,
382382
}) => {
383383
let (cb, ib) = self.head("");
384384
self.print_visibility(&item.vis);
385+
self.print_impl_restriction(impl_restriction);
385386
self.print_constness(*constness);
386387
self.print_safety(*safety);
387388
self.print_is_auto(*is_auto);
388-
self.print_impl_restriction(impl_restriction);
389389
self.word_nbsp("trait");
390390
self.print_ident(*ident);
391391
self.print_generic_params(&generics.params);

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,10 +1134,10 @@ impl<'a> Parser<'a> {
11341134
generics.where_clause = self.parse_where_clause()?;
11351135
let items = self.parse_item_list(attrs, |p| p.parse_trait_item(ForceCollect::No))?;
11361136
Ok(ItemKind::Trait(Box::new(Trait {
1137+
impl_restriction,
11371138
constness,
11381139
is_auto,
11391140
safety,
1140-
impl_restriction,
11411141
ident,
11421142
generics,
11431143
bounds,

src/tools/clippy/clippy_utils/src/ast_utils/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,30 +448,30 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
448448
},
449449
(
450450
Trait(box ast::Trait {
451+
impl_restriction: liprt,
451452
constness: lc,
452453
is_auto: la,
453454
safety: lu,
454-
impl_restriction: liprt,
455455
ident: li,
456456
generics: lg,
457457
bounds: lb,
458458
items: lis,
459459
}),
460460
Trait(box ast::Trait {
461+
impl_restriction: riprt,
461462
constness: rc,
462463
is_auto: ra,
463464
safety: ru,
464-
impl_restriction: riprt,
465465
ident: ri,
466466
generics: rg,
467467
bounds: rb,
468468
items: ris,
469469
}),
470470
) => {
471-
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
471+
eq_impl_restriction(liprt, riprt)
472+
&& matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
472473
&& la == ra
473474
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
474-
&& eq_impl_restriction(liprt, riprt)
475475
&& eq_id(*li, *ri)
476476
&& eq_generics(lg, rg)
477477
&& over(lb, rb, eq_generic_bound)

src/tools/rustfmt/src/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,10 @@ pub(crate) fn format_trait(
11551155
offset: Indent,
11561156
) -> RewriteResult {
11571157
let ast::Trait {
1158+
ref impl_restriction,
11581159
constness,
11591160
is_auto,
11601161
safety,
1161-
ref impl_restriction,
11621162
ident,
11631163
ref generics,
11641164
ref bounds,

0 commit comments

Comments
 (0)