diff options
| author | Bryanskiy <ivakin.kir@gmail.com> | 2023-11-26 15:57:31 +0300 |
|---|---|---|
| committer | Bryanskiy <ivakin.kir@gmail.com> | 2024-01-12 14:11:16 +0300 |
| commit | d69cd6473c110096bb009db0f2f21da6f67ac5a6 (patch) | |
| tree | 9c9ee290363a90b945c89bb88e734af4ac4f0840 /src/tools/rustfmt | |
| parent | 2b1365b34f0d5ee43944c4266a625923a7b312dd (diff) | |
Delegation implementation: step 1
Diffstat (limited to 'src/tools/rustfmt')
| -rw-r--r-- | src/tools/rustfmt/src/items.rs | 6 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/visitor.rs | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index 6fb69d6b883..b57be8c1054 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -728,7 +728,9 @@ impl<'a> FmtVisitor<'a> { (Const(..), Const(..)) | (MacCall(..), MacCall(..)) => { a.ident.as_str().cmp(b.ident.as_str()) } - (Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()), + (Fn(..), Fn(..)) | (Delegation(..), Delegation(..)) => { + a.span.lo().cmp(&b.span.lo()) + } (Type(ty), _) if is_type(&ty.ty) => Ordering::Less, (_, Type(ty)) if is_type(&ty.ty) => Ordering::Greater, (Type(..), _) => Ordering::Less, @@ -737,6 +739,8 @@ impl<'a> FmtVisitor<'a> { (_, Const(..)) => Ordering::Greater, (MacCall(..), _) => Ordering::Less, (_, MacCall(..)) => Ordering::Greater, + (Delegation(..), _) => Ordering::Less, + (_, Delegation(..)) => Ordering::Greater, }); let mut prev_kind = None; for (buf, item) in buffer { diff --git a/src/tools/rustfmt/src/visitor.rs b/src/tools/rustfmt/src/visitor.rs index f4d84d1381f..bc5accefd92 100644 --- a/src/tools/rustfmt/src/visitor.rs +++ b/src/tools/rustfmt/src/visitor.rs @@ -592,6 +592,11 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ); self.push_rewrite(item.span, rewrite); } + ast::ItemKind::Delegation(..) => { + // TODO: rewrite delegation items once syntax is established. + // For now, leave the contents of the Span unformatted. + self.push_rewrite(item.span, None) + } }; } self.skip_context = skip_context_saved; |
