Skip to content

Commit

Permalink
Fix lints (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored Dec 4, 2024
1 parent a0a3bbb commit e7a2511
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 187 deletions.
320 changes: 162 additions & 158 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
msrv = "1.70.0"
msrv = "1.83.0"

disallowed-types = [
{ path = "std::sync::Mutex", reason = "Use the faster & simpler non-poisonable primitives in `parking_lot` instead" },
Expand Down
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ deny = [
]
skip = [
{ crate = "[email protected]", reason = "gix uses this old version" },
{ crate = "[email protected]", reason = "reqwest -> system-configuration uses this old version" },
]
skip-tree = [
{ crate = "[email protected]", reason = "a foundational crate for many that bumps far too frequently to ever have a shared version" },
Expand All @@ -53,7 +54,6 @@ allow = [
exceptions = [
# Use exceptions for these as they only have a single user
{ allow = ["Zlib"], crate = "tinyvec" },
{ allow = ["Unicode-DFS-2016"], crate = "unicode-ident" },
{ allow = ["OpenSSL"], crate = "ring" },
]

Expand Down
2 changes: 1 addition & 1 deletion src/advisories/diags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn get_notes_from_advisory(advisory: &Metadata) -> Vec<String> {
n
}

impl<'a> crate::CheckCtx<'a, super::cfg::ValidConfig> {
impl crate::CheckCtx<'_, super::cfg::ValidConfig> {
pub(crate) fn diag_for_advisory<F>(
&self,
krate: &crate::Krate,
Expand Down
2 changes: 1 addition & 1 deletion src/bans/diags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ pub(crate) struct HomePath<'a> {
pub(crate) home: Option<&'a crate::Path>,
}

impl<'a> fmt::Display for HomePath<'a> {
impl fmt::Display for HomePath<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(rel_path) = self.home.and_then(|home| self.path.strip_prefix(home).ok()) {
f.write_str("$CARGO_HOME/")?;
Expand Down
6 changes: 3 additions & 3 deletions src/bans/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ impl<'a, 'b: 'a> From<&'b Krate> for Node<'a> {
}
}

impl<'a> fmt::Debug for Node<'a> {
impl fmt::Debug for Node<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}({})", self.name, self.version)
}
}

impl<'a> fmt::Display for Node<'a> {
impl fmt::Display for Node<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}({})", self.name, self.version)
}
Expand Down Expand Up @@ -60,7 +60,7 @@ struct NodeAttributes<'a> {
fill_color: Option<&'static str>,
}

impl<'a> NodeAttributes<'a> {
impl NodeAttributes<'_> {
fn has_attrs(&self) -> bool {
self.label.is_some()
|| self.shape.is_some()
Expand Down
8 changes: 4 additions & 4 deletions src/cargo-deny/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ enum OutputFormat<'a> {
}

impl<'a> OutputFormat<'a> {
fn lock(&'a self, max_severity: Severity) -> OutputLock<'a, '_> {
fn lock(&'a self, max_severity: Severity) -> OutputLock<'a, 'a> {
match self {
Self::Human(human) => OutputLock::Human(
human,
Expand All @@ -366,7 +366,7 @@ pub enum StdLock<'a> {
//Out(std::io::StdoutLock<'a>),
}

impl<'a> Write for StdLock<'a> {
impl Write for StdLock<'_> {
fn write(&mut self, d: &[u8]) -> std::io::Result<usize> {
match self {
Self::Err(stderr) => stderr.write(d),
Expand All @@ -392,7 +392,7 @@ pub enum OutputLock<'a, 'b> {
Json(&'a Json<'a>, Severity, StdLock<'b>),
}

impl<'a, 'b> OutputLock<'a, 'b> {
impl OutputLock<'_, '_> {
pub fn print(&mut self, diag: CsDiag, files: &Files) {
match self {
Self::Human(cfg, max, l, _) => {
Expand Down Expand Up @@ -525,7 +525,7 @@ impl<'a> DiagPrinter<'a> {
}

#[inline]
pub fn lock(&'a self) -> OutputLock<'a, '_> {
pub fn lock(&'a self) -> OutputLock<'a, 'a> {
self.which.lock(self.max_severity)
}
}
4 changes: 2 additions & 2 deletions src/cargo-deny/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn cmd(
#[derive(Ord, PartialOrd, PartialEq, Eq)]
struct SerKid<'k>(Cow<'k, Kid>);

impl<'k> serde::Serialize for SerKid<'k> {
impl serde::Serialize for SerKid<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -92,7 +92,7 @@ pub fn cmd(
}
}

impl<'k> SerKid<'k> {
impl SerKid<'_> {
fn parts(&self) -> (&str, &str) {
(self.0.name(), self.0.version())
}
Expand Down
2 changes: 1 addition & 1 deletion src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct ValidationContext<'ctx> {
pub diagnostics: &'ctx mut Vec<diag::Diagnostic>,
}

impl<'ctx> ValidationContext<'ctx> {
impl ValidationContext<'_> {
#[inline]
pub fn push(&mut self, diag: diag::Diagnostic) {
self.diagnostics.push(diag);
Expand Down
2 changes: 1 addition & 1 deletion src/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<'f> codespan_reporting::files::Files<'f> for Files {
let start = *file
.line_starts
.get(line_index)
.ok_or_else(|| FilesErr::LineTooLarge {
.ok_or(FilesErr::LineTooLarge {
given: line_index,
max: file.line_starts.len(),
})?;
Expand Down
3 changes: 1 addition & 2 deletions src/diag/krate_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,11 @@ fn read_workspace_deps<'k>(
name,
) {
Ok(url) => url::Url::parse(url.as_str())
.map_err(|err| {
.inspect_err(|err| {
log::warn!(
"unable to parse url '{}' for registry '{name}': {err}",
url.as_str()
);
err
})
.ok(),
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion src/licenses/gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ pub struct Summary<'a> {
pub nfos: Vec<KrateLicense<'a>>,
}

impl<'a> Summary<'a> {
impl Summary<'_> {
fn new(store: Arc<LicenseStore>) -> Self {
Self {
store,
Expand Down
17 changes: 6 additions & 11 deletions tests/licenses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ use cargo_deny::{
licenses::{self, cfg::Config},
test_utils as tu, Krates,
};
use parking_lot::Once;
use std::sync::Arc;
use std::sync::{Arc, OnceLock};

static mut STORE: Option<Arc<licenses::LicenseStore>> = None;
static INIT: Once = Once::new();
static STORE: OnceLock<Arc<licenses::LicenseStore>> = OnceLock::new();

#[inline]
fn store() -> Arc<licenses::LicenseStore> {
#[allow(unsafe_code)]
unsafe {
INIT.call_once(|| {
STORE = Some(Arc::new(licenses::LicenseStore::from_cache().unwrap()));
});
STORE.as_ref().unwrap().clone()
}
STORE
.get_or_init(|| Arc::new(licenses::LicenseStore::from_cache().unwrap()))
.clone()
}

fn setup<'k>(
Expand Down

0 comments on commit e7a2511

Please sign in to comment.