Skip to content

Commit 8ea79aa

Browse files
committed
add offset_left(4) for 'dyn '
1 parent f8f5d5c commit 8ea79aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/types.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,12 @@ impl Rewrite for ast::Ty {
617617
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
618618
match self.node {
619619
ast::TyKind::TraitObject(ref bounds, tobj_syntax) => {
620-
let res = bounds.rewrite(context, shape)?;
621620
// we have to consider 'dyn' keyword is used or not!!!
622-
if tobj_syntax == ast::TraitObjectSyntax::Dyn {
621+
let is_dyn = tobj_syntax == ast::TraitObjectSyntax::Dyn;
622+
// 4 is length of 'dyn '
623+
let shape = if is_dyn { shape.offset_left(4)? } else { shape };
624+
let res = bounds.rewrite(context, shape)?;
625+
if is_dyn {
623626
Some(format!("dyn {}", res))
624627
} else {
625628
Some(res)

0 commit comments

Comments
 (0)