@@ -20,7 +20,7 @@ use polonius_engine::Atom;
2020use rustc_ast:: ast:: { self , Ident } ;
2121use rustc_data_structures:: captures:: Captures ;
2222use rustc_hir as hir;
23- use rustc_hir:: def_id:: DefId ;
23+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
2424use rustc_index:: vec:: Idx ;
2525use rustc_macros:: HashStable ;
2626use rustc_span:: symbol:: { kw, Symbol } ;
@@ -2404,15 +2404,17 @@ static_assert_size!(Const<'_>, 48);
24042404impl < ' tcx > Const < ' tcx > {
24052405 /// Literals and const generic parameters are eagerly converted to a constant, everything else
24062406 /// becomes `Unevaluated`.
2407- pub fn from_hir_anon_const ( tcx : TyCtxt < ' tcx > , def_id : DefId , ty : Ty < ' tcx > ) -> & ' tcx Self {
2408- debug ! ( "Const::from_hir_anon_const (id={:?})" , def_id) ;
2407+ pub fn from_anon_const ( tcx : TyCtxt < ' tcx > , def_id : LocalDefId ) -> & ' tcx Self {
2408+ debug ! ( "Const::from_anon_const (id={:?})" , def_id) ;
24092409
2410- let hir_id = tcx. hir ( ) . as_local_hir_id ( def_id) . unwrap ( ) ;
2410+ let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
24112411
24122412 let body_id = tcx. hir ( ) . body_owned_by ( hir_id) ;
24132413
24142414 let expr = & tcx. hir ( ) . body ( body_id) . value ;
24152415
2416+ let ty = tcx. type_of ( def_id. to_def_id ( ) ) ;
2417+
24162418 let lit_input = match expr. kind {
24172419 hir:: ExprKind :: Lit ( ref lit) => Some ( LitToConstInput { lit : & lit. node , ty, neg : false } ) ,
24182420 hir:: ExprKind :: Unary ( hir:: UnOp :: UnNeg , ref expr) => match expr. kind {
@@ -2457,8 +2459,8 @@ impl<'tcx> Const<'tcx> {
24572459 ty:: ConstKind :: Param ( ty:: ParamConst :: new ( index, name) )
24582460 }
24592461 _ => ty:: ConstKind :: Unevaluated (
2460- def_id,
2461- InternalSubsts :: identity_for_item ( tcx, def_id) ,
2462+ def_id. to_def_id ( ) ,
2463+ InternalSubsts :: identity_for_item ( tcx, def_id. to_def_id ( ) ) ,
24622464 None ,
24632465 ) ,
24642466 } ;
0 commit comments