@@ -5,6 +5,7 @@ use rustc_abi as abi;
5
5
use rustc_abi:: Primitive :: Pointer ;
6
6
use rustc_abi:: { AddressSpace , HasDataLayout } ;
7
7
use rustc_ast:: Mutability ;
8
+ use rustc_codegen_ssa:: common:: TypeKind ;
8
9
use rustc_codegen_ssa:: traits:: * ;
9
10
use rustc_data_structures:: stable_hasher:: { Hash128 , HashStable , StableHasher } ;
10
11
use rustc_hir:: def_id:: DefId ;
@@ -146,6 +147,7 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
146
147
}
147
148
148
149
fn const_int ( & self , t : & ' ll Type , i : i64 ) -> & ' ll Value {
150
+ assert ! ( self . type_kind( t) == TypeKind :: Integer , "only allows integer types in const_int" ) ;
149
151
unsafe { llvm:: LLVMConstInt ( t, i as u64 , True ) }
150
152
}
151
153
@@ -176,10 +178,12 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
176
178
}
177
179
178
180
fn const_uint ( & self , t : & ' ll Type , i : u64 ) -> & ' ll Value {
181
+ assert ! ( self . type_kind( t) == TypeKind :: Integer , "only allows integer types in const_uint" ) ;
179
182
unsafe { llvm:: LLVMConstInt ( t, i, False ) }
180
183
}
181
184
182
185
fn const_uint_big ( & self , t : & ' ll Type , u : u128 ) -> & ' ll Value {
186
+ assert ! ( self . type_kind( t) == TypeKind :: Integer , "only allows integer types in const_uint_big" ) ;
183
187
unsafe {
184
188
let words = [ u as u64 , ( u >> 64 ) as u64 ] ;
185
189
llvm:: LLVMConstIntOfArbitraryPrecision ( t, 2 , words. as_ptr ( ) )
0 commit comments