@@ -20,7 +20,7 @@ use polonius_engine::Atom;
20
20
use rustc_ast:: ast:: { self , Ident } ;
21
21
use rustc_data_structures:: captures:: Captures ;
22
22
use rustc_hir as hir;
23
- use rustc_hir:: def_id:: DefId ;
23
+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
24
24
use rustc_index:: vec:: Idx ;
25
25
use rustc_macros:: HashStable ;
26
26
use rustc_span:: symbol:: { kw, Symbol } ;
@@ -2404,15 +2404,17 @@ static_assert_size!(Const<'_>, 48);
2404
2404
impl < ' tcx > Const < ' tcx > {
2405
2405
/// Literals and const generic parameters are eagerly converted to a constant, everything else
2406
2406
/// 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) ;
2409
2409
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) ;
2411
2411
2412
2412
let body_id = tcx. hir ( ) . body_owned_by ( hir_id) ;
2413
2413
2414
2414
let expr = & tcx. hir ( ) . body ( body_id) . value ;
2415
2415
2416
+ let ty = tcx. type_of ( def_id. to_def_id ( ) ) ;
2417
+
2416
2418
let lit_input = match expr. kind {
2417
2419
hir:: ExprKind :: Lit ( ref lit) => Some ( LitToConstInput { lit : & lit. node , ty, neg : false } ) ,
2418
2420
hir:: ExprKind :: Unary ( hir:: UnOp :: UnNeg , ref expr) => match expr. kind {
@@ -2457,8 +2459,8 @@ impl<'tcx> Const<'tcx> {
2457
2459
ty:: ConstKind :: Param ( ty:: ParamConst :: new ( index, name) )
2458
2460
}
2459
2461
_ => 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 ( ) ) ,
2462
2464
None ,
2463
2465
) ,
2464
2466
} ;
0 commit comments