ty/instance: use ParamEnvAnd
in the resolve_instance
query.
This commit is contained in:
parent
339a938fa6
commit
0b83a5a8ae
4 changed files with 16 additions and 16 deletions
|
@ -1258,8 +1258,10 @@ rustc_queries! {
|
|||
desc { "looking up enabled feature gates" }
|
||||
}
|
||||
|
||||
query resolve_instance(key: (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>)) -> Option<ty::Instance<'tcx>> {
|
||||
desc { "resolving instance `{:?}` `{:?}` with {:?}", key.1, key.2, key.0 }
|
||||
query resolve_instance(
|
||||
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
|
||||
) -> Option<ty::Instance<'tcx>> {
|
||||
desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,7 +290,14 @@ impl<'tcx> Instance<'tcx> {
|
|||
) -> Option<Instance<'tcx>> {
|
||||
// All regions in the result of this query are erased, so it's
|
||||
// fine to erase all of the input regions.
|
||||
tcx.resolve_instance((tcx.erase_regions(¶m_env), def_id, tcx.erase_regions(&substs)))
|
||||
|
||||
// HACK(eddyb) erase regions in `substs` first, so that `param_env.and(...)`
|
||||
// below is more likely to ignore the bounds in scope (e.g. if the only
|
||||
// generic parameters mentioned by `substs` were lifetime ones).
|
||||
let substs = tcx.erase_regions(&substs);
|
||||
|
||||
// FIXME(eddyb) should this always use `param_env.with_reveal_all()`?
|
||||
tcx.resolve_instance(tcx.erase_regions(¶m_env.and((def_id, substs))))
|
||||
}
|
||||
|
||||
pub fn resolve_for_fn_ptr(
|
||||
|
|
|
@ -296,14 +296,3 @@ impl Key for (Symbol, u32, u32) {
|
|||
DUMMY_SP
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Key for (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>) {
|
||||
type CacheSelector = DefaultCacheSelector;
|
||||
|
||||
fn query_crate(&self) -> CrateNum {
|
||||
self.1.krate
|
||||
}
|
||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
tcx.def_span(self.1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,12 @@ use traits::{translate_substs, Reveal};
|
|||
|
||||
use log::debug;
|
||||
|
||||
pub fn resolve_instance<'tcx>(
|
||||
fn resolve_instance<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
(param_env, def_id, substs): (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>),
|
||||
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>,
|
||||
) -> Option<Instance<'tcx>> {
|
||||
let (param_env, (def_id, substs)) = key.into_parts();
|
||||
|
||||
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
|
||||
let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
|
||||
debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env);
|
||||
|
|
Loading…
Add table
Reference in a new issue