pub fn codegen_fulfill_obligation<'tcx>(
tcx: TyCtxt<'tcx>,
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
-) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
+) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorReported> {
// 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.
Err(Unimplemented) => {
// This can trigger when we probe for the source of a `'static` lifetime requirement
// on a trait object: `impl Foo for dyn Trait {}` has an implicit `'static` bound.
+ // This can also trigger when we have a global bound that is not actually satisfied,
+ // but was included during typeck due to the trivial_bounds feature.
infcx.tcx.sess.delay_span_bug(
rustc_span::DUMMY_SP,
&format!(
});
let impl_source = drain_fulfillment_cx_or_panic(&infcx, &mut fulfill_cx, impl_source);
- // We may constrain the hidden types of opaque types in this query, but this is
- // not information our callers need, as all that information is handled by borrowck
- // and typeck.
- drop(infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types());
-
debug!("Cache miss: {:?} => {:?}", trait_ref, impl_source);
- Ok(impl_source)
+ Ok(&*tcx.arena.alloc(impl_source))
})
}