Skip to content

Commit

Permalink
Merge pull request #263 from dtolnay/clippy
Browse files Browse the repository at this point in the history
Resolve new clippy lints from Rust 1.57 through 1.70
  • Loading branch information
dtolnay committed Mar 30, 2024
2 parents c74de40 + 348f552 commit 3eb5c5a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 32 deletions.
14 changes: 4 additions & 10 deletions src/env.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
use crate::error::{Error, Result};
use std::env;

#[derive(PartialEq, Debug)]
#[derive(PartialEq, Default, Debug)]
pub(crate) enum Update {
#[default]
Wip,
Overwrite,
}

impl Default for Update {
fn default() -> Self {
Update::Wip
}
}

impl Update {
pub fn env() -> Result<Self> {
let var = match env::var_os("TRYBUILD") {
Some(var) => var,
None => return Ok(Update::default()),
let Some(var) = env::var_os("TRYBUILD") else {
return Ok(Update::default());
};

match var.as_os_str().to_str() {
Expand Down
5 changes: 2 additions & 3 deletions src/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ fn create(path: &Path) -> Option<File> {
},
};

let modified = match metadata.modified() {
Ok(modified) => modified,
Err(_) => return None,
let Ok(modified) = metadata.modified() else {
return None;
};

let now = SystemTime::now();
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref,
clippy::uninhabited_references,
clippy::uninlined_format_args,
clippy::unused_self,
clippy::while_let_on_iterator,
)]
Expand Down
9 changes: 2 additions & 7 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ pub(crate) struct Package {
pub publish: bool,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub(crate) enum Edition {
#[default]
#[serde(rename = "2015")]
E2015,
#[serde(rename = "2018")]
Expand Down Expand Up @@ -75,12 +76,6 @@ pub(crate) struct Workspace {
pub dependencies: Map<String, Dependency>,
}

impl Default for Edition {
fn default() -> Self {
Edition::E2015
}
}

impl AsRef<OsStr> for Name {
fn as_ref(&self) -> &OsStr {
self.0.as_ref()
Expand Down
5 changes: 2 additions & 3 deletions src/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,8 @@ fn unindent(diag: String, normalization: Normalization) -> String {
}

let mut ahead = lines.clone();
let next_line = match ahead.next() {
Some(line) => line,
None => continue,
let Some(next_line) = ahead.next() else {
continue;
};

if let IndentedLineKind::Code(indent) = indented_line_kind(next_line, normalization) {
Expand Down
15 changes: 6 additions & 9 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ impl Runner {
let mut features = source_manifest.features;
for (feature, enables) in &mut features {
enables.retain(|en| {
let dep_name = match en.strip_prefix("dep:") {
Some(dep_name) => dep_name,
None => return false,
let Some(dep_name) = en.strip_prefix("dep:") else {
return false;
};
if let Some(Dependency { optional: true, .. }) = dependencies.get(dep_name) {
return true;
Expand Down Expand Up @@ -622,9 +621,8 @@ fn parse_cargo_json(
let mut remaining = &*String::from_utf8_lossy(stdout);
let mut seen = Set::new();
while !remaining.is_empty() {
let begin = match remaining.find("{\"reason\":") {
Some(begin) => begin,
None => break,
let Some(begin) = remaining.find("{\"reason\":") else {
break;
};
let (nonmessage, rest) = remaining.split_at(begin);
nonmessage_stdout.push_str(nonmessage);
Expand All @@ -643,9 +641,8 @@ fn parse_cargo_json(
}
if let Ok(de) = serde_json::from_str::<CargoMessage>(message) {
if de.message.level != "failure-note" {
let (name, test) = match path_map.get(&de.target.src_path) {
Some(test) => test,
None => continue,
let Some((name, test)) = path_map.get(&de.target.src_path) else {
continue;
};
let entry = map
.entry(de.target.src_path)
Expand Down

0 comments on commit 3eb5c5a

Please sign in to comment.