@@ -1631,53 +1631,6 @@ impl<'c> Translation<'c> {
16311631 }
16321632 }
16331633
1634- fn static_initializer_is_unsafe ( & self , expr_id : Option < CExprId > , qty : CQualTypeId ) -> bool {
1635- // SIMD types are always unsafe in statics
1636- match self . ast_context . resolve_type ( qty. ctype ) . kind {
1637- CTypeKind :: Vector ( ..) => return true ,
1638- CTypeKind :: ConstantArray ( ctype, ..) => {
1639- let kind = & self . ast_context . resolve_type ( ctype) . kind ;
1640-
1641- if let CTypeKind :: Vector ( ..) = kind {
1642- return true ;
1643- }
1644- }
1645- _ => { }
1646- }
1647-
1648- // Get the initializer if there is one
1649- let expr_id = match expr_id {
1650- Some ( expr_id) => expr_id,
1651- None => return false ,
1652- } ;
1653-
1654- // Look for code which can only be translated unsafely
1655- let iter = DFExpr :: new ( & self . ast_context , expr_id. into ( ) ) ;
1656-
1657- for i in iter {
1658- let expr_id = match i {
1659- SomeId :: Expr ( expr_id) => expr_id,
1660- _ => unreachable ! ( "Found static initializer type other than expr" ) ,
1661- } ;
1662-
1663- use CExprKind :: * ;
1664- match self . ast_context [ expr_id] . kind {
1665- ImplicitCast ( _, _, cast_kind, _, _) | ExplicitCast ( _, _, cast_kind, _, _) => {
1666- use CastKind :: * ;
1667- match cast_kind {
1668- IntegralToPointer | FunctionToPointerDecay | PointerToIntegral => {
1669- return true ;
1670- }
1671- _ => { }
1672- }
1673- }
1674- _ => { }
1675- }
1676- }
1677-
1678- false
1679- }
1680-
16811634 /// The purpose of this function is to decide on whether or not a static initializer's
16821635 /// translation is able to be compiled as a valid rust static initializer
16831636 fn static_initializer_is_uncompilable (
@@ -2126,12 +2079,6 @@ impl<'c> Translation<'c> {
21262079 let mut items = init. stmts_to_items ( ) . ok_or_else ( || {
21272080 format_err ! ( "Expected only item statements in static initializer" )
21282081 } ) ?;
2129-
2130- // TODO: Replace this by relying entirely on
2131- // WithStmts.is_unsafe() of the translated variable
2132- if self . static_initializer_is_unsafe ( initializer, typ) {
2133- init. set_unsafe ( )
2134- }
21352082 let init = init. wrap_unsafe ( ) . to_pure_expr ( ) . unwrap ( ) ;
21362083 let item = static_def. span ( span) . static_item ( new_name, ty, init) ;
21372084 items. push ( item) ;
0 commit comments