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(
|
pub fn format_trait_alias(
|
||||||
context: &RewriteContext<'_>,
|
context: &RewriteContext<'_>,
|
||||||
ident: ast::Ident,
|
ident: ast::Ident,
|
||||||
|
vis: &ast::Visibility,
|
||||||
generics: &ast::Generics,
|
generics: &ast::Generics,
|
||||||
generic_bounds: &ast::GenericBounds,
|
generic_bounds: &ast::GenericBounds,
|
||||||
shape: Shape,
|
shape: Shape,
|
||||||
|
|
@ -1171,7 +1172,8 @@ pub fn format_trait_alias(
|
||||||
// 6 = "trait ", 2 = " ="
|
// 6 = "trait ", 2 = " ="
|
||||||
let g_shape = shape.offset_left(6)?.sub_width(2)?;
|
let g_shape = shape.offset_left(6)?.sub_width(2)?;
|
||||||
let generics_str = rewrite_generics(context, &alias, generics, g_shape)?;
|
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 = ";"
|
// 1 = ";"
|
||||||
rewrite_assign_rhs(context, lhs, generic_bounds, shape.sub_width(1)?).map(|s| s + ";")
|
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(
|
let rw = format_trait_alias(
|
||||||
&self.get_context(),
|
&self.get_context(),
|
||||||
item.ident,
|
item.ident,
|
||||||
|
&item.vis,
|
||||||
generics,
|
generics,
|
||||||
generic_bounds,
|
generic_bounds,
|
||||||
shape,
|
shape,
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,14 @@ trait FooBar =
|
||||||
trait FooBar <A, B, C>=
|
trait FooBar <A, B, C>=
|
||||||
Foo
|
Foo
|
||||||
+ Bar;
|
+ Bar;
|
||||||
|
pub trait FooBar =
|
||||||
|
Foo
|
||||||
|
+ Bar;
|
||||||
|
pub trait FooBar <A, B, C>=
|
||||||
|
Foo
|
||||||
|
+ Bar;
|
||||||
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||||
|
pub trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||||
trait AAAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
trait AAAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||||
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDDD;
|
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDDD;
|
||||||
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<A, B, C, D, E> = FooBar;
|
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<A, B, C, D, E> = FooBar;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,11 @@ trait MyTrait<
|
||||||
// Trait aliases
|
// Trait aliases
|
||||||
trait FooBar = Foo + Bar;
|
trait FooBar = Foo + Bar;
|
||||||
trait FooBar<A, B, C> = 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;
|
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||||
|
pub trait AAAAAAAAAAAAAAAAAA =
|
||||||
|
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||||
trait AAAAAAAAAAAAAAAAAAA =
|
trait AAAAAAAAAAAAAAAAAAA =
|
||||||
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
||||||
trait AAAAAAAAAAAAAAAAAA =
|
trait AAAAAAAAAAAAAAAAAA =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue