From 8531d70c77efcfc659b08ecc68d49793ea7de089 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Fri, 23 Feb 2018 09:07:35 +0900 Subject: [PATCH] Cargo clippy --- rustfmt-core/src/expr.rs | 6 +++--- rustfmt-core/src/lib.rs | 4 ++-- rustfmt-core/src/macros.rs | 2 +- rustfmt-core/tests/lib.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rustfmt-core/src/expr.rs b/rustfmt-core/src/expr.rs index 1ed85619235..9c5682cc635 100644 --- a/rustfmt-core/src/expr.rs +++ b/rustfmt-core/src/expr.rs @@ -1066,7 +1066,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { debug!("ControlFlow::rewrite {:?} {:?}", self, shape); let alt_block_sep = &shape.indent.to_string_with_newline(context.config); - let (cond_str, used_width) = self.rewrite_cond(context, shape, &alt_block_sep)?; + let (cond_str, used_width) = self.rewrite_cond(context, shape, alt_block_sep)?; // If `used_width` is 0, it indicates that whole control flow is written in a single line. if used_width == 0 { return Some(cond_str); @@ -1273,10 +1273,10 @@ fn rewrite_match( let cond_str = cond.rewrite(context, cond_shape)?; let alt_block_sep = &shape.indent.to_string_with_newline(context.config); let block_sep = match context.config.control_brace_style() { - ControlBraceStyle::AlwaysNextLine => &alt_block_sep, + ControlBraceStyle::AlwaysNextLine => alt_block_sep, _ if last_line_extendable(&cond_str) => " ", // 2 = ` {` - _ if cond_str.contains('\n') || cond_str.len() + 2 > cond_shape.width => &alt_block_sep, + _ if cond_str.contains('\n') || cond_str.len() + 2 > cond_shape.width => alt_block_sep, _ => " ", }; diff --git a/rustfmt-core/src/lib.rs b/rustfmt-core/src/lib.rs index b095d06abb8..5697d6cab2d 100644 --- a/rustfmt-core/src/lib.rs +++ b/rustfmt-core/src/lib.rs @@ -78,7 +78,7 @@ mod vertical; pub mod visitor; -const STDIN: &'static str = ""; +const STDIN: &str = ""; // A map of the files of a crate, with their new content pub type FileMap = Vec; @@ -753,7 +753,7 @@ pub struct ModifiedLines { pub chunks: Vec, } -/// The successful result of formatting via get_modified_lines(). +/// The successful result of formatting via `get_modified_lines()`. pub struct ModifiedLinesResult { /// The high level summary details pub summary: Summary, diff --git a/rustfmt-core/src/macros.rs b/rustfmt-core/src/macros.rs index 1d40efb9b3a..8228450b510 100644 --- a/rustfmt-core/src/macros.rs +++ b/rustfmt-core/src/macros.rs @@ -299,7 +299,7 @@ pub fn rewrite_macro_def( span: Span, ) -> Option { let snippet = Some(remove_trailing_white_spaces(context.snippet(span))); - if snippet.as_ref().map_or(true, |s| s.ends_with(";")) { + if snippet.as_ref().map_or(true, |s| s.ends_with(';')) { return snippet; } diff --git a/rustfmt-core/tests/lib.rs b/rustfmt-core/tests/lib.rs index f0aad73507d..f219cf3212b 100644 --- a/rustfmt-core/tests/lib.rs +++ b/rustfmt-core/tests/lib.rs @@ -706,7 +706,7 @@ fn code_block_valid(&self) -> bool { let fmt_skip = self.code_block .as_ref() .unwrap() - .split("\n") + .split('\n') .nth(0) .unwrap_or("") == "#![rustfmt_skip]"; -- 2.44.0