keep auto trait
This commit is contained in:
parent
866900449a
commit
5b5a72c840
2 changed files with 20 additions and 7 deletions
19
src/items.rs
19
src/items.rs
|
|
@ -32,9 +32,9 @@ use rewrite::{Rewrite, RewriteContext};
|
||||||
use shape::{Indent, Shape};
|
use shape::{Indent, Shape};
|
||||||
use spanned::Spanned;
|
use spanned::Spanned;
|
||||||
use types::TraitTyParamBounds;
|
use types::TraitTyParamBounds;
|
||||||
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_constness,
|
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_auto,
|
||||||
format_defaultness, format_mutability, format_unsafety, format_visibility,
|
format_constness, format_defaultness, format_mutability, format_unsafety,
|
||||||
is_attributes_extendable, last_line_contains_single_line_comment,
|
format_visibility, is_attributes_extendable, last_line_contains_single_line_comment,
|
||||||
last_line_used_width, last_line_width, mk_sp, semicolon_for_expr, starts_with_newline,
|
last_line_used_width, last_line_width, mk_sp, semicolon_for_expr, starts_with_newline,
|
||||||
stmt_expr, trimmed_last_line_width};
|
stmt_expr, trimmed_last_line_width};
|
||||||
use vertical::rewrite_with_alignment;
|
use vertical::rewrite_with_alignment;
|
||||||
|
|
@ -936,16 +936,21 @@ fn format_struct(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent) -> Option<String> {
|
pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent) -> Option<String> {
|
||||||
if let ast::ItemKind::Trait(_, unsafety, ref generics, ref type_param_bounds, ref trait_items) =
|
if let ast::ItemKind::Trait(
|
||||||
item.node
|
is_auto,
|
||||||
|
unsafety,
|
||||||
|
ref generics,
|
||||||
|
ref type_param_bounds,
|
||||||
|
ref trait_items,
|
||||||
|
) = item.node
|
||||||
{
|
{
|
||||||
let mut result = String::with_capacity(128);
|
let mut result = String::with_capacity(128);
|
||||||
let header = format!(
|
let header = format!(
|
||||||
"{}{}trait ",
|
"{}{}{}trait ",
|
||||||
|
format_auto(is_auto),
|
||||||
format_visibility(&item.vis),
|
format_visibility(&item.vis),
|
||||||
format_unsafety(unsafety),
|
format_unsafety(unsafety),
|
||||||
);
|
);
|
||||||
|
|
||||||
result.push_str(&header);
|
result.push_str(&header);
|
||||||
|
|
||||||
let body_lo = context.snippet_provider.span_after(item.span, "{");
|
let body_lo = context.snippet_provider.span_after(item.span, "{");
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,14 @@ pub fn format_unsafety(unsafety: ast::Unsafety) -> &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn format_auto(is_auto: ast::IsAuto) -> &'static str {
|
||||||
|
match is_auto {
|
||||||
|
ast::IsAuto::Yes => "auto ",
|
||||||
|
ast::IsAuto::No => "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn format_mutability(mutability: ast::Mutability) -> &'static str {
|
pub fn format_mutability(mutability: ast::Mutability) -> &'static str {
|
||||||
match mutability {
|
match mutability {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue