Skip to content

Commit 29f8f13

Browse files
committed
Require std::error::Error for all UserData errors
1 parent db2173f commit 29f8f13

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

gdnative-core/src/export/user_data.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub unsafe trait UserData: Sized + Clone {
121121

122122
/// Trait for wrappers that can be mapped immutably.
123123
pub trait Map: UserData {
124-
type Err: Debug;
124+
type Err: std::error::Error;
125125

126126
/// Maps a `&T` to `U`. Called for methods that take `&self`.
127127
///
@@ -134,7 +134,7 @@ pub trait Map: UserData {
134134

135135
/// Trait for wrappers that can be mapped mutably.
136136
pub trait MapMut: UserData {
137-
type Err: Debug;
137+
type Err: std::error::Error;
138138

139139
/// Maps a `&mut T` to `U`. Called for methods that take `&mut self`.
140140
///
@@ -147,7 +147,7 @@ pub trait MapMut: UserData {
147147

148148
/// Trait for wrappers that can be mapped once.
149149
pub trait MapOwned: UserData {
150-
type Err: Debug;
150+
type Err: std::error::Error;
151151

152152
/// Maps a `T` to `U`. Called for methods that take `self`. This method may fail with
153153
/// an error if it is called more than once on the same object.
@@ -168,10 +168,11 @@ pub type DefaultUserData<T> = LocalCellData<T>;
168168
#[allow(clippy::exhaustive_enums)] // explicitly uninhabited
169169
pub enum Infallible {}
170170

171+
impl std::error::Error for Infallible {}
171172
impl std::fmt::Display for Infallible {
172173
#[inline]
173-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
174-
write!(f, "operation that can't fail just failed")
174+
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
175+
unreachable!("uninhabited enum")
175176
}
176177
}
177178

gdnative-core/src/object/instance/receiver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Receiver<C: NativeClass>: Sized {
2222
#[doc(hidden)]
2323
type This<'a>;
2424
#[doc(hidden)]
25-
type Err: Debug;
25+
type Err: std::error::Error;
2626

2727
#[doc(hidden)]
2828
fn with_instance<F, R>(instance: TInstance<'_, C, Shared>, f: F) -> Result<R, Self::Err>
@@ -35,6 +35,7 @@ pub trait Receiver<C: NativeClass>: Sized {
3535
#[allow(clippy::exhaustive_enums)] // explicitly uninhabited
3636
pub enum Infallible {}
3737

38+
impl std::error::Error for Infallible {}
3839
impl Display for Infallible {
3940
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4041
unreachable!("uninhabited enum")

0 commit comments

Comments
 (0)