@@ -4,7 +4,6 @@ use crate::ty::{
44 VariantIdx ,
55} ;
66use crate :: { Error , Opaque , Span , Symbol } ;
7- use std:: borrow:: Cow ;
87use std:: io;
98/// The SMIR representation of a single function.
109#[ derive( Clone , Debug ) ]
@@ -265,63 +264,51 @@ pub enum AssertMessage {
265264}
266265
267266impl AssertMessage {
268- pub fn description ( & self ) -> Result < Cow < ' static , str > , Error > {
267+ pub fn description ( & self ) -> Result < & ' static str , Error > {
269268 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" ) ,
280273 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" )
289275 }
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" ) ,
290279 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" ) ,
292281 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" )
294283 }
295284 AssertMessage :: ResumedAfterReturn ( CoroutineKind :: Coroutine ) => {
296- Ok ( "coroutine resumed after completion" . into ( ) )
285+ Ok ( "coroutine resumed after completion" )
297286 }
298287 AssertMessage :: ResumedAfterReturn ( CoroutineKind :: Async ( _) ) => {
299- Ok ( "`async fn` resumed after completion" . into ( ) )
288+ Ok ( "`async fn` resumed after completion" )
300289 }
301290 AssertMessage :: ResumedAfterReturn ( CoroutineKind :: Gen ( _) ) => {
302- Ok ( "`async gen fn` resumed after completion" . into ( ) )
291+ Ok ( "`async gen fn` resumed after completion" )
303292 }
304293 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" )
307295 }
308296 AssertMessage :: ResumedAfterPanic ( CoroutineKind :: Coroutine ) => {
309- Ok ( "coroutine resumed after panicking" . into ( ) )
297+ Ok ( "coroutine resumed after panicking" )
310298 }
311299 AssertMessage :: ResumedAfterPanic ( CoroutineKind :: Async ( _) ) => {
312- Ok ( "`async fn` resumed after panicking" . into ( ) )
300+ Ok ( "`async fn` resumed after panicking" )
313301 }
314302 AssertMessage :: ResumedAfterPanic ( CoroutineKind :: Gen ( _) ) => {
315- Ok ( "`async gen fn` resumed after panicking" . into ( ) )
303+ Ok ( "`async gen fn` resumed after panicking" )
316304 }
317305 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" )
320307 }
321308
322- AssertMessage :: BoundsCheck { .. } => Ok ( "index out of bounds" . into ( ) ) ,
309+ AssertMessage :: BoundsCheck { .. } => Ok ( "index out of bounds" ) ,
323310 AssertMessage :: MisalignedPointerDereference { .. } => {
324- Ok ( "misaligned pointer dereference" . into ( ) )
311+ Ok ( "misaligned pointer dereference" )
325312 }
326313 }
327314 }
0 commit comments