From 7c6362a19c9c80c25cbefd910427f3b99b0d6f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 22 Aug 2020 02:01:02 +0200 Subject: [PATCH 1/5] expand-yaml-anchors: fix clippy::match_ref_pats and clippy::redundant_closure --- src/tools/expand-yaml-anchors/src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tools/expand-yaml-anchors/src/main.rs b/src/tools/expand-yaml-anchors/src/main.rs index d8dad8fc789e9..f7ff64036a1a9 100644 --- a/src/tools/expand-yaml-anchors/src/main.rs +++ b/src/tools/expand-yaml-anchors/src/main.rs @@ -48,8 +48,8 @@ impl App { // Parse CLI arguments let args = std::env::args().skip(1).collect::>(); let (mode, base) = match args.iter().map(|s| s.as_str()).collect::>().as_slice() { - &["generate", ref base] => (Mode::Generate, PathBuf::from(base)), - &["check", ref base] => (Mode::Check, PathBuf::from(base)), + ["generate", ref base] => (Mode::Generate, PathBuf::from(base)), + ["check", ref base] => (Mode::Check, PathBuf::from(base)), _ => { eprintln!("usage: expand-yaml-anchors "); std::process::exit(1); @@ -138,9 +138,7 @@ fn filter_document(document: Yaml) -> Yaml { .map(|(key, value)| (filter_document(key), filter_document(value))) .collect(), ), - Yaml::Array(vec) => { - Yaml::Array(vec.into_iter().map(|item| filter_document(item)).collect()) - } + Yaml::Array(vec) => Yaml::Array(vec.into_iter().map(filter_document).collect()), other => other, } } From d97c4703eb427be4209bc2bd4845fa6abafa3eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 22 Aug 2020 02:09:20 +0200 Subject: [PATCH 2/5] linkcheckr: fix clippy::redundant_static_lifetimes and clippy::single_char_pattern --- src/tools/linkchecker/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 194318d7a59b5..b7ceba1e28262 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -172,10 +172,10 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti { return; } - let mut parts = url.splitn(2, "#"); + let mut parts = url.splitn(2, '#'); let url = parts.next().unwrap(); let fragment = parts.next(); - let mut parts = url.splitn(2, "?"); + let mut parts = url.splitn(2, '?'); let url = parts.next().unwrap(); // Once we've plucked out the URL, parse it using our base url and @@ -258,7 +258,7 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti } // These appear to be broken in mdbook right now? - if fragment.starts_with("-") { + if fragment.starts_with('-') { return; } @@ -324,7 +324,7 @@ fn load_file( } fn maybe_redirect(source: &str) -> Option { - const REDIRECT: &'static str = "

Redirecting to Redirecting to (contents: &str, attr: &str, }; let quote_delim = rest.as_bytes()[pos_quote] as char; - if rest[..pos_quote].trim_start_matches(" ") != "" { + if rest[..pos_quote].trim_start_matches(' ') != "" { continue; } let rest = &rest[pos_quote + 1..]; From ebac0e4727769dbb9da1f2ecfe353438defa8b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 24 Aug 2020 00:14:04 +0200 Subject: [PATCH 3/5] tidy: remove redundant variable from check_if_error_code_is_test_in_explanation --- src/tools/tidy/src/error_codes_check.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 2fa0f12d7e8dc..8d015e916ebdc 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -47,9 +47,7 @@ fn check_error_code_explanation( invalid_compile_fail_format } -fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &String) -> bool { - let mut can_be_ignored = false; - +fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool { for line in f.lines() { let s = line.trim(); if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { @@ -60,11 +58,11 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &String) -> boo return true; } else if s.contains("(") { // It's very likely that we can't actually make it fail compilation... - can_be_ignored = true; + return true; } } } - can_be_ignored + false } macro_rules! some_or_continue { From ba6b4274b57ae38420e4bee951f29455204967e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 24 Aug 2020 00:43:50 +0200 Subject: [PATCH 4/5] unicode_table_generator: fix clippy::writeln_empty_string, clippy::useless_format, clippy:::for_kv_map --- src/tools/unicode-table-generator/src/main.rs | 2 +- src/tools/unicode-table-generator/src/raw_emitter.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/unicode-table-generator/src/main.rs b/src/tools/unicode-table-generator/src/main.rs index d2d1807b3bb22..218e9668df4ae 100644 --- a/src/tools/unicode-table-generator/src/main.rs +++ b/src/tools/unicode-table-generator/src/main.rs @@ -315,7 +315,7 @@ fn version() -> String { fn fmt_list(values: impl IntoIterator) -> String { let pieces = values.into_iter().map(|b| format!("{:?}, ", b)).collect::>(); let mut out = String::new(); - let mut line = format!("\n "); + let mut line = String::from("\n "); for piece in pieces { if line.len() + piece.len() < 98 { line.push_str(&piece); diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs index 63cc29b670f6b..42e7e5fb40605 100644 --- a/src/tools/unicode-table-generator/src/raw_emitter.rs +++ b/src/tools/unicode-table-generator/src/raw_emitter.rs @@ -20,7 +20,7 @@ impl RawEmitter { if self.file.is_empty() || self.file.ends_with("\n\n") { return; } - writeln!(&mut self.file, "").unwrap(); + writeln!(&mut self.file).unwrap(); } fn emit_bitset(&mut self, ranges: &[Range]) { @@ -161,10 +161,10 @@ pub fn emit_codepoints(emitter: &mut RawEmitter, ranges: &[Range]) { if bitset.bytes_used <= skiplist.bytes_used { *emitter = bitset; - emitter.desc = format!("bitset"); + emitter.desc = String::from("bitset"); } else { *emitter = skiplist; - emitter.desc = format!("skiplist"); + emitter.desc = String::from("skiplist"); } } @@ -289,7 +289,7 @@ impl Canonicalized { // Remove the now-canonicalized word from other mappings, // to ensure that we deprioritize them in the next iteration of // the while loop. - for (_, mapped) in &mut mappings { + for mapped in mappings.values_mut() { let mut i = 0; while i != mapped.len() { if mapped[i].0 == *from { @@ -309,7 +309,7 @@ impl Canonicalized { // Remove the now-canonical word from other mappings, to ensure that // we deprioritize them in the next iteration of the while loop. - for (_, mapped) in &mut mappings { + for mapped in mappings.values_mut() { let mut i = 0; while i != mapped.len() { if mapped[i].0 == to { From a72500145b28a5aa584dab9d19565597aae72892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 24 Aug 2020 00:47:38 +0200 Subject: [PATCH 5/5] unstable-book-gen: fix clippy::single_char_pattern and clippy::iter_skip_next --- src/tools/tidy/src/error_codes_check.rs | 2 +- src/tools/unstable-book-gen/src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 8d015e916ebdc..82a5234ac5b24 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -56,7 +56,7 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool { if s.starts_with("```") { if s.contains("compile_fail") && s.contains(err_code) { return true; - } else if s.contains("(") { + } else if s.contains('(') { // It's very likely that we can't actually make it fail compilation... return true; } diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 11617911446ec..5d277e1c41f40 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -94,9 +94,9 @@ fn copy_recursive(from: &Path, to: &Path) { } fn main() { - let library_path_str = env::args_os().skip(1).next().expect("library path required"); - let src_path_str = env::args_os().skip(2).next().expect("source path required"); - let dest_path_str = env::args_os().skip(3).next().expect("destination path required"); + let library_path_str = env::args_os().nth(1).expect("library path required"); + let src_path_str = env::args_os().nth(2).expect("source path required"); + let dest_path_str = env::args_os().nth(3).expect("destination path required"); let library_path = Path::new(&library_path_str); let src_path = Path::new(&src_path_str); let dest_path = Path::new(&dest_path_str);