Skip to content
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

Clippy fixes #1163

Merged
merged 3 commits into from
Jul 19, 2024
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
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ disallowed-methods = [
{ path = "std::env::var_os", reason = "Please use Build::getenv" },
{ path = "std::env::var", reason = "Please use Build::getenv" },
]
doc-valid-idents = ["AppleClang", "OpenBSD", ".."]
6 changes: 3 additions & 3 deletions src/command_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ pub(crate) struct CargoOutput {
/// Different strategies for handling compiler output (to stdout)
#[derive(Clone, Debug)]
pub(crate) enum OutputKind {
/// Forward the output to this process' stdout (Stdio::inherit)
/// Forward the output to this process' stdout ([`Stdio::inherit()`])
Forward,
/// Discard the output (Stdio::null)
/// Discard the output ([`Stdio::null()`])
Discard,
/// Capture the result
/// Capture the result (`[Stdio::piped()`])
Capture,
}

Expand Down
21 changes: 12 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
#![deny(warnings)]
#![deny(missing_docs)]
#![deny(clippy::disallowed_methods)]
#![warn(clippy::doc_markdown)]

use std::borrow::Cow;
use std::collections::HashMap;
Expand Down Expand Up @@ -1277,7 +1278,8 @@ impl Build {

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

/// This will return a result instead of panicking; see expand() for the complete description.
/// This will return a result instead of panicking; see [`Self::expand()`] for
/// the complete description.
pub fn try_expand(&self) -> Result<Vec<u8>, Error> {
let compiler = self.try_get_compiler()?;
let mut cmd = compiler.to_command();
Expand Down Expand Up @@ -2470,14 +2473,14 @@ impl Build {
cmd.arg("-PreDefine");
if let Some(ref value) = *value {
if let Ok(i) = value.parse::<i32>() {
cmd.arg(&format!("{} SETA {}", key, i));
cmd.arg(format!("{} SETA {}", key, i));
} else if value.starts_with('"') && value.ends_with('"') {
cmd.arg(&format!("{} SETS {}", key, value));
cmd.arg(format!("{} SETS {}", key, value));
} else {
cmd.arg(&format!("{} SETS \"{}\"", key, value));
cmd.arg(format!("{} SETS \"{}\"", key, value));
}
} else {
cmd.arg(&format!("{} SETL {}", key, "{TRUE}"));
cmd.arg(format!("{} SETL {}", key, "{TRUE}"));
}
}
} else {
Expand All @@ -2487,9 +2490,9 @@ impl Build {

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