@@ -517,26 +517,29 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
517
517
match ty:: get ( ety) . sty {
518
518
ty:: ty_float( _) => {
519
519
match val {
520
+ const_bool( b) => Ok ( const_float ( b as f64 ) ) ,
520
521
const_uint( u) => Ok ( const_float ( u as f64 ) ) ,
521
522
const_int( i) => Ok ( const_float ( i as f64 ) ) ,
522
523
const_float( f) => Ok ( const_float ( f) ) ,
523
- _ => Err ( "can't cast float to str " . to_string ( ) ) ,
524
+ _ => Err ( "can't cast this type to float " . to_string ( ) ) ,
524
525
}
525
526
}
526
527
ty:: ty_uint( _) => {
527
528
match val {
529
+ const_bool( b) => Ok ( const_uint ( b as u64 ) ) ,
528
530
const_uint( u) => Ok ( const_uint ( u) ) ,
529
531
const_int( i) => Ok ( const_uint ( i as u64 ) ) ,
530
532
const_float( f) => Ok ( const_uint ( f as u64 ) ) ,
531
- _ => Err ( "can't cast str to uint" . to_string ( ) ) ,
533
+ _ => Err ( "can't cast this type to uint" . to_string ( ) ) ,
532
534
}
533
535
}
534
- ty:: ty_int( _) | ty :: ty_bool => {
536
+ ty:: ty_int( _) => {
535
537
match val {
538
+ const_bool( b) => Ok ( const_int ( b as i64 ) ) ,
536
539
const_uint( u) => Ok ( const_int ( u as i64 ) ) ,
537
540
const_int( i) => Ok ( const_int ( i) ) ,
538
541
const_float( f) => Ok ( const_int ( f as i64 ) ) ,
539
- _ => Err ( "can't cast str to int" . to_string ( ) ) ,
542
+ _ => Err ( "can't cast this type to int" . to_string ( ) ) ,
540
543
}
541
544
}
542
545
_ => Err ( "can't cast this type" . to_string ( ) )
0 commit comments