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

Clippy (elided lifetimes) + rustfmt #956

Merged
merged 3 commits into from
Dec 1, 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
6 changes: 3 additions & 3 deletions godot-cell/src/blocking_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a, T> Deref for RefGuardBlocking<'a, T> {
}
}

impl<'a, T> Drop for RefGuardBlocking<'a, T> {
impl<T> Drop for RefGuardBlocking<'_, T> {
fn drop(&mut self) {
let mut state_lock = self.state.lock().unwrap();

Expand Down Expand Up @@ -88,13 +88,13 @@ impl<'a, T> Deref for MutGuardBlocking<'a, T> {
}
}

impl<'a, T> DerefMut for MutGuardBlocking<'a, T> {
impl<T> DerefMut for MutGuardBlocking<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.inner.as_mut().unwrap().deref_mut()
}
}

impl<'a, T> Drop for MutGuardBlocking<'a, T> {
impl<T> Drop for MutGuardBlocking<'_, T> {
fn drop(&mut self) {
drop(self.inner.take());

Expand Down
12 changes: 6 additions & 6 deletions godot-cell/src/guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a, T> RefGuard<'a, T> {
}
}

impl<'a, T> Deref for RefGuard<'a, T> {
impl<T> Deref for RefGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand All @@ -54,7 +54,7 @@ impl<'a, T> Deref for RefGuard<'a, T> {
}
}

impl<'a, T> Drop for RefGuard<'a, T> {
impl<T> Drop for RefGuard<'_, T> {
fn drop(&mut self) {
self.state
.lock()
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<'a, T> MutGuard<'a, T> {
}
}

impl<'a, T> Deref for MutGuard<'a, T> {
impl<T> Deref for MutGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -150,7 +150,7 @@ impl<'a, T> Deref for MutGuard<'a, T> {
}
}

impl<'a, T> DerefMut for MutGuard<'a, T> {
impl<T> DerefMut for MutGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
let count = self.state.lock().unwrap().borrow_state.mut_count();
// This is just a best-effort error check. It should never be triggered.
Expand All @@ -177,7 +177,7 @@ impl<'a, T> DerefMut for MutGuard<'a, T> {
}
}

impl<'a, T> Drop for MutGuard<'a, T> {
impl<T> Drop for MutGuard<'_, T> {
fn drop(&mut self) {
self.state
.lock()
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, T> InaccessibleGuard<'a, T> {
}
}

impl<'a, T> Drop for InaccessibleGuard<'a, T> {
impl<T> Drop for InaccessibleGuard<'_, T> {
fn drop(&mut self) {
// Default behavior of drop-logic simply panics and poisons the cell on failure. This is appropriate
// for single-threaded code where no errors should happen here.
Expand Down
2 changes: 1 addition & 1 deletion godot-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl<'a> Context<'a> {
self.cached_rust_types.get(ty)
}

pub fn notification_constants(&'a self, class_name: &TyName) -> Option<&Vec<(Ident, i32)>> {
pub fn notification_constants(&'a self, class_name: &TyName) -> Option<&'a Vec<(Ident, i32)>> {
self.notifications_by_class.get(class_name)
}

Expand Down
6 changes: 5 additions & 1 deletion godot-core/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ where
Self { _c: PhantomData }
}

pub fn virtual_method<'cb, F>(&'cb mut self, name: &'cb str, method: F) -> MethodBuilder<C, F> {
pub fn virtual_method<'cb, F>(
&'cb mut self,
name: &'cb str,
method: F,
) -> MethodBuilder<'cb, C, F> {
MethodBuilder::new(self, name, method)
}
}
Expand Down
8 changes: 5 additions & 3 deletions godot-core/src/builtin/collections/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,10 @@ impl<T: ArrayElement> Drop for Array<T> {
impl<T: ArrayElement> GodotType for Array<T> {
type Ffi = Self;

type ToFfi<'f> = RefArg<'f, Array<T>>
where Self: 'f;
type ToFfi<'f>
= RefArg<'f, Array<T>>
where
Self: 'f;

fn to_ffi(&self) -> Self::ToFfi<'_> {
RefArg::new(self)
Expand Down Expand Up @@ -1250,7 +1252,7 @@ pub struct Iter<'a, T: ArrayElement> {
next_idx: usize,
}

impl<'a, T: ArrayElement + FromGodot> Iterator for Iter<'a, T> {
impl<T: ArrayElement + FromGodot> Iterator for Iter<'_, T> {
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
8 changes: 4 additions & 4 deletions godot-core/src/builtin/collections/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ impl<'a> Iter<'a> {
}
}

impl<'a> Iterator for Iter<'a> {
impl Iterator for Iter<'_> {
type Item = (Variant, Variant);

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -614,7 +614,7 @@ impl<'a> Keys<'a> {
}
}

impl<'a> Iterator for Keys<'a> {
impl Iterator for Keys<'_> {
type Item = Variant;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -647,7 +647,7 @@ impl<'a, K, V> TypedIter<'a, K, V> {
}
}

impl<'a, K: FromGodot, V: FromGodot> Iterator for TypedIter<'a, K, V> {
impl<K: FromGodot, V: FromGodot> Iterator for TypedIter<'_, K, V> {
type Item = (K, V);

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -680,7 +680,7 @@ impl<'a, K> TypedKeys<'a, K> {
}
}

impl<'a, K: FromGodot> Iterator for TypedKeys<'a, K> {
impl<K: FromGodot> Iterator for TypedKeys<'_, K> {
type Item = K;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 4 additions & 2 deletions godot-core/src/builtin/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ impl GodotConvert for &str {
}

impl ToGodot for &str {
type ToVia<'v> = GString
where Self: 'v;
type ToVia<'v>
= GString
where
Self: 'v;

fn to_godot(&self) -> Self::ToVia<'_> {
GString::from(*self)
Expand Down
8 changes: 4 additions & 4 deletions godot-core/src/builtin/string/string_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,22 +344,22 @@ impl From<&'static std::ffi::CStr> for StringName {
/// See [`StringName::transient_ord()`].
pub struct TransientStringNameOrd<'a>(&'a StringName);

impl<'a> PartialEq for TransientStringNameOrd<'a> {
impl PartialEq for TransientStringNameOrd<'_> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}

impl<'a> Eq for TransientStringNameOrd<'a> {}
impl Eq for TransientStringNameOrd<'_> {}

impl<'a> PartialOrd for TransientStringNameOrd<'a> {
impl PartialOrd for TransientStringNameOrd<'_> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

// implement Ord like above
impl<'a> Ord for TransientStringNameOrd<'a> {
impl Ord for TransientStringNameOrd<'_> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
// SAFETY: builtin operator provided by Godot.
let op_less = |lhs, rhs| unsafe {
Expand Down
2 changes: 1 addition & 1 deletion godot-core/src/meta/args/as_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ macro_rules! declare_arg_method {
///
/// Allows forwarding of `impl AsArg<T>` arguments to both another signature of `impl AsArg<T>` and signature of `T` for `Copy` types.
/// This is necessary for packed array dispatching to different "inner" backend signatures.
impl<'a, T> AsArg<T> for CowArg<'a, T>
impl<T> AsArg<T> for CowArg<'_, T>
where
for<'r> T: ParamType<Arg<'r> = CowArg<'r, T>> + 'r,
{
Expand Down
24 changes: 13 additions & 11 deletions godot-core/src/meta/args/cow_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum CowArg<'r, T> {
Borrowed(&'r T),
}

impl<'r, T> CowArg<'r, T> {
impl<T> CowArg<'_, T> {
pub fn cow_into_owned(self) -> T
where
T: Clone,
Expand Down Expand Up @@ -53,7 +53,7 @@ impl<'r, T> CowArg<'r, T> {
///
/// `Borrow` may not be the most idiomatic trait for this, but it has the convenient feature that it's implemented for both `T` and `&T`.
/// Since this is a hidden API, it doesn't matter.
impl<'r, T> std::borrow::Borrow<T> for CowArg<'r, T> {
impl<T> std::borrow::Borrow<T> for CowArg<'_, T> {
fn borrow(&self) -> &T {
match self {
CowArg::Owned(v) => v,
Expand All @@ -71,27 +71,29 @@ macro_rules! wrong_direction {
};
}

impl<'r, T> GodotConvert for CowArg<'r, T>
impl<T> GodotConvert for CowArg<'_, T>
where
T: GodotConvert,
{
type Via = T::Via;
}

impl<'r, T> ToGodot for CowArg<'r, T>
impl<T> ToGodot for CowArg<'_, T>
where
T: ToGodot,
{
type ToVia<'v> = T::ToVia<'v>
where Self: 'v;
type ToVia<'v>
= T::ToVia<'v>
where
Self: 'v;

fn to_godot(&self) -> Self::ToVia<'_> {
self.cow_as_ref().to_godot()
}
}

// TODO refactor signature tuples into separate in+out traits, so FromGodot is no longer needed.
impl<'r, T> FromGodot for CowArg<'r, T>
impl<T> FromGodot for CowArg<'_, T>
where
T: FromGodot,
{
Expand All @@ -100,7 +102,7 @@ where
}
}

impl<'r, T> fmt::Debug for CowArg<'r, T>
impl<T> fmt::Debug for CowArg<'_, T>
where
T: fmt::Debug,
{
Expand All @@ -113,7 +115,7 @@ where
}

// SAFETY: delegated to T.
unsafe impl<'r, T> GodotFfi for CowArg<'r, T>
unsafe impl<T> GodotFfi for CowArg<'_, T>
where
T: GodotFfi,
{
Expand Down Expand Up @@ -157,7 +159,7 @@ where
}
}

impl<'r, T> GodotFfiVariant for CowArg<'r, T>
impl<T> GodotFfiVariant for CowArg<'_, T>
where
T: GodotFfiVariant,
{
Expand All @@ -170,7 +172,7 @@ where
}
}

impl<'r, T> GodotNullableFfi for CowArg<'r, T>
impl<T> GodotNullableFfi for CowArg<'_, T>
where
T: GodotNullableFfi,
{
Expand Down
20 changes: 11 additions & 9 deletions godot-core/src/meta/args/ref_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,21 @@ macro_rules! wrong_direction {
};
}

impl<'r, T> GodotConvert for RefArg<'r, T>
impl<T> GodotConvert for RefArg<'_, T>
where
T: GodotConvert,
{
type Via = T::Via;
}

impl<'r, T> ToGodot for RefArg<'r, T>
impl<T> ToGodot for RefArg<'_, T>
where
T: ToGodot,
{
type ToVia<'v> = T::ToVia<'v>
where Self: 'v;
type ToVia<'v>
= T::ToVia<'v>
where
Self: 'v;

fn to_godot(&self) -> Self::ToVia<'_> {
let shared_ref = self
Expand All @@ -97,7 +99,7 @@ where
}

// TODO refactor signature tuples into separate in+out traits, so FromGodot is no longer needed.
impl<'r, T> FromGodot for RefArg<'r, T>
impl<T> FromGodot for RefArg<'_, T>
where
T: FromGodot,
{
Expand All @@ -106,7 +108,7 @@ where
}
}

impl<'r, T> fmt::Debug for RefArg<'r, T>
impl<T> fmt::Debug for RefArg<'_, T>
where
T: fmt::Debug,
{
Expand All @@ -116,7 +118,7 @@ where
}

// SAFETY: delegated to T.
unsafe impl<'r, T> GodotFfi for RefArg<'r, T>
unsafe impl<T> GodotFfi for RefArg<'_, T>
where
T: GodotFfi,
{
Expand Down Expand Up @@ -166,7 +168,7 @@ where
}
}

impl<'r, T> GodotFfiVariant for RefArg<'r, T>
impl<T> GodotFfiVariant for RefArg<'_, T>
where
T: GodotFfiVariant,
{
Expand All @@ -182,7 +184,7 @@ where
}
}

impl<'r, T> GodotNullableFfi for RefArg<'r, T>
impl<T> GodotNullableFfi for RefArg<'_, T>
where
T: GodotNullableFfi,
{
Expand Down
12 changes: 8 additions & 4 deletions godot-core/src/meta/godot_convert/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ where
ToFfi<'f>: GodotNullableFfi,
>,
{
type ToVia<'v> = Option<T::ToVia<'v>>
type ToVia<'v>
= Option<T::ToVia<'v>>
// type ToVia<'v> = Self::Via
where Self: 'v;
where
Self: 'v;

fn to_godot(&self) -> Self::ToVia<'_> {
self.as_ref().map(ToGodot::to_godot)
Expand Down Expand Up @@ -421,8 +423,10 @@ impl<T: ArrayElement> GodotConvert for &[T] {
}

impl<T: ArrayElement> ToGodot for &[T] {
type ToVia<'v> = Array<T>
where Self: 'v;
type ToVia<'v>
= Array<T>
where
Self: 'v;

fn to_godot(&self) -> Self::ToVia<'_> {
Array::from(*self)
Expand Down
Loading
Loading