Skip to content

Commit 740fb57

Browse files
matthiaskrgrcalebcartwright
authored andcommitted
clippy fixes
1 parent f40b1d9 commit 740fb57

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

Diff for: src/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() {
2626
let exit_code = match execute(&opts) {
2727
Ok(code) => code,
2828
Err(e) => {
29-
eprintln!("{}", e.to_string());
29+
eprintln!("{}", e);
3030
1
3131
}
3232
};

Diff for: src/expr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2003,9 +2003,7 @@ fn choose_rhs<R: Rewrite>(
20032003
has_rhs_comment: bool,
20042004
) -> Option<String> {
20052005
match orig_rhs {
2006-
Some(ref new_str) if new_str.is_empty() => {
2007-
return Some(String::new());
2008-
}
2006+
Some(ref new_str) if new_str.is_empty() => Some(String::new()),
20092007
Some(ref new_str)
20102008
if !new_str.contains('\n') && unicode_str_width(new_str) <= shape.width =>
20112009
{

Diff for: src/formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn should_skip_module<T: FormatHandler>(
7676
return true;
7777
}
7878

79-
if !input_is_stdin && context.ignore_file(&path) {
79+
if !input_is_stdin && context.ignore_file(path) {
8080
return true;
8181
}
8282

Diff for: src/items.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,15 @@ pub(crate) fn rewrite_type_alias<'a, 'b>(
15351535
// https://rustc-dev-guide.rust-lang.org/opaque-types-type-alias-impl-trait.html
15361536
// https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/items.md#type-aliases
15371537
match (visitor_kind, &op_ty) {
1538-
(Item(_) | AssocTraitItem(_) | ForeignItem(_), Some(ref op_bounds)) => {
1538+
(Item(_) | AssocTraitItem(_) | ForeignItem(_), Some(op_bounds)) => {
15391539
let op = OpaqueType { bounds: op_bounds };
15401540
rewrite_ty(rw_info, Some(bounds), Some(&op), vis)
15411541
}
15421542
(Item(_) | AssocTraitItem(_) | ForeignItem(_), None) => {
15431543
rewrite_ty(rw_info, Some(bounds), ty_opt, vis)
15441544
}
15451545
(AssocImplItem(_), _) => {
1546-
let result = if let Some(ref op_bounds) = op_ty {
1546+
let result = if let Some(op_bounds) = op_ty {
15471547
let op = OpaqueType { bounds: op_bounds };
15481548
rewrite_ty(rw_info, Some(bounds), Some(&op), &DEFAULT_VISIBILITY)
15491549
} else {
@@ -3124,7 +3124,7 @@ impl Rewrite for ast::ForeignItem {
31243124
let inner_attrs = inner_attributes(&self.attrs);
31253125
let fn_ctxt = visit::FnCtxt::Foreign;
31263126
visitor.visit_fn(
3127-
visit::FnKind::Fn(fn_ctxt, self.ident, &sig, &self.vis, Some(body)),
3127+
visit::FnKind::Fn(fn_ctxt, self.ident, sig, &self.vis, Some(body)),
31283128
generics,
31293129
&sig.decl,
31303130
self.span,
@@ -3137,7 +3137,7 @@ impl Rewrite for ast::ForeignItem {
31373137
context,
31383138
shape.indent,
31393139
self.ident,
3140-
&FnSig::from_method_sig(&sig, generics, &self.vis),
3140+
&FnSig::from_method_sig(sig, generics, &self.vis),
31413141
span,
31423142
FnBraceStyle::None,
31433143
)
@@ -3166,7 +3166,7 @@ impl Rewrite for ast::ForeignItem {
31663166
.map(|s| s + ";")
31673167
}
31683168
ast::ForeignItemKind::TyAlias(ref ty_alias) => {
3169-
let (kind, span) = (&ItemVisitorKind::ForeignItem(&self), self.span);
3169+
let (kind, span) = (&ItemVisitorKind::ForeignItem(self), self.span);
31703170
rewrite_type_alias(ty_alias, context, shape.indent, kind, span)
31713171
}
31723172
ast::ForeignItemKind::MacCall(ref mac) => {

Diff for: src/lists.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,8 @@ where
448448
true
449449
} else if starts_with_newline(comment) {
450450
false
451-
} else if comment.trim().contains('\n') || comment.trim().len() > width {
452-
true
453451
} else {
454-
false
452+
comment.trim().contains('\n') || comment.trim().len() > width
455453
};
456454

457455
rewrite_comment(

Diff for: src/visitor.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
552552
_ => visit::FnCtxt::Foreign,
553553
};
554554
self.visit_fn(
555-
visit::FnKind::Fn(fn_ctxt, item.ident, &sig, &item.vis, Some(body)),
555+
visit::FnKind::Fn(fn_ctxt, item.ident, sig, &item.vis, Some(body)),
556556
generics,
557557
&sig.decl,
558558
item.span,
@@ -562,14 +562,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
562562
} else {
563563
let indent = self.block_indent;
564564
let rewrite = self.rewrite_required_fn(
565-
indent, item.ident, &sig, &item.vis, generics, item.span,
565+
indent, item.ident, sig, &item.vis, generics, item.span,
566566
);
567567
self.push_rewrite(item.span, rewrite);
568568
}
569569
}
570570
ast::ItemKind::TyAlias(ref ty_alias) => {
571571
use ItemVisitorKind::Item;
572-
self.visit_ty_alias_kind(ty_alias, &Item(&item), item.span);
572+
self.visit_ty_alias_kind(ty_alias, &Item(item), item.span);
573573
}
574574
ast::ItemKind::GlobalAsm(..) => {
575575
let snippet = Some(self.snippet(item.span).to_owned());
@@ -619,17 +619,17 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
619619
skip_out_of_file_lines_range_visitor!(self, ai.span);
620620

621621
if self.visit_attrs(&ai.attrs, ast::AttrStyle::Outer) {
622-
self.push_skipped_with_span(&ai.attrs.as_slice(), skip_span, skip_span);
622+
self.push_skipped_with_span(ai.attrs.as_slice(), skip_span, skip_span);
623623
return;
624624
}
625625

626626
// TODO(calebcartwright): consider enabling box_patterns feature gate
627627
match (&ai.kind, visitor_kind) {
628628
(ast::AssocItemKind::Const(..), AssocTraitItem(_)) => {
629-
self.visit_static(&StaticParts::from_trait_item(&ai))
629+
self.visit_static(&StaticParts::from_trait_item(ai))
630630
}
631631
(ast::AssocItemKind::Const(..), AssocImplItem(_)) => {
632-
self.visit_static(&StaticParts::from_impl_item(&ai))
632+
self.visit_static(&StaticParts::from_impl_item(ai))
633633
}
634634
(ast::AssocItemKind::Fn(ref fn_kind), _) => {
635635
let ast::Fn {

0 commit comments

Comments
 (0)