11use  rustc_ast as  ast; 
22use  rustc_hir:: LangItem ; 
33use  rustc_middle:: bug; 
4- use  rustc_middle:: mir:: interpret:: { LitToConstError ,   LitToConstInput } ; 
4+ use  rustc_middle:: mir:: interpret:: LitToConstInput ; 
55use  rustc_middle:: ty:: { self ,  ScalarInt ,  TyCtxt ,  TypeVisitableExt  as  _} ; 
66use  tracing:: trace; 
77
@@ -10,11 +10,11 @@ use crate::builder::parse_float_into_scalar;
1010pub ( crate )  fn  lit_to_const < ' tcx > ( 
1111    tcx :  TyCtxt < ' tcx > , 
1212    lit_input :  LitToConstInput < ' tcx > , 
13- )  -> Result < ty:: Const < ' tcx > ,   LitToConstError >  { 
13+ )  -> ty:: Const < ' tcx >  { 
1414    let  LitToConstInput  {  lit,  ty,  neg }  = lit_input; 
1515
1616    if  let  Err ( guar)  = ty. error_reported ( )  { 
17-         return  Ok ( ty:: Const :: new_error ( tcx,  guar) ) ; 
17+         return  ty:: Const :: new_error ( tcx,  guar) ; 
1818    } 
1919
2020    let  trunc = |n| { 
@@ -28,8 +28,8 @@ pub(crate) fn lit_to_const<'tcx>(
2828        let  result = width. truncate ( n) ; 
2929        trace ! ( "trunc result: {}" ,  result) ; 
3030
31-         Ok ( ScalarInt :: try_from_uint ( result,  width) 
32-             . unwrap_or_else ( || bug ! ( "expected to create ScalarInt from uint {:?}" ,  result) ) ) 
31+         ScalarInt :: try_from_uint ( result,  width) 
32+             . unwrap_or_else ( || bug ! ( "expected to create ScalarInt from uint {:?}" ,  result) ) 
3333    } ; 
3434
3535    let  valtree = match  ( lit,  ty. kind ( ) )  { 
@@ -57,7 +57,7 @@ pub(crate) fn lit_to_const<'tcx>(
5757        } 
5858        ( ast:: LitKind :: Int ( n,  _) ,  ty:: Uint ( _) )  | ( ast:: LitKind :: Int ( n,  _) ,  ty:: Int ( _) )  => { 
5959            let  scalar_int =
60-                 trunc ( if  neg {  ( n. get ( )  as  i128 ) . overflowing_neg ( ) . 0  as  u128  }  else  {  n. get ( )  } ) ? ; 
60+                 trunc ( if  neg {  ( n. get ( )  as  i128 ) . overflowing_neg ( ) . 0  as  u128  }  else  {  n. get ( )  } ) ; 
6161            ty:: ValTree :: from_scalar_int ( scalar_int) 
6262        } 
6363        ( ast:: LitKind :: Bool ( b) ,  ty:: Bool )  => ty:: ValTree :: from_scalar_int ( ( * b) . into ( ) ) , 
@@ -68,9 +68,9 @@ pub(crate) fn lit_to_const<'tcx>(
6868            ty:: ValTree :: from_scalar_int ( bits) 
6969        } 
7070        ( ast:: LitKind :: Char ( c) ,  ty:: Char )  => ty:: ValTree :: from_scalar_int ( ( * c) . into ( ) ) , 
71-         ( ast:: LitKind :: Err ( guar) ,  _)  => return  Ok ( ty:: Const :: new_error ( tcx,  * guar) ) , 
72-         _ => return  Ok ( ty:: Const :: new_misc_error ( tcx) ) , 
71+         ( ast:: LitKind :: Err ( guar) ,  _)  => return  ty:: Const :: new_error ( tcx,  * guar) , 
72+         _ => return  ty:: Const :: new_misc_error ( tcx) , 
7373    } ; 
7474
75-     Ok ( ty:: Const :: new_value ( tcx,  valtree,  ty) ) 
75+     ty:: Const :: new_value ( tcx,  valtree,  ty) 
7676} 
0 commit comments