Skip to content

Commit 730e11c

Browse files
committed
fix clippy nags in files I changed
1 parent ab5b3ab commit 730e11c

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/book/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl MDBook {
346346

347347
// rustdoc edition from cargo manifest takes precedence over book.toml
348348
// bugbug but also takes precedence over command line flag -- that seems rude.
349-
if extern_args.edition != "" {
349+
if !extern_args.edition.is_empty() {
350350
cmd.args(["--edition", &extern_args.edition]);
351351
} else if let Some(edition) = self.config.rust.edition {
352352
match edition {

src/utils/extern_args.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl ExternArgs {
6565

6666
/// Run a `cargo build` to see what args Cargo is using for library paths and extern crates.
6767
/// Touch a source file in the crate to ensure something is compiled and the args will be visible.
68-
6968
pub fn load(&mut self, cargo_path: &Path) -> Result<&Self> {
7069
// find Cargo.toml and determine the package name and lib or bin source file.
7170
let proj_root = cargo_path
@@ -77,7 +76,7 @@ impl ExternArgs {
7776
.parent()
7877
.ok_or(anyhow!("can't find parent of {:?}", cargo_path))?
7978
.to_owned();
80-
let mut manifest = Manifest::from_path(&cargo_path).context(format!(
79+
let mut manifest = Manifest::from_path(cargo_path).context(format!(
8180
"can't open cargo manifest {}",
8281
&cargo_path.to_string_lossy()
8382
))?;
@@ -107,7 +106,7 @@ impl ExternArgs {
107106
let try_path: PathBuf = proj_root.join("src").join(fname);
108107
if try_path.exists() {
109108
touch(&try_path)?;
110-
self.run_cargo(&proj_root, &cargo_path)?;
109+
self.run_cargo(&proj_root, cargo_path)?;
111110
return Ok(self);
112111
// file should be closed when f goes out of scope at bottom of this loop
113112
}
@@ -117,7 +116,7 @@ impl ExternArgs {
117116

118117
fn run_cargo(&mut self, proj_root: &Path, manifest_path: &Path) -> Result<&Self> {
119118
let mut cmd = Command::new("cargo");
120-
cmd.current_dir(&proj_root)
119+
cmd.current_dir(proj_root)
121120
.arg("build")
122121
.arg("--verbose")
123122
.arg("--manifest-path")
@@ -138,7 +137,7 @@ impl ExternArgs {
138137
//ultimatedebug std::fs::write(proj_root.join("mdbook_cargo_out.txt"), &output.stderr)?;
139138

140139
let cmd_resp: &str = std::str::from_utf8(&output.stderr)?;
141-
self.parse_response(&self.crate_name.clone(), &cmd_resp)?;
140+
self.parse_response(self.crate_name.clone().as_str(), cmd_resp)?;
142141

143142
Ok(self)
144143
}
@@ -148,7 +147,7 @@ impl ExternArgs {
148147
/// The response may contain multiple builds, scan for the one that corresponds to the doctest crate.
149148
///
150149
/// > This parser is broken, doesn't handle arg values with embedded spaces (single quoted).
151-
/// Fortunately, the args we care about (so far) don't have those kinds of values.
150+
/// > Fortunately, the args we care about (so far) don't have those kinds of values.
152151
pub fn parse_response(&mut self, my_crate: &str, buf: &str) -> Result<()> {
153152
let mut builds_ignored = 0;
154153

@@ -200,7 +199,7 @@ impl ExternArgs {
200199
};
201200
}
202201

203-
if self.extern_list.len() == 0 || self.lib_list.len() == 0 {
202+
if self.extern_list.is_empty() || self.lib_list.is_empty() {
204203
bail!("Couldn't extract -L or --extern args from Cargo, is current directory == cargo project root?");
205204
}
206205

@@ -227,6 +226,12 @@ impl ExternArgs {
227226
}
228227
}
229228

229+
impl Default for ExternArgs {
230+
fn default() -> Self {
231+
Self::new()
232+
}
233+
}
234+
230235
fn my_display_edition(edition: Edition) -> String {
231236
match edition {
232237
Edition::E2015 => "2015",

0 commit comments

Comments
 (0)