From 8a671168576b9b552a22be285646fc293a80d8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 12:38:21 +0100 Subject: use strip_prefix() instead of starts_with and slicing (clippy::manual_strip) --- xtask/src/codegen/gen_assists_docs.rs | 4 ++-- xtask/src/codegen/gen_parser_tests.rs | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 158680993..c91716409 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs @@ -154,8 +154,8 @@ fn hide_hash_comments(text: &str) -> String { fn reveal_hash_comments(text: &str) -> String { text.split('\n') // want final newline .map(|it| { - if it.starts_with("# ") { - &it[2..] + if let Some(stripped) = it.strip_prefix("# ") { + stripped } else if it == "#" { "" } else { diff --git a/xtask/src/codegen/gen_parser_tests.rs b/xtask/src/codegen/gen_parser_tests.rs index 096590653..2fecb9b5b 100644 --- a/xtask/src/codegen/gen_parser_tests.rs +++ b/xtask/src/codegen/gen_parser_tests.rs @@ -60,12 +60,10 @@ fn collect_tests(s: &str) -> Vec { let mut res = Vec::new(); for comment_block in extract_comment_blocks(s) { let first_line = &comment_block[0]; - let (name, ok) = if first_line.starts_with("test ") { - let name = first_line["test ".len()..].to_string(); - (name, true) - } else if first_line.starts_with("test_err ") { - let name = first_line["test_err ".len()..].to_string(); - (name, false) + let (name, ok) = if let Some(name) = first_line.strip_prefix("test ") { + (name.to_string(), true) + } else if let Some(name) = first_line.strip_prefix("test_err ") { + (name.to_string(), false) } else { continue; }; -- cgit v1.2.3 From bd407a9882250cbbb0897faba08e7d5ef80a4862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 12:49:40 +0100 Subject: xtask: remove redundant lifetime (clippy::extra_unused_lifetimes) --- xtask/src/metrics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xtask/src') diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs index 97395738b..b0b76b8aa 100644 --- a/xtask/src/metrics.rs +++ b/xtask/src/metrics.rs @@ -167,7 +167,7 @@ impl Host { return Ok(Host { os, cpu, mem }); - fn read_field<'a>(path: &str, field: &str) -> Result { + fn read_field(path: &str, field: &str) -> Result { let text = read_file(path)?; let line = text -- cgit v1.2.3 From 202b51bc7b6999900e06ec2cfb8d72fe9aa4af29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 15:33:18 +0100 Subject: a lot of clippy::style fixes --- xtask/src/codegen/gen_syntax.rs | 2 +- xtask/src/main.rs | 2 +- xtask/src/tidy.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 80f26e8f5..ba4b24848 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -707,7 +707,7 @@ fn extract_struct_trait(node: &mut AstNodeSrc, trait_name: &str, methods: &[&str let mut to_remove = Vec::new(); for (i, field) in node.fields.iter().enumerate() { let method_name = field.method_name().to_string(); - if methods.iter().any(|&it| it == &method_name) { + if methods.iter().any(|&it| it == method_name) { to_remove.push(i); } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 915aae71a..960927fc0 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -37,7 +37,7 @@ fn main() -> Result<()> { match flags.subcommand { flags::XtaskCmd::Help(_) => { println!("{}", flags::Xtask::HELP); - return Ok(()); + Ok(()) } flags::XtaskCmd::Install(cmd) => cmd.run(), flags::XtaskCmd::FuzzTests(_) => run_fuzzer(), diff --git a/xtask/src/tidy.rs b/xtask/src/tidy.rs index 1352d1218..50d9efccd 100644 --- a/xtask/src/tidy.rs +++ b/xtask/src/tidy.rs @@ -193,7 +193,7 @@ https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/#redo-after- } } -fn deny_clippy(path: &PathBuf, text: &String) { +fn deny_clippy(path: &Path, text: &str) { let ignore = &[ // The documentation in string literals may contain anything for its own purposes "ide_completion/src/generated_lint_completions.rs", -- cgit v1.2.3