@@ -5,7 +5,6 @@ use std::convert::TryFrom;
55use rustc_middle:: mir;
66use rustc_middle:: ty:: { self , TyCtxt } ;
77use rustc_span:: { source_map:: DUMMY_SP , symbol:: Symbol } ;
8- use rustc_target:: abi:: VariantIdx ;
98
109use crate :: interpret:: { intern_const_alloc_recursive, ConstValue , InternKind , InterpCx } ;
1110
@@ -19,32 +18,6 @@ pub use eval_queries::*;
1918pub use fn_queries:: * ;
2019pub use machine:: * ;
2120
22- /// Extracts a field of a (variant of a) const.
23- // this function uses `unwrap` copiously, because an already validated constant must have valid
24- // fields and can thus never fail outside of compiler bugs
25- pub ( crate ) fn const_field < ' tcx > (
26- tcx : TyCtxt < ' tcx > ,
27- param_env : ty:: ParamEnv < ' tcx > ,
28- variant : Option < VariantIdx > ,
29- field : mir:: Field ,
30- value : & ' tcx ty:: Const < ' tcx > ,
31- ) -> ConstValue < ' tcx > {
32- trace ! ( "const_field: {:?}, {:?}" , field, value) ;
33- let ecx = mk_eval_cx ( tcx, DUMMY_SP , param_env, false ) ;
34- // get the operand again
35- let op = ecx. eval_const_to_op ( value, None ) . unwrap ( ) ;
36- // downcast
37- let down = match variant {
38- None => op,
39- Some ( variant) => ecx. operand_downcast ( op, variant) . unwrap ( ) ,
40- } ;
41- // then project
42- let field = ecx. operand_field ( down, field. index ( ) ) . unwrap ( ) ;
43- // and finally move back to the const world, always normalizing because
44- // this is not called for statics.
45- op_to_const ( & ecx, field)
46- }
47-
4821pub ( crate ) fn const_caller_location (
4922 tcx : TyCtxt < ' tcx > ,
5023 ( file, line, col) : ( Symbol , u32 , u32 ) ,
0 commit comments