Swap DtorckConstraint to DropckConstraint

This change was made as per suspicion that this struct was never renamed after consistent use of DropCk.

This also clarifies the meaning behind the name of this structure.
This commit is contained in:
InfRandomness 2022-03-24 19:21:41 +01:00
parent 8d8135f003
commit 645620b3b3
6 changed files with 19 additions and 19 deletions

View File

@ -52,7 +52,7 @@ macro_rules! arena_types {
Vec<rustc_middle::traits::query::OutlivesBound<'tcx>> Vec<rustc_middle::traits::query::OutlivesBound<'tcx>>
> >
>, >,
[] dtorck_constraint: rustc_middle::traits::query::DtorckConstraint<'tcx>, [] dtorck_constraint: rustc_middle::traits::query::DropckConstraint<'tcx>,
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>, [] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>, [] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
[] type_op_subtype: [] type_op_subtype:

View File

@ -549,7 +549,7 @@ rustc_queries! {
query adt_dtorck_constraint( query adt_dtorck_constraint(
key: DefId key: DefId
) -> Result<&'tcx DtorckConstraint<'tcx>, NoSolution> { ) -> Result<&'tcx DropckConstraint<'tcx>, NoSolution> {
desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) } desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
} }

View File

@ -143,7 +143,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
/// A set of constraints that need to be satisfied in order for /// A set of constraints that need to be satisfied in order for
/// a type to be valid for destruction. /// a type to be valid for destruction.
#[derive(Clone, Debug, HashStable)] #[derive(Clone, Debug, HashStable)]
pub struct DtorckConstraint<'tcx> { pub struct DropckConstraint<'tcx> {
/// Types that are required to be alive in order for this /// Types that are required to be alive in order for this
/// type to be valid for destruction. /// type to be valid for destruction.
pub outlives: Vec<ty::subst::GenericArg<'tcx>>, pub outlives: Vec<ty::subst::GenericArg<'tcx>>,
@ -157,17 +157,17 @@ pub struct DtorckConstraint<'tcx> {
pub overflows: Vec<Ty<'tcx>>, pub overflows: Vec<Ty<'tcx>>,
} }
impl<'tcx> DtorckConstraint<'tcx> { impl<'tcx> DropckConstraint<'tcx> {
pub fn empty() -> DtorckConstraint<'tcx> { pub fn empty() -> DropckConstraint<'tcx> {
DtorckConstraint { outlives: vec![], dtorck_types: vec![], overflows: vec![] } DropckConstraint { outlives: vec![], dtorck_types: vec![], overflows: vec![] }
} }
} }
impl<'tcx> FromIterator<DtorckConstraint<'tcx>> for DtorckConstraint<'tcx> { impl<'tcx> FromIterator<DropckConstraint<'tcx>> for DropckConstraint<'tcx> {
fn from_iter<I: IntoIterator<Item = DtorckConstraint<'tcx>>>(iter: I) -> Self { fn from_iter<I: IntoIterator<Item = DropckConstraint<'tcx>>>(iter: I) -> Self {
let mut result = Self::empty(); let mut result = Self::empty();
for DtorckConstraint { outlives, dtorck_types, overflows } in iter { for DropckConstraint { outlives, dtorck_types, overflows } in iter {
result.outlives.extend(outlives); result.outlives.extend(outlives);
result.dtorck_types.extend(dtorck_types); result.dtorck_types.extend(dtorck_types);
result.overflows.extend(overflows); result.overflows.extend(overflows);

View File

@ -23,7 +23,7 @@ use crate::traits::query::{
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, NoSolution, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, NoSolution,
}; };
use crate::traits::query::{ use crate::traits::query::{
DropckOutlivesResult, DtorckConstraint, MethodAutoderefStepsResult, NormalizationResult, DropckConstraint, DropckOutlivesResult, MethodAutoderefStepsResult, NormalizationResult,
OutlivesBound, OutlivesBound,
}; };
use crate::traits::specialization_graph; use crate::traits::specialization_graph;

View File

@ -5,7 +5,7 @@ use crate::infer::InferOk;
use rustc_middle::ty::subst::GenericArg; use rustc_middle::ty::subst::GenericArg;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
pub use rustc_middle::traits::query::{DropckOutlivesResult, DtorckConstraint}; pub use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
pub trait AtExt<'tcx> { pub trait AtExt<'tcx> {
fn dropck_outlives(&self, ty: Ty<'tcx>) -> InferOk<'tcx, Vec<GenericArg<'tcx>>>; fn dropck_outlives(&self, ty: Ty<'tcx>) -> InferOk<'tcx, Vec<GenericArg<'tcx>>>;

View File

@ -9,7 +9,7 @@ use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt};
use rustc_span::source_map::{Span, DUMMY_SP}; use rustc_span::source_map::{Span, DUMMY_SP};
use rustc_trait_selection::traits::query::dropck_outlives::trivial_dropck_outlives; use rustc_trait_selection::traits::query::dropck_outlives::trivial_dropck_outlives;
use rustc_trait_selection::traits::query::dropck_outlives::{ use rustc_trait_selection::traits::query::dropck_outlives::{
DropckOutlivesResult, DtorckConstraint, DropckConstraint, DropckOutlivesResult,
}; };
use rustc_trait_selection::traits::query::normalize::AtExt; use rustc_trait_selection::traits::query::normalize::AtExt;
use rustc_trait_selection::traits::query::{CanonicalTyGoal, NoSolution}; use rustc_trait_selection::traits::query::{CanonicalTyGoal, NoSolution};
@ -78,7 +78,7 @@ fn dropck_outlives<'tcx>(
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx); let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
let cause = ObligationCause::dummy(); let cause = ObligationCause::dummy();
let mut constraints = DtorckConstraint::empty(); let mut constraints = DropckConstraint::empty();
while let Some((ty, depth)) = ty_stack.pop() { while let Some((ty, depth)) = ty_stack.pop() {
debug!( debug!(
"{} kinds, {} overflows, {} ty_stack", "{} kinds, {} overflows, {} ty_stack",
@ -159,7 +159,7 @@ fn dtorck_constraint_for_ty<'tcx>(
for_ty: Ty<'tcx>, for_ty: Ty<'tcx>,
depth: usize, depth: usize,
ty: Ty<'tcx>, ty: Ty<'tcx>,
constraints: &mut DtorckConstraint<'tcx>, constraints: &mut DropckConstraint<'tcx>,
) -> Result<(), NoSolution> { ) -> Result<(), NoSolution> {
debug!("dtorck_constraint_for_ty({:?}, {:?}, {:?}, {:?})", span, for_ty, depth, ty); debug!("dtorck_constraint_for_ty({:?}, {:?}, {:?}, {:?})", span, for_ty, depth, ty);
@ -267,7 +267,7 @@ fn dtorck_constraint_for_ty<'tcx>(
} }
ty::Adt(def, substs) => { ty::Adt(def, substs) => {
let DtorckConstraint { dtorck_types, outlives, overflows } = let DropckConstraint { dtorck_types, outlives, overflows } =
tcx.at(span).adt_dtorck_constraint(def.did())?; tcx.at(span).adt_dtorck_constraint(def.did())?;
// FIXME: we can try to recursively `dtorck_constraint_on_ty` // FIXME: we can try to recursively `dtorck_constraint_on_ty`
// there, but that needs some way to handle cycles. // there, but that needs some way to handle cycles.
@ -301,7 +301,7 @@ fn dtorck_constraint_for_ty<'tcx>(
crate fn adt_dtorck_constraint( crate fn adt_dtorck_constraint(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
def_id: DefId, def_id: DefId,
) -> Result<&DtorckConstraint<'_>, NoSolution> { ) -> Result<&DropckConstraint<'_>, NoSolution> {
let def = tcx.adt_def(def_id); let def = tcx.adt_def(def_id);
let span = tcx.def_span(def_id); let span = tcx.def_span(def_id);
debug!("dtorck_constraint: {:?}", def); debug!("dtorck_constraint: {:?}", def);
@ -311,7 +311,7 @@ crate fn adt_dtorck_constraint(
// `PhantomData`. // `PhantomData`.
let substs = InternalSubsts::identity_for_item(tcx, def_id); let substs = InternalSubsts::identity_for_item(tcx, def_id);
assert_eq!(substs.len(), 1); assert_eq!(substs.len(), 1);
let result = DtorckConstraint { let result = DropckConstraint {
outlives: vec![], outlives: vec![],
dtorck_types: vec![substs.type_at(0)], dtorck_types: vec![substs.type_at(0)],
overflows: vec![], overflows: vec![],
@ -320,7 +320,7 @@ crate fn adt_dtorck_constraint(
return Ok(tcx.arena.alloc(result)); return Ok(tcx.arena.alloc(result));
} }
let mut result = DtorckConstraint::empty(); let mut result = DropckConstraint::empty();
for field in def.all_fields() { for field in def.all_fields() {
let fty = tcx.type_of(field.did); let fty = tcx.type_of(field.did);
dtorck_constraint_for_ty(tcx, span, fty, 0, fty, &mut result)?; dtorck_constraint_for_ty(tcx, span, fty, 0, fty, &mut result)?;
@ -333,7 +333,7 @@ crate fn adt_dtorck_constraint(
Ok(tcx.arena.alloc(result)) Ok(tcx.arena.alloc(result))
} }
fn dedup_dtorck_constraint(c: &mut DtorckConstraint<'_>) { fn dedup_dtorck_constraint(c: &mut DropckConstraint<'_>) {
let mut outlives = FxHashSet::default(); let mut outlives = FxHashSet::default();
let mut dtorck_types = FxHashSet::default(); let mut dtorck_types = FxHashSet::default();