Skip to content

Commit 583e26c

Browse files
committed
clippy lints
1 parent 22998f0 commit 583e26c

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

src/bootstrap/src/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn main() {
9999
// HACK: Since the commit script uses hard links, we can't actually tell if it was installed by x.py setup or not.
100100
// We could see if it's identical to src/etc/pre-push.sh, but pre-push may have been modified in the meantime.
101101
// Instead, look for this comment, which is almost certainly not in any custom hook.
102-
if fs::read_to_string(pre_commit).map_or(false, |contents| {
102+
if fs::read_to_string(pre_commit).is_ok_and(|contents| {
103103
contents.contains("https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570")
104104
}) {
105105
println!(

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ impl Step for Sysroot {
16551655
let mut add_filtered_files = |suffix, contents| {
16561656
for path in contents {
16571657
let path = Path::new(&path);
1658-
if path.parent().map_or(false, |parent| parent.ends_with(suffix)) {
1658+
if path.parent().is_some_and(|parent| parent.ends_with(suffix)) {
16591659
filtered_files.push(path.file_name().unwrap().to_owned());
16601660
}
16611661
}

src/bootstrap/src/core/build_steps/format.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
5656
fn get_rustfmt_version(build: &Builder<'_>) -> Option<(String, PathBuf)> {
5757
let stamp_file = build.out.join("rustfmt.stamp");
5858

59-
let mut cmd = command(match build.initial_rustfmt() {
60-
Some(p) => p,
61-
None => return None,
62-
});
59+
let mut cmd = command(build.initial_rustfmt()?);
6360
cmd.arg("--version");
6461

6562
let output = cmd.allow_failure().run_capture(build);
@@ -279,7 +276,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
279276
Box::new(move |entry| {
280277
let cwd = std::env::current_dir();
281278
let entry = t!(entry);
282-
if entry.file_type().map_or(false, |t| t.is_file()) {
279+
if entry.file_type().is_some_and(|t| t.is_file()) {
283280
formatted_paths_ref.lock().unwrap().push({
284281
// `into_path` produces an absolute path. Try to strip `cwd` to get a shorter
285282
// relative path.

src/bootstrap/src/core/config/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,7 @@ impl Config {
16651665
}
16661666

16671667
config.llvm_assertions =
1668-
toml.llvm.as_ref().map_or(false, |llvm| llvm.assertions.unwrap_or(false));
1668+
toml.llvm.as_ref().is_some_and(|llvm| llvm.assertions.unwrap_or(false));
16691669

16701670
// Store off these values as options because if they're not provided
16711671
// we'll infer default values for them later

src/bootstrap/src/core/download.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ download-rustc = false
830830

831831
fn path_is_dylib(path: &Path) -> bool {
832832
// The .so is not necessarily the extension, it might be libLLVM.so.18.1
833-
path.to_str().map_or(false, |path| path.contains(".so"))
833+
path.to_str().is_some_and(|path| path.contains(".so"))
834834
}
835835

836836
/// Checks whether the CI rustc is available for the given target triple.

src/bootstrap/src/core/sanity.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,15 @@ pub fn check(build: &mut Build) {
135135

136136
// We need cmake, but only if we're actually building LLVM or sanitizers.
137137
let building_llvm = !build.config.llvm_from_ci
138-
&& build
139-
.hosts
140-
.iter()
141-
.map(|host| {
142-
build.config.llvm_enabled(*host)
143-
&& build
144-
.config
145-
.target_config
146-
.get(host)
147-
.map(|config| config.llvm_config.is_none())
148-
.unwrap_or(true)
149-
})
150-
.any(|build_llvm_ourselves| build_llvm_ourselves);
138+
&& build.hosts.iter().any(|host| {
139+
build.config.llvm_enabled(*host)
140+
&& build
141+
.config
142+
.target_config
143+
.get(host)
144+
.map(|config| config.llvm_config.is_none())
145+
.unwrap_or(true)
146+
});
151147

152148
let need_cmake = building_llvm || build.config.any_sanitizers_to_build();
153149
if need_cmake && cmd_finder.maybe_have("cmake").is_none() {

src/bootstrap/src/utils/helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn exe(name: &str, target: TargetSelection) -> String {
5555

5656
/// Returns `true` if the file name given looks like a dynamic library.
5757
pub fn is_dylib(path: &Path) -> bool {
58-
path.extension().and_then(|ext| ext.to_str()).map_or(false, |ext| {
58+
path.extension().and_then(|ext| ext.to_str()).is_some_and(|ext| {
5959
ext == "dylib" || ext == "so" || ext == "dll" || (ext == "a" && is_aix_shared_archive(path))
6060
})
6161
}

0 commit comments

Comments
 (0)