Skip to content

Commit 385a765

Browse files
authored
Merge pull request #956 from godot-rust/qol/clippy-elided-lifetimes
Clippy (elided lifetimes) + rustfmt
2 parents c6b8b0e + 6b2a833 commit 385a765

File tree

20 files changed

+80
-61
lines changed

20 files changed

+80
-61
lines changed

godot-cell/src/blocking_guards.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, T> Deref for RefGuardBlocking<'a, T> {
4343
}
4444
}
4545

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

@@ -88,13 +88,13 @@ impl<'a, T> Deref for MutGuardBlocking<'a, T> {
8888
}
8989
}
9090

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

97-
impl<'a, T> Drop for MutGuardBlocking<'a, T> {
97+
impl<T> Drop for MutGuardBlocking<'_, T> {
9898
fn drop(&mut self) {
9999
drop(self.inner.take());
100100

godot-cell/src/guards.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a, T> RefGuard<'a, T> {
4545
}
4646
}
4747

48-
impl<'a, T> Deref for RefGuard<'a, T> {
48+
impl<T> Deref for RefGuard<'_, T> {
4949
type Target = T;
5050

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

57-
impl<'a, T> Drop for RefGuard<'a, T> {
57+
impl<T> Drop for RefGuard<'_, T> {
5858
fn drop(&mut self) {
5959
self.state
6060
.lock()
@@ -122,7 +122,7 @@ impl<'a, T> MutGuard<'a, T> {
122122
}
123123
}
124124

125-
impl<'a, T> Deref for MutGuard<'a, T> {
125+
impl<T> Deref for MutGuard<'_, T> {
126126
type Target = T;
127127

128128
fn deref(&self) -> &Self::Target {
@@ -150,7 +150,7 @@ impl<'a, T> Deref for MutGuard<'a, T> {
150150
}
151151
}
152152

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

180-
impl<'a, T> Drop for MutGuard<'a, T> {
180+
impl<T> Drop for MutGuard<'_, T> {
181181
fn drop(&mut self) {
182182
self.state
183183
.lock()
@@ -276,7 +276,7 @@ impl<'a, T> InaccessibleGuard<'a, T> {
276276
}
277277
}
278278

279-
impl<'a, T> Drop for InaccessibleGuard<'a, T> {
279+
impl<T> Drop for InaccessibleGuard<'_, T> {
280280
fn drop(&mut self) {
281281
// Default behavior of drop-logic simply panics and poisons the cell on failure. This is appropriate
282282
// for single-threaded code where no errors should happen here.

godot-codegen/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'a> Context<'a> {
274274
self.cached_rust_types.get(ty)
275275
}
276276

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

godot-core/src/builder/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ where
2222
Self { _c: PhantomData }
2323
}
2424

25-
pub fn virtual_method<'cb, F>(&'cb mut self, name: &'cb str, method: F) -> MethodBuilder<C, F> {
25+
pub fn virtual_method<'cb, F>(
26+
&'cb mut self,
27+
name: &'cb str,
28+
method: F,
29+
) -> MethodBuilder<'cb, C, F> {
2630
MethodBuilder::new(self, name, method)
2731
}
2832
}

godot-core/src/builtin/collections/array.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,10 @@ impl<T: ArrayElement> Drop for Array<T> {
11021102
impl<T: ArrayElement> GodotType for Array<T> {
11031103
type Ffi = Self;
11041104

1105-
type ToFfi<'f> = RefArg<'f, Array<T>>
1106-
where Self: 'f;
1105+
type ToFfi<'f>
1106+
= RefArg<'f, Array<T>>
1107+
where
1108+
Self: 'f;
11071109

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

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

12561258
fn next(&mut self) -> Option<Self::Item> {

godot-core/src/builtin/collections/dictionary.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl<'a> Iter<'a> {
572572
}
573573
}
574574

575-
impl<'a> Iterator for Iter<'a> {
575+
impl Iterator for Iter<'_> {
576576
type Item = (Variant, Variant);
577577

578578
fn next(&mut self) -> Option<Self::Item> {
@@ -614,7 +614,7 @@ impl<'a> Keys<'a> {
614614
}
615615
}
616616

617-
impl<'a> Iterator for Keys<'a> {
617+
impl Iterator for Keys<'_> {
618618
type Item = Variant;
619619

620620
fn next(&mut self) -> Option<Self::Item> {
@@ -647,7 +647,7 @@ impl<'a, K, V> TypedIter<'a, K, V> {
647647
}
648648
}
649649

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

653653
fn next(&mut self) -> Option<Self::Item> {
@@ -680,7 +680,7 @@ impl<'a, K> TypedKeys<'a, K> {
680680
}
681681
}
682682

683-
impl<'a, K: FromGodot> Iterator for TypedKeys<'a, K> {
683+
impl<K: FromGodot> Iterator for TypedKeys<'_, K> {
684684
type Item = K;
685685

686686
fn next(&mut self) -> Option<Self::Item> {

godot-core/src/builtin/string/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ impl GodotConvert for &str {
2424
}
2525

2626
impl ToGodot for &str {
27-
type ToVia<'v> = GString
28-
where Self: 'v;
27+
type ToVia<'v>
28+
= GString
29+
where
30+
Self: 'v;
2931

3032
fn to_godot(&self) -> Self::ToVia<'_> {
3133
GString::from(*self)

godot-core/src/builtin/string/string_name.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,22 +344,22 @@ impl From<&'static std::ffi::CStr> for StringName {
344344
/// See [`StringName::transient_ord()`].
345345
pub struct TransientStringNameOrd<'a>(&'a StringName);
346346

347-
impl<'a> PartialEq for TransientStringNameOrd<'a> {
347+
impl PartialEq for TransientStringNameOrd<'_> {
348348
fn eq(&self, other: &Self) -> bool {
349349
self.0 == other.0
350350
}
351351
}
352352

353-
impl<'a> Eq for TransientStringNameOrd<'a> {}
353+
impl Eq for TransientStringNameOrd<'_> {}
354354

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

361361
// implement Ord like above
362-
impl<'a> Ord for TransientStringNameOrd<'a> {
362+
impl Ord for TransientStringNameOrd<'_> {
363363
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
364364
// SAFETY: builtin operator provided by Godot.
365365
let op_less = |lhs, rhs| unsafe {

godot-core/src/meta/args/as_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ macro_rules! declare_arg_method {
179179
///
180180
/// Allows forwarding of `impl AsArg<T>` arguments to both another signature of `impl AsArg<T>` and signature of `T` for `Copy` types.
181181
/// This is necessary for packed array dispatching to different "inner" backend signatures.
182-
impl<'a, T> AsArg<T> for CowArg<'a, T>
182+
impl<T> AsArg<T> for CowArg<'_, T>
183183
where
184184
for<'r> T: ParamType<Arg<'r> = CowArg<'r, T>> + 'r,
185185
{

godot-core/src/meta/args/cow_arg.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum CowArg<'r, T> {
2020
Borrowed(&'r T),
2121
}
2222

23-
impl<'r, T> CowArg<'r, T> {
23+
impl<T> CowArg<'_, T> {
2424
pub fn cow_into_owned(self) -> T
2525
where
2626
T: Clone,
@@ -53,7 +53,7 @@ impl<'r, T> CowArg<'r, T> {
5353
///
5454
/// `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`.
5555
/// Since this is a hidden API, it doesn't matter.
56-
impl<'r, T> std::borrow::Borrow<T> for CowArg<'r, T> {
56+
impl<T> std::borrow::Borrow<T> for CowArg<'_, T> {
5757
fn borrow(&self) -> &T {
5858
match self {
5959
CowArg::Owned(v) => v,
@@ -71,27 +71,29 @@ macro_rules! wrong_direction {
7171
};
7272
}
7373

74-
impl<'r, T> GodotConvert for CowArg<'r, T>
74+
impl<T> GodotConvert for CowArg<'_, T>
7575
where
7676
T: GodotConvert,
7777
{
7878
type Via = T::Via;
7979
}
8080

81-
impl<'r, T> ToGodot for CowArg<'r, T>
81+
impl<T> ToGodot for CowArg<'_, T>
8282
where
8383
T: ToGodot,
8484
{
85-
type ToVia<'v> = T::ToVia<'v>
86-
where Self: 'v;
85+
type ToVia<'v>
86+
= T::ToVia<'v>
87+
where
88+
Self: 'v;
8789

8890
fn to_godot(&self) -> Self::ToVia<'_> {
8991
self.cow_as_ref().to_godot()
9092
}
9193
}
9294

9395
// TODO refactor signature tuples into separate in+out traits, so FromGodot is no longer needed.
94-
impl<'r, T> FromGodot for CowArg<'r, T>
96+
impl<T> FromGodot for CowArg<'_, T>
9597
where
9698
T: FromGodot,
9799
{
@@ -100,7 +102,7 @@ where
100102
}
101103
}
102104

103-
impl<'r, T> fmt::Debug for CowArg<'r, T>
105+
impl<T> fmt::Debug for CowArg<'_, T>
104106
where
105107
T: fmt::Debug,
106108
{
@@ -113,7 +115,7 @@ where
113115
}
114116

115117
// SAFETY: delegated to T.
116-
unsafe impl<'r, T> GodotFfi for CowArg<'r, T>
118+
unsafe impl<T> GodotFfi for CowArg<'_, T>
117119
where
118120
T: GodotFfi,
119121
{
@@ -157,7 +159,7 @@ where
157159
}
158160
}
159161

160-
impl<'r, T> GodotFfiVariant for CowArg<'r, T>
162+
impl<T> GodotFfiVariant for CowArg<'_, T>
161163
where
162164
T: GodotFfiVariant,
163165
{
@@ -170,7 +172,7 @@ where
170172
}
171173
}
172174

173-
impl<'r, T> GodotNullableFfi for CowArg<'r, T>
175+
impl<T> GodotNullableFfi for CowArg<'_, T>
174176
where
175177
T: GodotNullableFfi,
176178
{

godot-core/src/meta/args/ref_arg.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,21 @@ macro_rules! wrong_direction {
7373
};
7474
}
7575

76-
impl<'r, T> GodotConvert for RefArg<'r, T>
76+
impl<T> GodotConvert for RefArg<'_, T>
7777
where
7878
T: GodotConvert,
7979
{
8080
type Via = T::Via;
8181
}
8282

83-
impl<'r, T> ToGodot for RefArg<'r, T>
83+
impl<T> ToGodot for RefArg<'_, T>
8484
where
8585
T: ToGodot,
8686
{
87-
type ToVia<'v> = T::ToVia<'v>
88-
where Self: 'v;
87+
type ToVia<'v>
88+
= T::ToVia<'v>
89+
where
90+
Self: 'v;
8991

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

99101
// TODO refactor signature tuples into separate in+out traits, so FromGodot is no longer needed.
100-
impl<'r, T> FromGodot for RefArg<'r, T>
102+
impl<T> FromGodot for RefArg<'_, T>
101103
where
102104
T: FromGodot,
103105
{
@@ -106,7 +108,7 @@ where
106108
}
107109
}
108110

109-
impl<'r, T> fmt::Debug for RefArg<'r, T>
111+
impl<T> fmt::Debug for RefArg<'_, T>
110112
where
111113
T: fmt::Debug,
112114
{
@@ -116,7 +118,7 @@ where
116118
}
117119

118120
// SAFETY: delegated to T.
119-
unsafe impl<'r, T> GodotFfi for RefArg<'r, T>
121+
unsafe impl<T> GodotFfi for RefArg<'_, T>
120122
where
121123
T: GodotFfi,
122124
{
@@ -166,7 +168,7 @@ where
166168
}
167169
}
168170

169-
impl<'r, T> GodotFfiVariant for RefArg<'r, T>
171+
impl<T> GodotFfiVariant for RefArg<'_, T>
170172
where
171173
T: GodotFfiVariant,
172174
{
@@ -182,7 +184,7 @@ where
182184
}
183185
}
184186

185-
impl<'r, T> GodotNullableFfi for RefArg<'r, T>
187+
impl<T> GodotNullableFfi for RefArg<'_, T>
186188
where
187189
T: GodotNullableFfi,
188190
{

godot-core/src/meta/godot_convert/impls.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ where
100100
ToFfi<'f>: GodotNullableFfi,
101101
>,
102102
{
103-
type ToVia<'v> = Option<T::ToVia<'v>>
103+
type ToVia<'v>
104+
= Option<T::ToVia<'v>>
104105
// type ToVia<'v> = Self::Via
105-
where Self: 'v;
106+
where
107+
Self: 'v;
106108

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

423425
impl<T: ArrayElement> ToGodot for &[T] {
424-
type ToVia<'v> = Array<T>
425-
where Self: 'v;
426+
type ToVia<'v>
427+
= Array<T>
428+
where
429+
Self: 'v;
426430

427431
fn to_godot(&self) -> Self::ToVia<'_> {
428432
Array::from(*self)

0 commit comments

Comments
 (0)