Skip to content

Fixed crate_universe clippy defects #1228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions crate_universe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ filegroup(
visibility = ["//:__subpackages__"],
)

TAGS = [
# https://github.com/rust-lang/rust-clippy/issues/8470
"noclippy",
]

rust_library(
name = "cargo_bazel",
srcs = glob(
Expand All @@ -72,7 +67,6 @@ rust_library(
exclude = ["src/**/*.rs"],
),
proc_macro_deps = all_crate_deps(proc_macro = True),
tags = TAGS,
version = VERSION,
visibility = ["//visibility:public"],
deps = all_crate_deps(normal = True),
Expand All @@ -81,7 +75,6 @@ rust_library(
rust_binary(
name = "cargo_bazel_bin",
srcs = ["src/main.rs"],
tags = TAGS,
version = VERSION,
visibility = ["//visibility:public"],
deps = [":cargo_bazel"],
Expand All @@ -108,7 +101,6 @@ rust_test(
"CARGO": "$(rootpath @rules_rust//rust/toolchain:current_exec_cargo_files)",
"RUSTC": "$(rootpath @rules_rust//rust/toolchain:current_exec_rustc_files)",
},
tags = TAGS,
deps = [
"@rules_rust//tools/runfiles",
] + all_crate_deps(
Expand Down
9 changes: 4 additions & 5 deletions crate_universe/src/context/crate_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,10 @@ impl CrateContext {
let crate_name = sanitize_module_name(&target.name);

// Locate the crate's root source file relative to the package root normalized for unix
let crate_root =
pathdiff::diff_paths(target.src_path.to_string(), package_root).map(
// Normalize the path so that it always renders the same regardless of platform
|root| root.to_string_lossy().replace("\\", "/"),
);
let crate_root = pathdiff::diff_paths(&target.src_path, package_root).map(
// Normalize the path so that it always renders the same regardless of platform
|root| root.to_string_lossy().replace('\\', "/"),
);

// Conditionally check to see if the dependencies is a build-script target
if include_build_scripts && kind == "custom-build" {
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/src/splicing/splicer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'a> SplicerKind<'a> {
!manifests.keys().any(|path| {
let path_str = path.to_string_lossy().to_string();
// Account for windows paths.
let path_str = path_str.replace("\\", "/");
let path_str = path_str.replace('\\', "/");
// Workspace members are represented as directories.
path_str.trim_end_matches("/Cargo.toml").ends_with(member)
})
Expand Down Expand Up @@ -1015,7 +1015,7 @@ mod test {
// On windows, make sure we normalize the path to match what Cargo would
// otherwise use to populate metadata.
if cfg!(target_os = "windows") {
workspace_root = format!("/{}", workspace_root.replace("\\", "/"))
workspace_root = format!("/{}", workspace_root.replace('\\', "/"))
};

if is_root {
Expand Down