@@ -16,7 +16,8 @@ use crate::traits::{
1616} ;
1717use rustc_data_structures:: fx:: FxIndexSet ;
1818use rustc_errors:: Diagnostic ;
19- use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
19+ use rustc_hir:: def_id:: { DefId , CRATE_DEF_ID , LOCAL_CRATE } ;
20+ use rustc_hir:: CRATE_HIR_ID ;
2021use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
2122use rustc_infer:: traits:: util;
2223use rustc_middle:: traits:: specialization_graph:: OverlapMode ;
@@ -395,19 +396,20 @@ fn resolve_negative_obligation<'cx, 'tcx>(
395396 return false ;
396397 }
397398
398- let outlives_env = if let Some ( body_def_id) = body_def_id. as_local ( ) {
399- let body_id = tcx. hir ( ) . local_def_id_to_hir_id ( body_def_id) ;
400- let ocx = ObligationCtxt :: new ( & infcx) ;
401- let wf_tys = ocx. assumed_wf_types ( param_env, DUMMY_SP , body_def_id) ;
402- OutlivesEnvironment :: with_bounds (
403- param_env,
404- Some ( & infcx) ,
405- infcx. implied_bounds_tys ( param_env, body_id, wf_tys) ,
406- )
399+ let ( body_id, body_def_id) = if let Some ( body_def_id) = body_def_id. as_local ( ) {
400+ ( tcx. hir ( ) . local_def_id_to_hir_id ( body_def_id) , body_def_id)
407401 } else {
408- OutlivesEnvironment :: new ( param_env )
402+ ( CRATE_HIR_ID , CRATE_DEF_ID )
409403 } ;
410404
405+ let ocx = ObligationCtxt :: new ( & infcx) ;
406+ let wf_tys = ocx. assumed_wf_types ( param_env, DUMMY_SP , body_def_id) ;
407+ let outlives_env = OutlivesEnvironment :: with_bounds (
408+ param_env,
409+ Some ( & infcx) ,
410+ infcx. implied_bounds_tys ( param_env, body_id, wf_tys) ,
411+ ) ;
412+
411413 infcx. process_registered_region_obligations ( outlives_env. region_bound_pairs ( ) , param_env) ;
412414
413415 infcx. resolve_regions ( & outlives_env) . is_empty ( )
0 commit comments