Remove unnecessary FulfillmentContext from need_migrate_deref_output_trait_object
This commit is contained in:
parent
37d412cff7
commit
61d9b1656d
1 changed files with 18 additions and 20 deletions
|
@ -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,7 +706,6 @@ 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>,
|
||||
) -> Option<(Ty<'tcx>, DefId)> {
|
||||
let tcx = self.tcx();
|
||||
|
@ -721,7 +720,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
};
|
||||
|
||||
let obligation = traits::Obligation::new(
|
||||
cause.clone(),
|
||||
ObligationCause::dummy(),
|
||||
param_env,
|
||||
ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
|
||||
);
|
||||
|
@ -729,24 +728,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(),
|
||||
);
|
||||
ObligationCause::dummy(),
|
||||
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`.
|
||||
|
@ -807,11 +809,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let target_trait_did = principal_def_id_b.unwrap();
|
||||
let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
|
||||
if let Some((deref_output_ty, deref_output_trait_did)) = self
|
||||
.need_migrate_deref_output_trait_object(
|
||||
source,
|
||||
&obligation.cause,
|
||||
obligation.param_env,
|
||||
)
|
||||
.need_migrate_deref_output_trait_object(source, obligation.param_env)
|
||||
{
|
||||
if deref_output_trait_did == target_trait_did {
|
||||
self.tcx().struct_span_lint_hir(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue