Skip to content

Commit

Permalink
Fix 2024 edition (1.85.0) lints
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFordTytherington authored Feb 21, 2025
1 parent be5fca7 commit 3d34588
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/cxx-qt-build/src/qml_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
pub qrc_files: &'a [A],
}

impl<'a, A, B> Default for QmlModule<'a, A, B>
impl<A, B> Default for QmlModule<'_, A, B>
where
A: AsRef<Path>,
B: AsRef<Path>,
Expand Down
4 changes: 2 additions & 2 deletions crates/cxx-qt-lib/src/core/qhash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ where

/// An iterator visiting all key-value pairs in arbitrary order.
/// The iterator element type is (&'a T::Key, &'a T::Value).
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter {
hash: self,
index: 0,
Expand Down Expand Up @@ -197,7 +197,7 @@ where
}
}

impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<T> ExactSizeIterator for Iter<'_, T>
where
T: QHashPair,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/cxx-qt-lib/src/core/qlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where

/// An iterator visiting all elements in arbitrary order.
/// The iterator element type is &'a T.
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter {
list: self,
index: 0,
Expand Down Expand Up @@ -249,7 +249,7 @@ where
}
}

impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<T> ExactSizeIterator for Iter<'_, T>
where
T: QListElement,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/cxx-qt-lib/src/core/qmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where

/// An iterator visiting all key-value pairs in an arbitrary order.
/// The iterator element type is (&T::Key, &T::Value).
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter {
map: self,
index: 0,
Expand Down Expand Up @@ -193,7 +193,7 @@ where
}
}

impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<T> ExactSizeIterator for Iter<'_, T>
where
T: QMapPair,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/cxx-qt-lib/src/core/qset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where

/// An iterator visiting all elements in arbitrary order.
/// The iterator element type is &'a T.
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter {
set: self,
index: 0,
Expand Down Expand Up @@ -172,7 +172,7 @@ where
}
}

impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<T> ExactSizeIterator for Iter<'_, T>
where
T: QSetElement,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/cxx-qt-lib/src/core/qvector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where

/// An iterator visiting all elements in arbitrary order.
/// The iterator element type is &'a T.
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter {
vector: self,
index: 0,
Expand Down Expand Up @@ -249,7 +249,7 @@ where
}
}

impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<T> ExactSizeIterator for Iter<'_, T>
where
T: QVectorElement,
{
Expand Down
42 changes: 25 additions & 17 deletions crates/qt-build-utils/src/parse_cflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
use std::env;

#[cfg(feature = "link_qt_object_files")]
use std::{collections::HashSet, sync::OnceLock};
use std::{
collections::HashSet,
sync::{OnceLock, RwLock},
};

#[cfg(feature = "link_qt_object_files")]
static mut LINKED_OBJECT_FILES: OnceLock<HashSet<String>> = OnceLock::new();
static LINKED_OBJECT_FILES: OnceLock<RwLock<HashSet<String>>> = OnceLock::new();

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

0 comments on commit 3d34588

Please sign in to comment.