@@ -2361,9 +2361,7 @@ impl<'c> Translation<'c> {
23612361 . span ( span)
23622362 . mutbl ( )
23632363 . static_item ( & ident2, ty, default_init) ;
2364- let mut init = init?;
2365- init. set_unsafe ( ) ;
2366- let mut init = init. to_expr ( ) ;
2364+ let mut init = init?. set_unsafe ( ) . to_expr ( ) ;
23672365
23682366 self . add_static_initializer_to_section ( ctx, & ident2, typ, & mut init) ?;
23692367 self . items . borrow_mut ( ) [ & self . main_file ] . add_item ( static_item) ;
@@ -3131,9 +3129,7 @@ impl<'c> Translation<'c> {
31313129 }
31323130 }
31333131
3134- let mut res = WithStmts :: new_val ( val) ;
3135- res. merge_unsafe ( set_unsafe) ;
3136- Ok ( res)
3132+ Ok ( WithStmts :: new_val ( val) . merge_unsafe ( set_unsafe) )
31373133 }
31383134
31393135 OffsetOf ( ty, ref kind) => match kind {
@@ -3255,7 +3251,7 @@ impl<'c> Translation<'c> {
32553251
32563252 if is_explicit {
32573253 let stmts = self . compute_variable_array_sizes ( ctx, ty. ctype ) ?;
3258- val. prepend_stmts ( stmts) ;
3254+ val = val . prepend_stmts ( stmts) ;
32593255 }
32603256
32613257 // Shuffle Vector "function" builtins will add a cast to the output of the
@@ -3316,14 +3312,17 @@ impl<'c> Translation<'c> {
33163312 let is_unsafe = lhs. is_unsafe ( ) || rhs. is_unsafe ( ) ;
33173313 let then = mk ( ) . block ( lhs. into_stmts ( ) ) ;
33183314 let else_ = mk ( ) . block_expr ( mk ( ) . block ( rhs. into_stmts ( ) ) ) ;
3315+ let res = cond
3316+ . and_then ( |c| {
3317+ WithStmts :: new (
3318+ vec ! [ mk( ) . semi_stmt( mk( ) . ifte_expr( c, then, Some ( else_) ) ) ] ,
3319+ self . panic_or_err (
3320+ "Conditional expression is not supposed to be used" ,
3321+ ) ,
3322+ )
3323+ } )
3324+ . merge_unsafe ( is_unsafe) ;
33193325
3320- let mut res = cond. and_then ( |c| {
3321- WithStmts :: new (
3322- vec ! [ mk( ) . semi_stmt( mk( ) . ifte_expr( c, then, Some ( else_) ) ) ] ,
3323- self . panic_or_err ( "Conditional expression is not supposed to be used" ) ,
3324- )
3325- } ) ;
3326- res. merge_unsafe ( is_unsafe) ;
33273326 Ok ( res)
33283327 } else {
33293328 let then = lhs. to_block ( ) ;
@@ -3345,7 +3344,7 @@ impl<'c> Translation<'c> {
33453344 if ctx. is_unused ( ) {
33463345 let mut lhs = self . convert_condition ( ctx, false , lhs) ?;
33473346 let rhs = self . convert_expr ( ctx, rhs, None ) ?;
3348- lhs. merge_unsafe ( rhs. is_unsafe ( ) ) ;
3347+ lhs = lhs . merge_unsafe ( rhs. is_unsafe ( ) ) ;
33493348
33503349 Ok ( lhs. and_then ( |val| {
33513350 WithStmts :: new (
0 commit comments