1- use  rustc_abi:: { self  as  abi,  Align ,   HasDataLayout ,  Primitive } ; 
1+ use  rustc_abi:: { self  as  abi,  HasDataLayout ,  Primitive } ; 
22use  rustc_ast:: Mutability ; 
33use  rustc_data_structures:: stable_hasher:: { HashStable ,  StableHasher } ; 
44use  rustc_hashes:: Hash128 ; 
@@ -49,24 +49,17 @@ pub trait ConstCodegenMethods<'tcx>:
4949    fn  const_to_opt_uint ( & self ,  v :  Self :: Value )  -> Option < u64 > ; 
5050    fn  const_to_opt_u128 ( & self ,  v :  Self :: Value ,  sign_ext :  bool )  -> Option < u128 > ; 
5151
52-     fn  const_data_from_alloc ( & self ,  alloc :  ConstAllocation < ' _ > )  -> Self :: Value ; 
53- 
5452    fn  const_bitcast ( & self ,  val :  Self :: Value ,  ty :  Self :: Type )  -> Self :: Value ; 
5553    fn  const_pointercast ( & self ,  val :  Self :: Value ,  ty :  Self :: Type )  -> Self :: Value ; 
5654    fn  const_int_to_ptr ( & self ,  val :  Self :: Value ,  ty :  Self :: Type )  -> Self :: Value ; 
5755    fn  const_ptr_to_int ( & self ,  val :  Self :: Value ,  ty :  Self :: Type )  -> Self :: Value ; 
5856    /// Create a global constant. 
5957/// 
6058/// The returned global variable is a pointer in the default address space for globals. 
61- fn  static_addr_of_const ( 
62-         & self , 
63-         cv :  Self :: Value , 
64-         align :  Align , 
65-         kind :  Option < & str > , 
66-     )  -> Self :: Value ; 
59+ fn  static_addr_of_const ( & self ,  alloc :  ConstAllocation < ' _ > ,  kind :  Option < & str > )  -> Self :: Value ; 
6760
6861    /// Same as `static_addr_of_const`, but does not mark the static as immutable 
69- fn  static_addr_of_mut ( & self ,  cv :   Self :: Value ,   align :   Align ,  kind :  Option < & str > )  -> Self :: Value ; 
62+ fn  static_addr_of_mut ( & self ,  alloc :   ConstAllocation < ' _ > ,  kind :  Option < & str > )  -> Self :: Value ; 
7063
7164    fn  scalar_to_backend ( & self ,  cv :  Scalar ,  layout :  abi:: Scalar ,  llty :  Self :: Type )  -> Self :: Value  { 
7265        let  bitsize = if  layout. is_bool ( )  {  1  }  else  {  layout. size ( self ) . bits ( )  } ; 
@@ -97,18 +90,16 @@ pub trait ConstCodegenMethods<'tcx>:
9790                                self . const_bitcast ( llval,  llty) 
9891                            } ; 
9992                        }  else  { 
100-                             let  init = self . const_data_from_alloc ( alloc) ; 
101-                             let  alloc = alloc. inner ( ) ; 
102-                             let  value = match  alloc. mutability  { 
103-                                 Mutability :: Mut  => self . static_addr_of_mut ( init,  alloc. align ,  None ) , 
104-                                 _ => self . static_addr_of_const ( init,  alloc. align ,  None ) , 
93+                             let  value = match  alloc. inner ( ) . mutability  { 
94+                                 Mutability :: Mut  => self . static_addr_of_mut ( alloc,  None ) , 
95+                                 _ => self . static_addr_of_const ( alloc,  None ) , 
10596                            } ; 
10697                            if  !self . tcx ( ) . sess . fewer_names ( ) 
10798                                && self . get_value_name ( value) . is_empty ( ) 
10899                            { 
109100                                let  hash = self . tcx ( ) . with_stable_hashing_context ( |mut  hcx| { 
110101                                    let  mut  hasher = StableHasher :: new ( ) ; 
111-                                     alloc. hash_stable ( & mut  hcx,  & mut  hasher) ; 
102+                                     alloc. inner ( ) . hash_stable ( & mut  hcx,  & mut  hasher) ; 
112103                                    hasher. finish :: < Hash128 > ( ) 
113104                                } ) ; 
114105                                self . set_value_name ( value,  format ! ( "alloc_{hash:032x}" ) . as_bytes ( ) ) ; 
@@ -127,9 +118,7 @@ pub trait ConstCodegenMethods<'tcx>:
127118                                } ) , 
128119                            ) ) ) 
129120                            . unwrap_memory ( ) ; 
130-                         let  init = self . const_data_from_alloc ( alloc) ; 
131-                         let  value = self . static_addr_of_const ( init,  alloc. inner ( ) . align ,  None ) ; 
132-                         value
121+                         self . static_addr_of_const ( alloc,  None ) 
133122                    } 
134123                    GlobalAlloc :: Static ( def_id)  => { 
135124                        assert ! ( self . tcx( ) . is_static( def_id) ) ; 
0 commit comments