Auto merge of #99743 - compiler-errors:fulfillment-context-cleanups, r=jackh726
Some `FulfillmentContext`-related cleanups Use `ObligationCtxt` in some places, remove some `FulfillmentContext`s in others... r? types
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
use hir::LangItem;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::traits::TraitEngine;
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_infer::traits::{Obligation, SelectionError, TraitObligation};
|
||||
use rustc_lint_defs::builtin::DEREF_INTO_DYN_SUPERTRAIT;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
@@ -706,8 +706,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
fn need_migrate_deref_output_trait_object(
|
||||
&mut self,
|
||||
ty: Ty<'tcx>,
|
||||
cause: &traits::ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
) -> Option<(Ty<'tcx>, DefId)> {
|
||||
let tcx = self.tcx();
|
||||
if tcx.features().trait_upcasting {
|
||||
@@ -729,24 +729,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut fulfillcx = traits::FulfillmentContext::new_in_snapshot();
|
||||
let normalized_ty = fulfillcx.normalize_projection_type(
|
||||
&self.infcx,
|
||||
let ty = traits::normalize_projection_type(
|
||||
self,
|
||||
param_env,
|
||||
ty::ProjectionTy {
|
||||
item_def_id: tcx.lang_items().deref_target()?,
|
||||
substs: trait_ref.substs,
|
||||
},
|
||||
cause.clone(),
|
||||
);
|
||||
0,
|
||||
// We're *intentionally* throwing these away,
|
||||
// since we don't actually use them.
|
||||
&mut vec![],
|
||||
)
|
||||
.ty()
|
||||
.unwrap();
|
||||
|
||||
let ty::Dynamic(data, ..) = normalized_ty.kind() else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let def_id = data.principal_def_id()?;
|
||||
|
||||
return Some((normalized_ty, def_id));
|
||||
if let ty::Dynamic(data, ..) = ty.kind() {
|
||||
Some((ty, data.principal_def_id()?))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Searches for unsizing that might apply to `obligation`.
|
||||
@@ -809,8 +812,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
if let Some((deref_output_ty, deref_output_trait_did)) = self
|
||||
.need_migrate_deref_output_trait_object(
|
||||
source,
|
||||
&obligation.cause,
|
||||
obligation.param_env,
|
||||
&obligation.cause,
|
||||
)
|
||||
{
|
||||
if deref_output_trait_did == target_trait_did {
|
||||
|
||||
Reference in New Issue
Block a user