Skip to content

Commit f7217c2

Browse files
committed
Clippy fixes for Rust v1.73.0
1 parent 57ad44e commit f7217c2

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

godot-core/src/builtin/macros.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ macro_rules! impl_builtin_traits_inner {
6868
impl Eq for $Type {}
6969
};
7070

71-
( PartialOrd for $Type:ty => $gd_method:ident ) => {
72-
impl PartialOrd for $Type {
71+
( Ord for $Type:ty => $gd_method:ident ) => {
72+
impl Ord for $Type {
7373
#[inline]
74-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
74+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
7575
let op_less = |lhs, rhs| unsafe {
7676
let mut result = false;
7777
::godot_ffi::builtin_call! {
@@ -81,22 +81,18 @@ macro_rules! impl_builtin_traits_inner {
8181
};
8282

8383
if op_less(self.sys(), other.sys()) {
84-
Some(std::cmp::Ordering::Less)
84+
std::cmp::Ordering::Less
8585
} else if op_less(other.sys(), self.sys()) {
86-
Some(std::cmp::Ordering::Greater)
86+
std::cmp::Ordering::Greater
8787
} else {
88-
Some(std::cmp::Ordering::Equal)
88+
std::cmp::Ordering::Equal
8989
}
9090
}
9191
}
92-
};
93-
94-
( Ord for $Type:ty => $gd_method:ident ) => {
95-
impl_builtin_traits_inner!(PartialOrd for $Type => $gd_method);
96-
impl Ord for $Type {
92+
impl PartialOrd for $Type {
9793
#[inline]
98-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
99-
PartialOrd::partial_cmp(self, other).expect("PartialOrd::partial_cmp")
94+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
95+
Some(self.cmp(other))
10096
}
10197
}
10298
};

godot-macros/src/util/list_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl ListParser {
167167

168168
/// Take the next element of the list, if it is a key-value pair of the form `key = expression`.
169169
pub(crate) fn try_next_key_value(&mut self) -> Option<(Ident, KvValue)> {
170-
let Some(kv) = self.peek() else { return None };
170+
let kv = self.peek()?;
171171

172172
if let Ok((key, value)) = kv.as_key_value() {
173173
_ = self.pop_next();

itest/rust/src/framework/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn get_execution_time(test: &Variant) -> Option<Duration> {
364364
fn get_errors(test: &Variant) -> Array<GodotString> {
365365
test.call("get", &["errors".to_variant()])
366366
.try_to::<Array<GodotString>>()
367-
.unwrap_or(Array::new())
367+
.unwrap_or_default()
368368
}
369369

370370
#[must_use]

0 commit comments

Comments
 (0)