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) }
}
}
}
) -> 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(
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)
- }
-}
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);