Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr authored and calebcartwright committed Dec 14, 2021
1 parent f40b1d9 commit 740fb57
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/bin/main.rs
Expand Up @@ -26,7 +26,7 @@ fn main() {
let exit_code = match execute(&opts) {
Ok(code) => code,
Err(e) => {
eprintln!("{}", e.to_string());
eprintln!("{}", e);
1
}
};
Expand Down
4 changes: 1 addition & 3 deletions src/expr.rs
Expand Up @@ -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 =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/formatting.rs
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions src/items.rs
Expand Up @@ -1535,15 +1535,15 @@ 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)
}
(Item(_) | AssocTraitItem(_) | ForeignItem(_), None) => {
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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
)
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 1 addition & 3 deletions src/lists.rs
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions src/visitor.rs
Expand Up @@ -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,
Expand All @@ -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());
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 740fb57

Please sign in to comment.