Auto merge of #95280 - InfRandomness:infrandomness/Dtorck_clarification, r=oli-obk

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.

Fixes https://github.com/rust-lang/rust/issues/94310
This commit is contained in:
bors 2022-03-25 14:16:13 +00:00
commit 09be68c869
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>>
>
>,
[] dtorck_constraint: rustc_middle::traits::query::DtorckConstraint<'tcx>,
[] dtorck_constraint: rustc_middle::traits::query::DropckConstraint<'tcx>,
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
[] type_op_subtype:

View File

@ -549,7 +549,7 @@ rustc_queries! {
query adt_dtorck_constraint(
key: DefId
) -> Result<&'tcx DtorckConstraint<'tcx>, NoSolution> {
) -> Result<&'tcx DropckConstraint<'tcx>, NoSolution> {
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 type to be valid for destruction.
#[derive(Clone, Debug, HashStable)]
pub struct DtorckConstraint<'tcx> {
pub struct DropckConstraint<'tcx> {
/// Types that are required to be alive in order for this
/// type to be valid for destruction.
pub outlives: Vec<ty::subst::GenericArg<'tcx>>,
@ -157,17 +157,17 @@ pub struct DtorckConstraint<'tcx> {
pub overflows: Vec<Ty<'tcx>>,
}
impl<'tcx> DtorckConstraint<'tcx> {
pub fn empty() -> DtorckConstraint<'tcx> {
DtorckConstraint { outlives: vec![], dtorck_types: vec![], overflows: vec![] }
impl<'tcx> DropckConstraint<'tcx> {
pub fn empty() -> DropckConstraint<'tcx> {
DropckConstraint { outlives: vec![], dtorck_types: vec![], overflows: vec![] }
}
}
impl<'tcx> FromIterator<DtorckConstraint<'tcx>> for DtorckConstraint<'tcx> {
fn from_iter<I: IntoIterator<Item = DtorckConstraint<'tcx>>>(iter: I) -> Self {
impl<'tcx> FromIterator<DropckConstraint<'tcx>> for DropckConstraint<'tcx> {
fn from_iter<I: IntoIterator<Item = DropckConstraint<'tcx>>>(iter: I) -> Self {
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.dtorck_types.extend(dtorck_types);
result.overflows.extend(overflows);

View File

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