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 spanned::Spanned;
|
||||
use types::TraitTyParamBounds;
|
||||
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_constness,
|
||||
format_defaultness, format_mutability, format_unsafety, format_visibility,
|
||||
is_attributes_extendable, last_line_contains_single_line_comment,
|
||||
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_auto,
|
||||
format_constness, format_defaultness, format_mutability, format_unsafety,
|
||||
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,
|
||||
stmt_expr, trimmed_last_line_width};
|
||||
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> {
|
||||
if let ast::ItemKind::Trait(_, unsafety, ref generics, ref type_param_bounds, ref trait_items) =
|
||||
item.node
|
||||
if let ast::ItemKind::Trait(
|
||||
is_auto,
|
||||
unsafety,
|
||||
ref generics,
|
||||
ref type_param_bounds,
|
||||
ref trait_items,
|
||||
) = item.node
|
||||
{
|
||||
let mut result = String::with_capacity(128);
|
||||
let header = format!(
|
||||
"{}{}trait ",
|
||||
"{}{}{}trait ",
|
||||
format_auto(is_auto),
|
||||
format_visibility(&item.vis),
|
||||
format_unsafety(unsafety),
|
||||
);
|
||||
|
||||
result.push_str(&header);
|
||||
|
||||
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]
|
||||
pub fn format_mutability(mutability: ast::Mutability) -> &'static str {
|
||||
match mutability {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue