diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2022-08-23 09:08:30 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2022-08-23 09:08:30 -0300 |
| commit | 4da14ef50eb697298f36d41f91cb02dc800275bf (patch) | |
| tree | c4c0e089710c7b0d9703f8dc00e6994e7d9a0610 | |
| parent | 4cb492e7408c9c54fbc9e6ad5a13af650514c715 (diff) | |
| download | rust-4da14ef50eb697298f36d41f91cb02dc800275bf.tar.gz rust-4da14ef50eb697298f36d41f91cb02dc800275bf.zip | |
Use CRATE_HIR_ID and CRATE_DEF_ID for obligations from foreign crates
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/coherence.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index f09be12b84d..292787d4dbb 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -16,7 +16,8 @@ use crate::traits::{ }; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::Diagnostic; -use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE}; +use rustc_hir::CRATE_HIR_ID; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; use rustc_infer::traits::util; use rustc_middle::traits::specialization_graph::OverlapMode; @@ -395,19 +396,20 @@ fn resolve_negative_obligation<'cx, 'tcx>( return false; } - let outlives_env = if let Some(body_def_id) = body_def_id.as_local() { - let body_id = tcx.hir().local_def_id_to_hir_id(body_def_id); - let ocx = ObligationCtxt::new(&infcx); - let wf_tys = ocx.assumed_wf_types(param_env, DUMMY_SP, body_def_id); - OutlivesEnvironment::with_bounds( - param_env, - Some(&infcx), - infcx.implied_bounds_tys(param_env, body_id, wf_tys), - ) + let (body_id, body_def_id) = if let Some(body_def_id) = body_def_id.as_local() { + (tcx.hir().local_def_id_to_hir_id(body_def_id), body_def_id) } else { - OutlivesEnvironment::new(param_env) + (CRATE_HIR_ID, CRATE_DEF_ID) }; + let ocx = ObligationCtxt::new(&infcx); + let wf_tys = ocx.assumed_wf_types(param_env, DUMMY_SP, body_def_id); + let outlives_env = OutlivesEnvironment::with_bounds( + param_env, + Some(&infcx), + infcx.implied_bounds_tys(param_env, body_id, wf_tys), + ); + infcx.process_registered_region_obligations(outlives_env.region_bound_pairs(), param_env); infcx.resolve_regions(&outlives_env).is_empty() |
