Format visibility on trait alias
This commit is contained in:
parent
ce682bdabc
commit
96a3df3b5c
4 changed files with 15 additions and 1 deletions
|
@ -1163,6 +1163,7 @@ pub fn format_trait(
|
|||
pub fn format_trait_alias(
|
||||
context: &RewriteContext<'_>,
|
||||
ident: ast::Ident,
|
||||
vis: &ast::Visibility,
|
||||
generics: &ast::Generics,
|
||||
generic_bounds: &ast::GenericBounds,
|
||||
shape: Shape,
|
||||
|
@ -1171,7 +1172,8 @@ pub fn format_trait_alias(
|
|||
// 6 = "trait ", 2 = " ="
|
||||
let g_shape = shape.offset_left(6)?.sub_width(2)?;
|
||||
let generics_str = rewrite_generics(context, &alias, generics, g_shape)?;
|
||||
let lhs = format!("trait {} =", generics_str);
|
||||
let vis_str = format_visibility(context, vis);
|
||||
let lhs = format!("{}trait {} =", vis_str, generics_str);
|
||||
// 1 = ";"
|
||||
rewrite_assign_rhs(context, lhs, generic_bounds, shape.sub_width(1)?).map(|s| s + ";")
|
||||
}
|
||||
|
|
|
@ -363,6 +363,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||
let rw = format_trait_alias(
|
||||
&self.get_context(),
|
||||
item.ident,
|
||||
&item.vis,
|
||||
generics,
|
||||
generic_bounds,
|
||||
shape,
|
||||
|
|
|
@ -84,7 +84,14 @@ trait FooBar =
|
|||
trait FooBar <A, B, C>=
|
||||
Foo
|
||||
+ Bar;
|
||||
pub trait FooBar =
|
||||
Foo
|
||||
+ Bar;
|
||||
pub trait FooBar <A, B, C>=
|
||||
Foo
|
||||
+ Bar;
|
||||
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||
pub trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||
trait AAAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDDD;
|
||||
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<A, B, C, D, E> = FooBar;
|
||||
|
|
|
@ -113,7 +113,11 @@ trait MyTrait<
|
|||
// Trait aliases
|
||||
trait FooBar = Foo + Bar;
|
||||
trait FooBar<A, B, C> = Foo + Bar;
|
||||
pub trait FooBar = Foo + Bar;
|
||||
pub trait FooBar<A, B, C> = Foo + Bar;
|
||||
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||
pub trait AAAAAAAAAAAAAAAAAA =
|
||||
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||
trait AAAAAAAAAAAAAAAAAAA =
|
||||
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||
trait AAAAAAAAAAAAAAAAAA =
|
||||
|
|
Loading…
Reference in a new issue