@@ -205,17 +205,17 @@ pub type Result<T> = StdResult<T, Error>;
205
205
#[ cfg( not( tarpaulin_include) ) ]
206
206
impl fmt:: Display for Error {
207
207
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
208
- match * self {
209
- Error :: SyntaxError { ref message, .. } => write ! ( fmt, "syntax error: {message}" ) ,
210
- Error :: RuntimeError ( ref msg) => write ! ( fmt, "runtime error: {msg}" ) ,
211
- Error :: MemoryError ( ref msg) => {
208
+ match self {
209
+ Error :: SyntaxError { message, .. } => write ! ( fmt, "syntax error: {message}" ) ,
210
+ Error :: RuntimeError ( msg) => write ! ( fmt, "runtime error: {msg}" ) ,
211
+ Error :: MemoryError ( msg) => {
212
212
write ! ( fmt, "memory error: {msg}" )
213
213
}
214
214
#[ cfg( any( feature = "lua53" , feature = "lua52" ) ) ]
215
- Error :: GarbageCollectorError ( ref msg) => {
215
+ Error :: GarbageCollectorError ( msg) => {
216
216
write ! ( fmt, "garbage collector error: {msg}" )
217
217
}
218
- Error :: SafetyError ( ref msg) => {
218
+ Error :: SafetyError ( msg) => {
219
219
write ! ( fmt, "safety error: {msg}" )
220
220
} ,
221
221
Error :: MemoryLimitNotAvailable => {
@@ -234,7 +234,7 @@ impl fmt::Display for Error {
234
234
fmt,
235
235
"too many arguments to Function::bind"
236
236
) ,
237
- Error :: BadArgument { ref to, pos, ref name, ref cause } => {
237
+ Error :: BadArgument { to, pos, name, cause } => {
238
238
if let Some ( name) = name {
239
239
write ! ( fmt, "bad argument `{name}`" ) ?;
240
240
} else {
@@ -245,40 +245,40 @@ impl fmt::Display for Error {
245
245
}
246
246
write ! ( fmt, ": {cause}" )
247
247
} ,
248
- Error :: ToLuaConversionError { from, to, ref message } => {
248
+ Error :: ToLuaConversionError { from, to, message } => {
249
249
write ! ( fmt, "error converting {from} to Lua {to}" ) ?;
250
- match * message {
250
+ match message {
251
251
None => Ok ( ( ) ) ,
252
- Some ( ref message) => write ! ( fmt, " ({message})" ) ,
252
+ Some ( message) => write ! ( fmt, " ({message})" ) ,
253
253
}
254
254
}
255
- Error :: FromLuaConversionError { from, to, ref message } => {
255
+ Error :: FromLuaConversionError { from, to, message } => {
256
256
write ! ( fmt, "error converting Lua {from} to {to}" ) ?;
257
- match * message {
257
+ match message {
258
258
None => Ok ( ( ) ) ,
259
- Some ( ref message) => write ! ( fmt, " ({message})" ) ,
259
+ Some ( message) => write ! ( fmt, " ({message})" ) ,
260
260
}
261
261
}
262
262
Error :: CoroutineUnresumable => write ! ( fmt, "coroutine is non-resumable" ) ,
263
263
Error :: UserDataTypeMismatch => write ! ( fmt, "userdata is not expected type" ) ,
264
264
Error :: UserDataDestructed => write ! ( fmt, "userdata has been destructed" ) ,
265
265
Error :: UserDataBorrowError => write ! ( fmt, "error borrowing userdata" ) ,
266
266
Error :: UserDataBorrowMutError => write ! ( fmt, "error mutably borrowing userdata" ) ,
267
- Error :: MetaMethodRestricted ( ref method) => write ! ( fmt, "metamethod {method} is restricted" ) ,
268
- Error :: MetaMethodTypeError { ref method, type_name, ref message } => {
267
+ Error :: MetaMethodRestricted ( method) => write ! ( fmt, "metamethod {method} is restricted" ) ,
268
+ Error :: MetaMethodTypeError { method, type_name, message } => {
269
269
write ! ( fmt, "metamethod {method} has unsupported type {type_name}" ) ?;
270
- match * message {
270
+ match message {
271
271
None => Ok ( ( ) ) ,
272
- Some ( ref message) => write ! ( fmt, " ({message})" ) ,
272
+ Some ( message) => write ! ( fmt, " ({message})" ) ,
273
273
}
274
274
}
275
275
Error :: MismatchedRegistryKey => {
276
276
write ! ( fmt, "RegistryKey used from different Lua state" )
277
277
}
278
- Error :: CallbackError { ref cause, ref traceback } => {
278
+ Error :: CallbackError { cause, traceback } => {
279
279
// Trace errors down to the root
280
280
let ( mut cause, mut full_traceback) = ( cause, None ) ;
281
- while let Error :: CallbackError { cause : ref cause2, traceback : ref traceback2 } = * * cause {
281
+ while let Error :: CallbackError { cause : cause2, traceback : traceback2 } = & * * cause {
282
282
cause = cause2;
283
283
full_traceback = Some ( traceback2) ;
284
284
}
@@ -302,15 +302,15 @@ impl fmt::Display for Error {
302
302
write ! ( fmt, "previously resumed panic returned again" )
303
303
}
304
304
#[ cfg( feature = "serialize" ) ]
305
- Error :: SerializeError ( ref err) => {
305
+ Error :: SerializeError ( err) => {
306
306
write ! ( fmt, "serialize error: {err}" )
307
307
} ,
308
308
#[ cfg( feature = "serialize" ) ]
309
- Error :: DeserializeError ( ref err) => {
309
+ Error :: DeserializeError ( err) => {
310
310
write ! ( fmt, "deserialize error: {err}" )
311
311
} ,
312
- Error :: ExternalError ( ref err) => write ! ( fmt, "{err}" ) ,
313
- Error :: WithContext { ref context, ref cause } => {
312
+ Error :: ExternalError ( err) => write ! ( fmt, "{err}" ) ,
313
+ Error :: WithContext { context, cause } => {
314
314
writeln ! ( fmt, "{context}" ) ?;
315
315
write ! ( fmt, "{cause}" )
316
316
}
@@ -320,15 +320,15 @@ impl fmt::Display for Error {
320
320
321
321
impl StdError for Error {
322
322
fn source ( & self ) -> Option < & ( dyn StdError + ' static ) > {
323
- match * self {
323
+ match self {
324
324
// An error type with a source error should either return that error via source or
325
325
// include that source's error message in its own Display output, but never both.
326
326
// https://blog.rust-lang.org/inside-rust/2021/07/01/What-the-error-handling-project-group-is-working-towards.html
327
327
// Given that we include source to fmt::Display implementation for `CallbackError`, this call
328
328
// returns nothing.
329
329
Error :: CallbackError { .. } => None ,
330
- Error :: ExternalError ( ref err) => err. source ( ) ,
331
- Error :: WithContext { ref cause, .. } => match cause. as_ref ( ) {
330
+ Error :: ExternalError ( err) => err. source ( ) ,
331
+ Error :: WithContext { cause, .. } => match cause. as_ref ( ) {
332
332
Error :: ExternalError ( err) => err. source ( ) ,
333
333
_ => None ,
334
334
} ,
@@ -374,15 +374,15 @@ impl Error {
374
374
}
375
375
}
376
376
377
- pub ( crate ) fn from_lua_conversion < ' a > (
377
+ pub ( crate ) fn from_lua_conversion (
378
378
from : & ' static str ,
379
379
to : & ' static str ,
380
- message : impl Into < Option < & ' a str > > ,
380
+ message : impl Into < Option < String > > ,
381
381
) -> Self {
382
382
Error :: FromLuaConversionError {
383
383
from,
384
384
to,
385
- message : message. into ( ) . map ( |s| s . into ( ) ) ,
385
+ message : message. into ( ) ,
386
386
}
387
387
}
388
388
}
0 commit comments