Skip to content

Commit e7a2511

Browse files
authored
Fix lints (#733)
1 parent a0a3bbb commit e7a2511

File tree

13 files changed

+185
-187
lines changed

13 files changed

+185
-187
lines changed

Cargo.lock

+162-158
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
msrv = "1.70.0"
1+
msrv = "1.83.0"
22

33
disallowed-types = [
44
{ path = "std::sync::Mutex", reason = "Use the faster & simpler non-poisonable primitives in `parking_lot` instead" },

deny.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ deny = [
2828
]
2929
skip = [
3030
{ crate = "[email protected]", reason = "gix uses this old version" },
31+
{ crate = "[email protected]", reason = "reqwest -> system-configuration uses this old version" },
3132
]
3233
skip-tree = [
3334
{ crate = "[email protected]", reason = "a foundational crate for many that bumps far too frequently to ever have a shared version" },
@@ -53,7 +54,6 @@ allow = [
5354
exceptions = [
5455
# Use exceptions for these as they only have a single user
5556
{ allow = ["Zlib"], crate = "tinyvec" },
56-
{ allow = ["Unicode-DFS-2016"], crate = "unicode-ident" },
5757
{ allow = ["OpenSSL"], crate = "ring" },
5858
]
5959

src/advisories/diags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn get_notes_from_advisory(advisory: &Metadata) -> Vec<String> {
6666
n
6767
}
6868

69-
impl<'a> crate::CheckCtx<'a, super::cfg::ValidConfig> {
69+
impl crate::CheckCtx<'_, super::cfg::ValidConfig> {
7070
pub(crate) fn diag_for_advisory<F>(
7171
&self,
7272
krate: &crate::Krate,

src/bans/diags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub(crate) struct HomePath<'a> {
541541
pub(crate) home: Option<&'a crate::Path>,
542542
}
543543

544-
impl<'a> fmt::Display for HomePath<'a> {
544+
impl fmt::Display for HomePath<'_> {
545545
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
546546
if let Some(rel_path) = self.home.and_then(|home| self.path.strip_prefix(home).ok()) {
547547
f.write_str("$CARGO_HOME/")?;

src/bans/graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ impl<'a, 'b: 'a> From<&'b Krate> for Node<'a> {
2424
}
2525
}
2626

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

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

63-
impl<'a> NodeAttributes<'a> {
63+
impl NodeAttributes<'_> {
6464
fn has_attrs(&self) -> bool {
6565
self.label.is_some()
6666
|| self.shape.is_some()

src/cargo-deny/common.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ enum OutputFormat<'a> {
348348
}
349349

350350
impl<'a> OutputFormat<'a> {
351-
fn lock(&'a self, max_severity: Severity) -> OutputLock<'a, '_> {
351+
fn lock(&'a self, max_severity: Severity) -> OutputLock<'a, 'a> {
352352
match self {
353353
Self::Human(human) => OutputLock::Human(
354354
human,
@@ -366,7 +366,7 @@ pub enum StdLock<'a> {
366366
//Out(std::io::StdoutLock<'a>),
367367
}
368368

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

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

527527
#[inline]
528-
pub fn lock(&'a self) -> OutputLock<'a, '_> {
528+
pub fn lock(&'a self) -> OutputLock<'a, 'a> {
529529
self.which.lock(self.max_severity)
530530
}
531531
}

src/cargo-deny/list.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn cmd(
7878
#[derive(Ord, PartialOrd, PartialEq, Eq)]
7979
struct SerKid<'k>(Cow<'k, Kid>);
8080

81-
impl<'k> serde::Serialize for SerKid<'k> {
81+
impl serde::Serialize for SerKid<'_> {
8282
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
8383
where
8484
S: serde::Serializer,
@@ -92,7 +92,7 @@ pub fn cmd(
9292
}
9393
}
9494

95-
impl<'k> SerKid<'k> {
95+
impl SerKid<'_> {
9696
fn parts(&self) -> (&str, &str) {
9797
(self.0.name(), self.0.version())
9898
}

src/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct ValidationContext<'ctx> {
1010
pub diagnostics: &'ctx mut Vec<diag::Diagnostic>,
1111
}
1212

13-
impl<'ctx> ValidationContext<'ctx> {
13+
impl ValidationContext<'_> {
1414
#[inline]
1515
pub fn push(&mut self, diag: diag::Diagnostic) {
1616
self.diagnostics.push(diag);

src/diag.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'f> codespan_reporting::files::Files<'f> for Files {
161161
let start = *file
162162
.line_starts
163163
.get(line_index)
164-
.ok_or_else(|| FilesErr::LineTooLarge {
164+
.ok_or(FilesErr::LineTooLarge {
165165
given: line_index,
166166
max: file.line_starts.len(),
167167
})?;

src/diag/krate_spans.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,11 @@ fn read_workspace_deps<'k>(
637637
name,
638638
) {
639639
Ok(url) => url::Url::parse(url.as_str())
640-
.map_err(|err| {
640+
.inspect_err(|err| {
641641
log::warn!(
642642
"unable to parse url '{}' for registry '{name}': {err}",
643643
url.as_str()
644644
);
645-
err
646645
})
647646
.ok(),
648647
Err(err) => {

src/licenses/gather.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ pub struct Summary<'a> {
393393
pub nfos: Vec<KrateLicense<'a>>,
394394
}
395395

396-
impl<'a> Summary<'a> {
396+
impl Summary<'_> {
397397
fn new(store: Arc<LicenseStore>) -> Self {
398398
Self {
399399
store,

tests/licenses.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ use cargo_deny::{
33
licenses::{self, cfg::Config},
44
test_utils as tu, Krates,
55
};
6-
use parking_lot::Once;
7-
use std::sync::Arc;
6+
use std::sync::{Arc, OnceLock};
87

9-
static mut STORE: Option<Arc<licenses::LicenseStore>> = None;
10-
static INIT: Once = Once::new();
8+
static STORE: OnceLock<Arc<licenses::LicenseStore>> = OnceLock::new();
119

10+
#[inline]
1211
fn store() -> Arc<licenses::LicenseStore> {
13-
#[allow(unsafe_code)]
14-
unsafe {
15-
INIT.call_once(|| {
16-
STORE = Some(Arc::new(licenses::LicenseStore::from_cache().unwrap()));
17-
});
18-
STORE.as_ref().unwrap().clone()
19-
}
12+
STORE
13+
.get_or_init(|| Arc::new(licenses::LicenseStore::from_cache().unwrap()))
14+
.clone()
2015
}
2116

2217
fn setup<'k>(

0 commit comments

Comments
 (0)