Rollup merge of #99156 - lcnr:omoe-wa, r=wesleywiser

`codegen_fulfill_obligation` expect erased regions

it's a query, so by erasing regions before calling it, we get better caching.
This doesn't actually change anything as its already the status quo.
This commit is contained in:
Matthias Krüger 2022-08-02 07:30:39 +02:00 committed by GitHub
commit 0629445300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -8,7 +8,7 @@ pub use self::ValuePairs::*;
use self::opaque_types::OpaqueTypeStorage;
pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};
use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};
use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine, TraitEngineExt};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
@ -645,9 +645,7 @@ impl<'tcx, T> InferOk<'tcx, T> {
fulfill_cx: &mut dyn TraitEngine<'tcx>,
) -> T {
let InferOk { value, obligations } = self;
for obligation in obligations {
fulfill_cx.register_predicate_obligation(infcx, obligation);
}
fulfill_cx.register_predicate_obligations(infcx, obligations);
value
}
}

View File

@ -23,8 +23,6 @@ pub fn codegen_fulfill_obligation<'tcx>(
tcx: TyCtxt<'tcx>,
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> {
// Remove any references to regions; this helps improve caching.
let trait_ref = tcx.erase_regions(trait_ref);
// We expect the input to be fully normalized.
debug_assert_eq!(trait_ref, tcx.normalize_erasing_regions(param_env, trait_ref));