Skip to content

Commit 7d0edcf

Browse files
Clippy fixes (#1163)
1 parent b646ce5 commit 7d0edcf

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ disallowed-methods = [
22
{ path = "std::env::var_os", reason = "Please use Build::getenv" },
33
{ path = "std::env::var", reason = "Please use Build::getenv" },
44
]
5+
doc-valid-idents = ["AppleClang", "OpenBSD", ".."]

src/command_helpers.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub(crate) struct CargoOutput {
2929
/// Different strategies for handling compiler output (to stdout)
3030
#[derive(Clone, Debug)]
3131
pub(crate) enum OutputKind {
32-
/// Forward the output to this process' stdout (Stdio::inherit)
32+
/// Forward the output to this process' stdout ([`Stdio::inherit()`])
3333
Forward,
34-
/// Discard the output (Stdio::null)
34+
/// Discard the output ([`Stdio::null()`])
3535
Discard,
36-
/// Capture the result
36+
/// Capture the result (`[Stdio::piped()`])
3737
Capture,
3838
}
3939

src/lib.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
#![deny(warnings)]
211211
#![deny(missing_docs)]
212212
#![deny(clippy::disallowed_methods)]
213+
#![warn(clippy::doc_markdown)]
213214

214215
use std::borrow::Cow;
215216
use std::collections::HashMap;
@@ -1277,7 +1278,8 @@ impl Build {
12771278

12781279
/// Run the compiler, generating the file `output`
12791280
///
1280-
/// This will return a result instead of panicking; see compile() for the complete description.
1281+
/// This will return a result instead of panicking; see [`Self::compile()`] for
1282+
/// the complete description.
12811283
pub fn try_compile(&self, output: &str) -> Result<(), Error> {
12821284
let mut output_components = Path::new(output).components();
12831285
match (output_components.next(), output_components.next()) {
@@ -1716,7 +1718,8 @@ impl Build {
17161718
Ok((cmd, name))
17171719
}
17181720

1719-
/// This will return a result instead of panicking; see expand() for the complete description.
1721+
/// This will return a result instead of panicking; see [`Self::expand()`] for
1722+
/// the complete description.
17201723
pub fn try_expand(&self) -> Result<Vec<u8>, Error> {
17211724
let compiler = self.try_get_compiler()?;
17221725
let mut cmd = compiler.to_command();
@@ -2470,14 +2473,14 @@ impl Build {
24702473
cmd.arg("-PreDefine");
24712474
if let Some(ref value) = *value {
24722475
if let Ok(i) = value.parse::<i32>() {
2473-
cmd.arg(&format!("{} SETA {}", key, i));
2476+
cmd.arg(format!("{} SETA {}", key, i));
24742477
} else if value.starts_with('"') && value.ends_with('"') {
2475-
cmd.arg(&format!("{} SETS {}", key, value));
2478+
cmd.arg(format!("{} SETS {}", key, value));
24762479
} else {
2477-
cmd.arg(&format!("{} SETS \"{}\"", key, value));
2480+
cmd.arg(format!("{} SETS \"{}\"", key, value));
24782481
}
24792482
} else {
2480-
cmd.arg(&format!("{} SETL {}", key, "{TRUE}"));
2483+
cmd.arg(format!("{} SETL {}", key, "{TRUE}"));
24812484
}
24822485
}
24832486
} else {
@@ -2487,9 +2490,9 @@ impl Build {
24872490

24882491
for (key, value) in self.definitions.iter() {
24892492
if let Some(ref value) = *value {
2490-
cmd.arg(&format!("-D{}={}", key, value));
2493+
cmd.arg(format!("-D{}={}", key, value));
24912494
} else {
2492-
cmd.arg(&format!("-D{}", key));
2495+
cmd.arg(format!("-D{}", key));
24932496
}
24942497
}
24952498
}
@@ -4016,7 +4019,7 @@ impl Build {
40164019
// clang driver appears to be forcing UTF-8 output even on Windows,
40174020
// hence from_utf8 is assumed to be usable in all cases.
40184021
let search_dirs = std::str::from_utf8(&search_dirs).ok()?;
4019-
for dirs in search_dirs.split(|c| c == '\r' || c == '\n') {
4022+
for dirs in search_dirs.split(['\r', '\n']) {
40204023
if let Some(path) = dirs.strip_prefix("programs: =") {
40214024
return self.which(prog, Some(OsStr::new(path)));
40224025
}

0 commit comments

Comments
 (0)