@@ -101,9 +101,12 @@ impl<'tcx> Const<'tcx> {
101
101
ConstVal :: Str ( ref v) => C_str_slice ( ccx, v. clone ( ) ) ,
102
102
ConstVal :: ByteStr ( ref v) => consts:: addr_of ( ccx, C_bytes ( ccx, v) , 1 , "byte_str" ) ,
103
103
ConstVal :: Struct ( _) | ConstVal :: Tuple ( _) |
104
- ConstVal :: Array ( ..) | ConstVal :: Repeat ( ..) |
104
+ ConstVal :: Array ( ..) | ConstVal :: Repeat ( ..) => {
105
+ bug ! ( "MIR must not use `{:?}` (aggregates are expanded to MIR rvalues)" , cv)
106
+ }
105
107
ConstVal :: Function ( ..) => {
106
- bug ! ( "MIR must not use `{:?}` (which refers to a local ID)" , cv)
108
+ let llty = type_of:: type_of ( ccx, ty) ;
109
+ return Const :: new ( C_null ( llty) , ty) ;
107
110
}
108
111
ConstVal :: Char ( c) => C_integral ( Type :: char ( ccx) , c as u64 , false ) ,
109
112
} ;
@@ -477,13 +480,6 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
477
480
let ty = self . monomorphize ( & constant. ty ) ;
478
481
match constant. literal . clone ( ) {
479
482
mir:: Literal :: Item { def_id, substs } => {
480
- // Shortcut for zero-sized types, including function item
481
- // types, which would not work with MirConstContext.
482
- if common:: type_is_zero_size ( self . ccx , ty) {
483
- let llty = type_of:: type_of ( self . ccx , ty) ;
484
- return Ok ( Const :: new ( C_null ( llty) , ty) ) ;
485
- }
486
-
487
483
let substs = self . monomorphize ( & substs) ;
488
484
let instance = Instance :: new ( def_id, substs) ;
489
485
MirConstContext :: trans_def ( self . ccx , instance, IndexVec :: new ( ) )
@@ -927,13 +923,6 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
927
923
let ty = self . monomorphize ( & constant. ty ) ;
928
924
let result = match constant. literal . clone ( ) {
929
925
mir:: Literal :: Item { def_id, substs } => {
930
- // Shortcut for zero-sized types, including function item
931
- // types, which would not work with MirConstContext.
932
- if common:: type_is_zero_size ( bcx. ccx , ty) {
933
- let llty = type_of:: type_of ( bcx. ccx , ty) ;
934
- return Const :: new ( C_null ( llty) , ty) ;
935
- }
936
-
937
926
let substs = self . monomorphize ( & substs) ;
938
927
let instance = Instance :: new ( def_id, substs) ;
939
928
MirConstContext :: trans_def ( bcx. ccx , instance, IndexVec :: new ( ) )
0 commit comments