Skip to content

Commit 3d34588

Browse files
Fix 2024 edition (1.85.0) lints
1 parent be5fca7 commit 3d34588

File tree

7 files changed

+36
-28
lines changed

7 files changed

+36
-28
lines changed

crates/cxx-qt-build/src/qml_modules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ where
3535
pub qrc_files: &'a [A],
3636
}
3737

38-
impl<'a, A, B> Default for QmlModule<'a, A, B>
38+
impl<A, B> Default for QmlModule<'_, A, B>
3939
where
4040
A: AsRef<Path>,
4141
B: AsRef<Path>,

crates/cxx-qt-lib/src/core/qhash/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ where
111111

112112
/// An iterator visiting all key-value pairs in arbitrary order.
113113
/// The iterator element type is (&'a T::Key, &'a T::Value).
114-
pub fn iter(&self) -> Iter<T> {
114+
pub fn iter(&self) -> Iter<'_, T> {
115115
Iter {
116116
hash: self,
117117
index: 0,
@@ -197,7 +197,7 @@ where
197197
}
198198
}
199199

200-
impl<'a, T> ExactSizeIterator for Iter<'a, T>
200+
impl<T> ExactSizeIterator for Iter<'_, T>
201201
where
202202
T: QHashPair,
203203
{

crates/cxx-qt-lib/src/core/qlist/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ where
139139

140140
/// An iterator visiting all elements in arbitrary order.
141141
/// The iterator element type is &'a T.
142-
pub fn iter(&self) -> Iter<T> {
142+
pub fn iter(&self) -> Iter<'_, T> {
143143
Iter {
144144
list: self,
145145
index: 0,
@@ -249,7 +249,7 @@ where
249249
}
250250
}
251251

252-
impl<'a, T> ExactSizeIterator for Iter<'a, T>
252+
impl<T> ExactSizeIterator for Iter<'_, T>
253253
where
254254
T: QListElement,
255255
{

crates/cxx-qt-lib/src/core/qmap/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ where
120120

121121
/// An iterator visiting all key-value pairs in an arbitrary order.
122122
/// The iterator element type is (&T::Key, &T::Value).
123-
pub fn iter(&self) -> Iter<T> {
123+
pub fn iter(&self) -> Iter<'_, T> {
124124
Iter {
125125
map: self,
126126
index: 0,
@@ -193,7 +193,7 @@ where
193193
}
194194
}
195195

196-
impl<'a, T> ExactSizeIterator for Iter<'a, T>
196+
impl<T> ExactSizeIterator for Iter<'_, T>
197197
where
198198
T: QMapPair,
199199
{

crates/cxx-qt-lib/src/core/qset/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ where
104104

105105
/// An iterator visiting all elements in arbitrary order.
106106
/// The iterator element type is &'a T.
107-
pub fn iter(&self) -> Iter<T> {
107+
pub fn iter(&self) -> Iter<'_, T> {
108108
Iter {
109109
set: self,
110110
index: 0,
@@ -172,7 +172,7 @@ where
172172
}
173173
}
174174

175-
impl<'a, T> ExactSizeIterator for Iter<'a, T>
175+
impl<T> ExactSizeIterator for Iter<'_, T>
176176
where
177177
T: QSetElement,
178178
{

crates/cxx-qt-lib/src/core/qvector/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ where
139139

140140
/// An iterator visiting all elements in arbitrary order.
141141
/// The iterator element type is &'a T.
142-
pub fn iter(&self) -> Iter<T> {
142+
pub fn iter(&self) -> Iter<'_, T> {
143143
Iter {
144144
vector: self,
145145
index: 0,
@@ -249,7 +249,7 @@ where
249249
}
250250
}
251251

252-
impl<'a, T> ExactSizeIterator for Iter<'a, T>
252+
impl<T> ExactSizeIterator for Iter<'_, T>
253253
where
254254
T: QVectorElement,
255255
{

crates/qt-build-utils/src/parse_cflags.rs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
use std::env;
1212

1313
#[cfg(feature = "link_qt_object_files")]
14-
use std::{collections::HashSet, sync::OnceLock};
14+
use std::{
15+
collections::HashSet,
16+
sync::{OnceLock, RwLock},
17+
};
1518

1619
#[cfg(feature = "link_qt_object_files")]
17-
static mut LINKED_OBJECT_FILES: OnceLock<HashSet<String>> = OnceLock::new();
20+
static LINKED_OBJECT_FILES: OnceLock<RwLock<HashSet<String>>> = OnceLock::new();
1821

1922
/// Extract the &str to pass to cargo::rustc-link-lib from a filename (just the file name, not including directories)
2023
/// using target-specific logic.
@@ -187,21 +190,26 @@ pub(crate) fn parse_libs_cflags(name: &str, link_args: &[u8], _builder: &mut cc:
187190
#[cfg(feature = "link_qt_object_files")]
188191
{
189192
let path_string = path.to_string_lossy().to_string();
190-
unsafe {
191-
// Linking will fail with duplicate symbol errors if the same .o file is linked twice.
192-
// Many of Qt's .prl files repeat listing .o files that other .prl files also list.
193-
let already_linked_object_files =
194-
LINKED_OBJECT_FILES.get_or_init(HashSet::new);
195-
if !already_linked_object_files.contains(&path_string) {
196-
// Cargo doesn't have a means to directly specify an object to link,
197-
// so use the cc crate to specify it instead.
198-
// TODO: pass file path directly when link-arg library type is stabilized
199-
// https://github.com/rust-lang/rust/issues/99427#issuecomment-1562092085
200-
// TODO: remove builder argument when it's not used anymore to link object files.
201-
// also remove the dependency on cc when this is done
202-
_builder.object(path);
203-
}
204-
LINKED_OBJECT_FILES.get_mut().unwrap().insert(path_string);
193+
// Linking will fail with duplicate symbol errors if the same .o file is linked twice.
194+
// Many of Qt's .prl files repeat listing .o files that other .prl files also list.
195+
let already_linked_object_files =
196+
LINKED_OBJECT_FILES.get_or_init(|| RwLock::new(HashSet::new()));
197+
if !already_linked_object_files
198+
.read()
199+
.expect("Lock poisoned")
200+
.contains(&path_string)
201+
{
202+
// Cargo doesn't have a means to directly specify an object to link,
203+
// so use the cc crate to specify it instead.
204+
// TODO: pass file path directly when link-arg library type is stabilized
205+
// https://github.com/rust-lang/rust/issues/99427#issuecomment-1562092085
206+
// TODO: remove builder argument when it's not used anymore to link object files.
207+
// also remove the dependency on cc when this is done
208+
_builder.object(path);
209+
already_linked_object_files
210+
.write()
211+
.expect("Lock poisoned!")
212+
.insert(path_string.clone());
205213
}
206214
}
207215
} else {

0 commit comments

Comments
 (0)