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

chore(ci): Check for clippy correctness #14796

Merged
merged 4 commits into from
Nov 12, 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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ rust_2018_idioms = "warn" # TODO: could this be removed?
private_intra_doc_links = "allow"

[workspace.lints.clippy]
all = { level = "allow", priority = -1 }
all = { level = "allow", priority = -2 }
correctness = { level = "warn", priority = -1 }
Comment on lines +124 to +125
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ehuss wanted to check in with you on this change as I believe you were one of the people concerned about clippy's defaults. correctness seems to have a higher bar than the warn by defaults, so I feel like this would be acceptable and much easier to maintain than trying to copy in all of the "relevant" correctness lints.

dbg_macro = "warn"
disallowed_methods = "warn"
print_stderr = "warn"
Expand Down
21 changes: 21 additions & 0 deletions crates/cargo-util-schemas/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,13 @@ impl<'de> de::Deserialize<'de> for InheritableString {
Ok(InheritableString::Value(value))
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_string(value.to_owned())
}

fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
where
V: de::MapAccess<'de>,
Expand Down Expand Up @@ -454,6 +461,13 @@ impl<'de> de::Deserialize<'de> for InheritableRustVersion {
Ok(InheritableRustVersion::Value(value))
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_string(value.to_owned())
}

fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
where
V: de::MapAccess<'de>,
Expand Down Expand Up @@ -533,6 +547,13 @@ impl<'de> de::Deserialize<'de> for InheritableStringOrBool {
StringOrBool::deserialize(string).map(InheritableField::Value)
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_string(value.to_owned())
}

fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
where
V: de::MapAccess<'de>,
Expand Down
1 change: 1 addition & 0 deletions crates/rustfix/src/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ mod tests {
}

#[test]
#[allow(clippy::reversed_empty_ranges)]
fn replace_invalid_range() {
let mut d = Data::new(b"foo!");

Expand Down
1 change: 0 additions & 1 deletion src/cargo/core/resolver/dep_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ impl<'a> RegistryQueryer<'a> {
}
}

let first_version = first_version;
self.version_prefs.sort_summaries(&mut ret, first_version);

let out = Poll::Ready(Rc::new(ret));
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ mod test {
);
assert_eq!(human_readable_bytes(1024 * 1024 * 1024), (1., "GiB"));
assert_eq!(
human_readable_bytes((1024. * 1024. * 1024. * 3.1415) as u64),
(3.1415, "GiB")
human_readable_bytes((1024. * 1024. * 1024. * 1.2345) as u64),
(1.2345, "GiB")
);
assert_eq!(human_readable_bytes(1024 * 1024 * 1024 * 1024), (1., "TiB"));
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn normalize_toml(

normalized_toml.badges = original_toml.badges.clone();
} else {
for field in original_toml.requires_package() {
if let Some(field) = original_toml.requires_package().next() {
bail!("this virtual manifest specifies a `{field}` section, which is not allowed");
}
}
Expand Down