From d6cf2ec939c1eff9f6601588468146cf72c97e5b Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 18 May 2021 23:35:24 +0900 Subject: [PATCH] Fix clippy warnings for //tools/rust_analyzer:gen_rust_project (#746) * Fix clippy warnings for //tools/rust_analyzer:gen_rust_project * buildifier tools/rustfmt/BUILD.bazel --- tools/rust_analyzer/BUILD.bazel | 11 ++++++++++- tools/rust_analyzer/main.rs | 4 ++-- tools/rustfmt/BUILD.bazel | 11 ++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/rust_analyzer/BUILD.bazel b/tools/rust_analyzer/BUILD.bazel index 1bd2edde1c..403516ec51 100644 --- a/tools/rust_analyzer/BUILD.bazel +++ b/tools/rust_analyzer/BUILD.bazel @@ -1,4 +1,4 @@ -load("//rust:defs.bzl", "rust_binary") +load("//rust:defs.bzl", "rust_binary", "rust_clippy") rust_binary( name = "gen_rust_project", @@ -11,3 +11,12 @@ rust_binary( "//util/label", ], ) + +rust_clippy( + name = "gen_rust_project_clippy", + testonly = True, + visibility = ["//visibility:private"], + deps = [ + ":gen_rust_project", + ], +) diff --git a/tools/rust_analyzer/main.rs b/tools/rust_analyzer/main.rs index 7b53be75a3..9c798601fa 100644 --- a/tools/rust_analyzer/main.rs +++ b/tools/rust_analyzer/main.rs @@ -108,8 +108,8 @@ fn parse_config() -> anyhow::Result { let output = String::from_utf8_lossy(&output.stdout.as_slice()); let bazel_info = output .trim() - .split("\n") - .map(|line| line.split_at(line.find(":").expect("missing `:` in bazel info output"))) + .split('\n') + .map(|line| line.split_at(line.find(':').expect("missing `:` in bazel info output"))) .map(|(k, v)| (k, (&v[1..]).trim())) .collect::>(); diff --git a/tools/rustfmt/BUILD.bazel b/tools/rustfmt/BUILD.bazel index 2394456d11..40fa906acb 100644 --- a/tools/rustfmt/BUILD.bazel +++ b/tools/rustfmt/BUILD.bazel @@ -1,4 +1,4 @@ -load("//rust:defs.bzl", "rust_binary", "rust_library") +load("//rust:defs.bzl", "rust_binary", "rust_clippy", "rust_library") package(default_visibility = ["//visibility:public"]) @@ -58,3 +58,12 @@ rust_binary( "//tools/runfiles", ], ) + +rust_clippy( + name = "rustfmt_clippy", + testonly = True, + visibility = ["//visibility:private"], + deps = [ + ":rustfmt", + ], +)