introduce DropckOutlives
type-op
This commit is contained in:
parent
7a641cb145
commit
252a6dfa35
src/librustc_mir/borrow_check/nll/type_check
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use borrow_check::nll::region_infer::Cause;
|
||||
use borrow_check::nll::type_check::type_op::CustomTypeOp;
|
||||
use borrow_check::nll::type_check::type_op::DropckOutlives;
|
||||
use borrow_check::nll::type_check::AtLocation;
|
||||
use dataflow::move_paths::{HasMoveData, MoveData};
|
||||
use dataflow::MaybeInitializedPlaces;
|
||||
@ -17,7 +17,6 @@ use dataflow::{FlowAtLocation, FlowsAtLocation};
|
||||
use rustc::infer::region_constraints::RegionConstraintData;
|
||||
use rustc::mir::Local;
|
||||
use rustc::mir::{BasicBlock, Location, Mir};
|
||||
use rustc::traits::ObligationCause;
|
||||
use rustc::ty::subst::Kind;
|
||||
use rustc::ty::{Ty, TypeFoldable};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
@ -217,15 +216,11 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
|
||||
) -> DropData<'tcx> {
|
||||
debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,);
|
||||
|
||||
let param_env = cx.param_env;
|
||||
let (dropped_kinds, region_constraint_data) =
|
||||
cx.fully_perform_op_and_get_region_constraint_data(CustomTypeOp::new(
|
||||
|cx| {
|
||||
Ok(cx
|
||||
.infcx
|
||||
.at(&ObligationCause::dummy(), cx.param_env)
|
||||
.dropck_outlives(dropped_ty))
|
||||
},
|
||||
|| format!("compute_drop_data(dropped_ty={:?})", dropped_ty),
|
||||
cx.fully_perform_op_and_get_region_constraint_data(DropckOutlives::new(
|
||||
param_env,
|
||||
dropped_ty,
|
||||
)).unwrap();
|
||||
|
||||
DropData {
|
||||
|
@ -13,6 +13,7 @@ use rustc::infer::{InferCtxt, InferOk, InferResult};
|
||||
use rustc::traits::query::NoSolution;
|
||||
use rustc::traits::{Normalized, Obligation, ObligationCause, PredicateObligation};
|
||||
use rustc::ty::fold::TypeFoldable;
|
||||
use rustc::ty::subst::Kind;
|
||||
use rustc::ty::{ParamEnv, Predicate, Ty};
|
||||
use std::fmt;
|
||||
|
||||
@ -242,3 +243,32 @@ where
|
||||
Ok(InferOk { value, obligations })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct DropckOutlives<'tcx> {
|
||||
param_env: ParamEnv<'tcx>,
|
||||
dropped_ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> DropckOutlives<'tcx> {
|
||||
pub(super) fn new(
|
||||
param_env: ParamEnv<'tcx>,
|
||||
dropped_ty: Ty<'tcx>,
|
||||
) -> Self {
|
||||
DropckOutlives { param_env, dropped_ty }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gcx, 'tcx> InfcxTypeOp<'gcx, 'tcx> for DropckOutlives<'tcx> {
|
||||
type Output = Vec<Kind<'tcx>>;
|
||||
|
||||
fn trivial_noop(self) -> Result<Self::Output, Self> {
|
||||
Err(self)
|
||||
}
|
||||
|
||||
fn perform(self, infcx: &InferCtxt<'_, 'gcx, 'tcx>) -> InferResult<'tcx, Self::Output> {
|
||||
Ok(infcx
|
||||
.at(&ObligationCause::dummy(), self.param_env)
|
||||
.dropck_outlives(self.dropped_ty))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user