@@ -4,7 +4,6 @@ use crate::ty::{
4
4
VariantIdx ,
5
5
} ;
6
6
use crate :: { Error , Opaque , Span , Symbol } ;
7
- use std:: borrow:: Cow ;
8
7
use std:: io;
9
8
/// The SMIR representation of a single function.
10
9
#[ derive( Clone , Debug ) ]
@@ -265,63 +264,51 @@ pub enum AssertMessage {
265
264
}
266
265
267
266
impl AssertMessage {
268
- pub fn description ( & self ) -> Result < Cow < ' static , str > , Error > {
267
+ pub fn description ( & self ) -> Result < & ' static str , Error > {
269
268
match self {
270
- AssertMessage :: Overflow ( BinOp :: Add , _, _) => Ok ( "attempt to add with overflow" . into ( ) ) ,
271
- AssertMessage :: Overflow ( BinOp :: Sub , _, _) => {
272
- Ok ( "attempt to subtract with overflow" . into ( ) )
273
- }
274
- AssertMessage :: Overflow ( BinOp :: Mul , _, _) => {
275
- Ok ( "attempt to multiply with overflow" . into ( ) )
276
- }
277
- AssertMessage :: Overflow ( BinOp :: Div , _, _) => {
278
- Ok ( "attempt to divide with overflow" . into ( ) )
279
- }
269
+ AssertMessage :: Overflow ( BinOp :: Add , _, _) => Ok ( "attempt to add with overflow" ) ,
270
+ AssertMessage :: Overflow ( BinOp :: Sub , _, _) => Ok ( "attempt to subtract with overflow" ) ,
271
+ AssertMessage :: Overflow ( BinOp :: Mul , _, _) => Ok ( "attempt to multiply with overflow" ) ,
272
+ AssertMessage :: Overflow ( BinOp :: Div , _, _) => Ok ( "attempt to divide with overflow" ) ,
280
273
AssertMessage :: Overflow ( BinOp :: Rem , _, _) => {
281
- Ok ( "attempt to calculate the remainder with overflow" . into ( ) )
282
- }
283
- AssertMessage :: OverflowNeg ( _) => Ok ( "attempt to negate with overflow" . into ( ) ) ,
284
- AssertMessage :: Overflow ( BinOp :: Shr , _, _) => {
285
- Ok ( "attempt to shift right with overflow" . into ( ) )
286
- }
287
- AssertMessage :: Overflow ( BinOp :: Shl , _, _) => {
288
- Ok ( "attempt to shift left with overflow" . into ( ) )
274
+ Ok ( "attempt to calculate the remainder with overflow" )
289
275
}
276
+ AssertMessage :: OverflowNeg ( _) => Ok ( "attempt to negate with overflow" ) ,
277
+ AssertMessage :: Overflow ( BinOp :: Shr , _, _) => Ok ( "attempt to shift right with overflow" ) ,
278
+ AssertMessage :: Overflow ( BinOp :: Shl , _, _) => Ok ( "attempt to shift left with overflow" ) ,
290
279
AssertMessage :: Overflow ( op, _, _) => Err ( error ! ( "`{:?}` cannot overflow" , op) ) ,
291
- AssertMessage :: DivisionByZero ( _) => Ok ( "attempt to divide by zero" . into ( ) ) ,
280
+ AssertMessage :: DivisionByZero ( _) => Ok ( "attempt to divide by zero" ) ,
292
281
AssertMessage :: RemainderByZero ( _) => {
293
- Ok ( "attempt to calculate the remainder with a divisor of zero" . into ( ) )
282
+ Ok ( "attempt to calculate the remainder with a divisor of zero" )
294
283
}
295
284
AssertMessage :: ResumedAfterReturn ( CoroutineKind :: Coroutine ) => {
296
- Ok ( "coroutine resumed after completion" . into ( ) )
285
+ Ok ( "coroutine resumed after completion" )
297
286
}
298
287
AssertMessage :: ResumedAfterReturn ( CoroutineKind :: Async ( _) ) => {
299
- Ok ( "`async fn` resumed after completion" . into ( ) )
288
+ Ok ( "`async fn` resumed after completion" )
300
289
}
301
290
AssertMessage :: ResumedAfterReturn ( CoroutineKind :: Gen ( _) ) => {
302
- Ok ( "`async gen fn` resumed after completion" . into ( ) )
291
+ Ok ( "`async gen fn` resumed after completion" )
303
292
}
304
293
AssertMessage :: ResumedAfterReturn ( CoroutineKind :: AsyncGen ( _) ) => {
305
- Ok ( "`gen fn` should just keep returning `AssertMessage::None` after completion"
306
- . into ( ) )
294
+ Ok ( "`gen fn` should just keep returning `AssertMessage::None` after completion" )
307
295
}
308
296
AssertMessage :: ResumedAfterPanic ( CoroutineKind :: Coroutine ) => {
309
- Ok ( "coroutine resumed after panicking" . into ( ) )
297
+ Ok ( "coroutine resumed after panicking" )
310
298
}
311
299
AssertMessage :: ResumedAfterPanic ( CoroutineKind :: Async ( _) ) => {
312
- Ok ( "`async fn` resumed after panicking" . into ( ) )
300
+ Ok ( "`async fn` resumed after panicking" )
313
301
}
314
302
AssertMessage :: ResumedAfterPanic ( CoroutineKind :: Gen ( _) ) => {
315
- Ok ( "`async gen fn` resumed after panicking" . into ( ) )
303
+ Ok ( "`async gen fn` resumed after panicking" )
316
304
}
317
305
AssertMessage :: ResumedAfterPanic ( CoroutineKind :: AsyncGen ( _) ) => {
318
- Ok ( "`gen fn` should just keep returning `AssertMessage::None` after panicking"
319
- . into ( ) )
306
+ Ok ( "`gen fn` should just keep returning `AssertMessage::None` after panicking" )
320
307
}
321
308
322
- AssertMessage :: BoundsCheck { .. } => Ok ( "index out of bounds" . into ( ) ) ,
309
+ AssertMessage :: BoundsCheck { .. } => Ok ( "index out of bounds" ) ,
323
310
AssertMessage :: MisalignedPointerDereference { .. } => {
324
- Ok ( "misaligned pointer dereference" . into ( ) )
311
+ Ok ( "misaligned pointer dereference" )
325
312
}
326
313
}
327
314
}
0 commit comments