clippy fixes
This commit is contained in:
parent
f40b1d9f1a
commit
740fb57f5d
@ -26,7 +26,7 @@ fn main() {
|
||||
let exit_code = match execute(&opts) {
|
||||
Ok(code) => code,
|
||||
Err(e) => {
|
||||
eprintln!("{}", e.to_string());
|
||||
eprintln!("{}", e);
|
||||
1
|
||||
}
|
||||
};
|
||||
|
@ -2003,9 +2003,7 @@ fn choose_rhs<R: Rewrite>(
|
||||
has_rhs_comment: bool,
|
||||
) -> Option<String> {
|
||||
match orig_rhs {
|
||||
Some(ref new_str) if new_str.is_empty() => {
|
||||
return Some(String::new());
|
||||
}
|
||||
Some(ref new_str) if new_str.is_empty() => Some(String::new()),
|
||||
Some(ref new_str)
|
||||
if !new_str.contains('\n') && unicode_str_width(new_str) <= shape.width =>
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ fn should_skip_module<T: FormatHandler>(
|
||||
return true;
|
||||
}
|
||||
|
||||
if !input_is_stdin && context.ignore_file(&path) {
|
||||
if !input_is_stdin && context.ignore_file(path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
10
src/items.rs
10
src/items.rs
@ -1535,7 +1535,7 @@ pub(crate) fn rewrite_type_alias<'a, 'b>(
|
||||
// https://rustc-dev-guide.rust-lang.org/opaque-types-type-alias-impl-trait.html
|
||||
// https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/items.md#type-aliases
|
||||
match (visitor_kind, &op_ty) {
|
||||
(Item(_) | AssocTraitItem(_) | ForeignItem(_), Some(ref op_bounds)) => {
|
||||
(Item(_) | AssocTraitItem(_) | ForeignItem(_), Some(op_bounds)) => {
|
||||
let op = OpaqueType { bounds: op_bounds };
|
||||
rewrite_ty(rw_info, Some(bounds), Some(&op), vis)
|
||||
}
|
||||
@ -1543,7 +1543,7 @@ pub(crate) fn rewrite_type_alias<'a, 'b>(
|
||||
rewrite_ty(rw_info, Some(bounds), ty_opt, vis)
|
||||
}
|
||||
(AssocImplItem(_), _) => {
|
||||
let result = if let Some(ref op_bounds) = op_ty {
|
||||
let result = if let Some(op_bounds) = op_ty {
|
||||
let op = OpaqueType { bounds: op_bounds };
|
||||
rewrite_ty(rw_info, Some(bounds), Some(&op), &DEFAULT_VISIBILITY)
|
||||
} else {
|
||||
@ -3124,7 +3124,7 @@ impl Rewrite for ast::ForeignItem {
|
||||
let inner_attrs = inner_attributes(&self.attrs);
|
||||
let fn_ctxt = visit::FnCtxt::Foreign;
|
||||
visitor.visit_fn(
|
||||
visit::FnKind::Fn(fn_ctxt, self.ident, &sig, &self.vis, Some(body)),
|
||||
visit::FnKind::Fn(fn_ctxt, self.ident, sig, &self.vis, Some(body)),
|
||||
generics,
|
||||
&sig.decl,
|
||||
self.span,
|
||||
@ -3137,7 +3137,7 @@ impl Rewrite for ast::ForeignItem {
|
||||
context,
|
||||
shape.indent,
|
||||
self.ident,
|
||||
&FnSig::from_method_sig(&sig, generics, &self.vis),
|
||||
&FnSig::from_method_sig(sig, generics, &self.vis),
|
||||
span,
|
||||
FnBraceStyle::None,
|
||||
)
|
||||
@ -3166,7 +3166,7 @@ impl Rewrite for ast::ForeignItem {
|
||||
.map(|s| s + ";")
|
||||
}
|
||||
ast::ForeignItemKind::TyAlias(ref ty_alias) => {
|
||||
let (kind, span) = (&ItemVisitorKind::ForeignItem(&self), self.span);
|
||||
let (kind, span) = (&ItemVisitorKind::ForeignItem(self), self.span);
|
||||
rewrite_type_alias(ty_alias, context, shape.indent, kind, span)
|
||||
}
|
||||
ast::ForeignItemKind::MacCall(ref mac) => {
|
||||
|
@ -448,10 +448,8 @@ where
|
||||
true
|
||||
} else if starts_with_newline(comment) {
|
||||
false
|
||||
} else if comment.trim().contains('\n') || comment.trim().len() > width {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
comment.trim().contains('\n') || comment.trim().len() > width
|
||||
};
|
||||
|
||||
rewrite_comment(
|
||||
|
@ -552,7 +552,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
_ => visit::FnCtxt::Foreign,
|
||||
};
|
||||
self.visit_fn(
|
||||
visit::FnKind::Fn(fn_ctxt, item.ident, &sig, &item.vis, Some(body)),
|
||||
visit::FnKind::Fn(fn_ctxt, item.ident, sig, &item.vis, Some(body)),
|
||||
generics,
|
||||
&sig.decl,
|
||||
item.span,
|
||||
@ -562,14 +562,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
} else {
|
||||
let indent = self.block_indent;
|
||||
let rewrite = self.rewrite_required_fn(
|
||||
indent, item.ident, &sig, &item.vis, generics, item.span,
|
||||
indent, item.ident, sig, &item.vis, generics, item.span,
|
||||
);
|
||||
self.push_rewrite(item.span, rewrite);
|
||||
}
|
||||
}
|
||||
ast::ItemKind::TyAlias(ref ty_alias) => {
|
||||
use ItemVisitorKind::Item;
|
||||
self.visit_ty_alias_kind(ty_alias, &Item(&item), item.span);
|
||||
self.visit_ty_alias_kind(ty_alias, &Item(item), item.span);
|
||||
}
|
||||
ast::ItemKind::GlobalAsm(..) => {
|
||||
let snippet = Some(self.snippet(item.span).to_owned());
|
||||
@ -619,17 +619,17 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
skip_out_of_file_lines_range_visitor!(self, ai.span);
|
||||
|
||||
if self.visit_attrs(&ai.attrs, ast::AttrStyle::Outer) {
|
||||
self.push_skipped_with_span(&ai.attrs.as_slice(), skip_span, skip_span);
|
||||
self.push_skipped_with_span(ai.attrs.as_slice(), skip_span, skip_span);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(calebcartwright): consider enabling box_patterns feature gate
|
||||
match (&ai.kind, visitor_kind) {
|
||||
(ast::AssocItemKind::Const(..), AssocTraitItem(_)) => {
|
||||
self.visit_static(&StaticParts::from_trait_item(&ai))
|
||||
self.visit_static(&StaticParts::from_trait_item(ai))
|
||||
}
|
||||
(ast::AssocItemKind::Const(..), AssocImplItem(_)) => {
|
||||
self.visit_static(&StaticParts::from_impl_item(&ai))
|
||||
self.visit_static(&StaticParts::from_impl_item(ai))
|
||||
}
|
||||
(ast::AssocItemKind::Fn(ref fn_kind), _) => {
|
||||
let ast::Fn {
|
||||
|
Loading…
x
Reference in New Issue
Block a user