Apply Clippy
This commit is contained in:
parent
7483c2a8f9
commit
2b11d84119
@ -168,7 +168,7 @@ fn is_block_expr(expr: &ast::Expr, repr: &str) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn pop_expr_chain<'a>(expr: &'a ast::Expr) -> Option<&'a ast::Expr> {
|
||||
fn pop_expr_chain(expr: &ast::Expr) -> Option<&ast::Expr> {
|
||||
match expr.node {
|
||||
ast::Expr_::ExprMethodCall(_, _, ref expressions) => Some(&expressions[0]),
|
||||
ast::Expr_::ExprTupField(ref subexpr, _) |
|
||||
|
@ -1008,7 +1008,7 @@ fn rewrite_guard(context: &RewriteContext,
|
||||
// the arm (excludes offset).
|
||||
pattern_width: usize)
|
||||
-> Option<String> {
|
||||
if let &Some(ref guard) = guard {
|
||||
if let Some(ref guard) = *guard {
|
||||
// First try to fit the guard string on the same line as the pattern.
|
||||
// 4 = ` if `, 5 = ` => {`
|
||||
let overhead = pattern_width + 4 + 5;
|
||||
|
@ -465,7 +465,7 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) -
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
result.push_str("!");
|
||||
}
|
||||
if let &Some(ref trait_ref) = trait_ref {
|
||||
if let Some(ref trait_ref) = *trait_ref {
|
||||
let budget = try_opt!(context.config.max_width.checked_sub(result.len()));
|
||||
let indent = offset + result.len();
|
||||
result.push_str(&*try_opt!(trait_ref.rewrite(context, budget, indent)));
|
||||
@ -496,7 +496,7 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) -
|
||||
BraceStyle::AlwaysNextLine => result.push('\n'),
|
||||
BraceStyle::PreferSameLine => result.push(' '),
|
||||
BraceStyle::SameLineWhere => {
|
||||
if where_clause_str.len() > 0 {
|
||||
if !where_clause_str.is_empty() {
|
||||
result.push('\n')
|
||||
} else {
|
||||
result.push(' ')
|
||||
@ -720,7 +720,7 @@ fn format_tuple_struct(context: &RewriteContext,
|
||||
result.push_str(&body);
|
||||
result.push(')');
|
||||
|
||||
if where_clause_str.len() > 0 && !where_clause_str.contains('\n') &&
|
||||
if !where_clause_str.is_empty() && !where_clause_str.contains('\n') &&
|
||||
(result.contains('\n') ||
|
||||
context.block_indent.width() + result.len() + where_clause_str.len() + 1 >
|
||||
context.config.max_width) {
|
||||
@ -1052,7 +1052,7 @@ fn rewrite_fn_base(context: &RewriteContext,
|
||||
let indent = match context.config.fn_return_indent {
|
||||
ReturnIndent::WithWhereClause => indent + 4,
|
||||
// Aligning with non-existent args looks silly.
|
||||
_ if arg_str.len() == 0 => {
|
||||
_ if arg_str.is_empty() => {
|
||||
force_new_line_for_brace = true;
|
||||
indent + 4
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ pub fn format_string(input: String, config: &Config, mode: WriteMode) -> FileMap
|
||||
visitor.buffer.push_str("\n");
|
||||
file_map.insert(path.to_owned(), visitor.buffer);
|
||||
|
||||
return file_map;
|
||||
file_map
|
||||
}
|
||||
|
||||
pub fn format(file: &Path, config: &Config, mode: WriteMode) -> FileMap {
|
||||
@ -427,7 +427,7 @@ pub fn format(file: &Path, config: &Config, mode: WriteMode) -> FileMap {
|
||||
// newlines so we must add one on for each file. This is sad.
|
||||
filemap::append_newlines(&mut file_map);
|
||||
|
||||
return file_map;
|
||||
file_map
|
||||
}
|
||||
|
||||
// args are the arguments passed on the command line, generally passed through
|
||||
|
@ -191,7 +191,7 @@ pub fn definitive_tactic<'t, I, T>(items: I,
|
||||
|
||||
// Format a list of commented items into a string.
|
||||
// TODO: add unit tests
|
||||
pub fn write_list<'b, I, T>(items: I, formatting: &ListFormatting<'b>) -> Option<String>
|
||||
pub fn write_list<I, T>(items: I, formatting: &ListFormatting) -> Option<String>
|
||||
where I: IntoIterator<Item = T>,
|
||||
T: AsRef<ListItem>
|
||||
{
|
||||
|
@ -94,9 +94,10 @@ fn write_snippet_inner<F>(&mut self,
|
||||
fn replace_chars(string: &str) -> String {
|
||||
string.chars()
|
||||
.map(|ch| {
|
||||
match ch.is_whitespace() {
|
||||
true => ch,
|
||||
false => 'X',
|
||||
if ch.is_whitespace() {
|
||||
ch
|
||||
} else {
|
||||
'X'
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
@ -415,7 +415,7 @@ pub fn visit_attrs(&mut self, attrs: &[ast::Attribute]) -> bool {
|
||||
|
||||
let outers: Vec<_> = attrs.iter()
|
||||
.filter(|a| a.node.style == ast::AttrStyle::Outer)
|
||||
.map(|a| a.clone())
|
||||
.cloned()
|
||||
.collect();
|
||||
if outers.is_empty() {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user