use syntax::source_map::Span;
use crate::ty::subst::GenericArg;
use crate::ty::{self, Ty, TyCtxt};
-use crate::ty::query::Providers;
+
+use rustc_error_codes::*;
impl<'cx, 'tcx> At<'cx, 'tcx> {
/// Given a type `ty` of some value being dropped, computes a set
// Quick check: there are a number of cases that we know do not require
// any destructor.
let tcx = self.infcx.tcx;
- if tcx.trivial_dropck_outlives(ty) {
+ if trivial_dropck_outlives(tcx, ty) {
return InferOk {
value: vec![],
obligations: vec![],
}
}
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, HashStable, TypeFoldable, Lift)]
pub struct DropckOutlivesResult<'tcx> {
pub kinds: Vec<GenericArg<'tcx>>,
pub overflows: Vec<Ty<'tcx>>,
/// A set of constraints that need to be satisfied in order for
/// a type to be valid for destruction.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, HashStable)]
pub struct DtorckConstraint<'tcx> {
/// Types that are required to be alive in order for this
/// type to be valid for destruction.
result
}
}
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for DropckOutlivesResult<'tcx> {
- kinds, overflows
- }
-}
-
-BraceStructLiftImpl! {
- impl<'a, 'tcx> Lift<'tcx> for DropckOutlivesResult<'a> {
- type Lifted = DropckOutlivesResult<'tcx>;
- kinds, overflows
- }
-}
-
-impl_stable_hash_for!(struct DropckOutlivesResult<'tcx> {
- kinds, overflows
-});
-
-impl_stable_hash_for!(struct DtorckConstraint<'tcx> {
- outlives,
- dtorck_types,
- overflows
-});
/// This returns true if the type `ty` is "trivial" for
/// dropck-outlives -- that is, if it doesn't require any types to
| ty::Error => true,
// [T; N] and [T] have same properties as T.
- ty::Array(ty, _) | ty::Slice(ty) => tcx.trivial_dropck_outlives(ty),
+ ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty),
// (T1..Tn) and closures have same properties as T1..Tn --
// check if *any* of those are trivial.
- ty::Tuple(ref tys) => tys.iter().all(|t| tcx.trivial_dropck_outlives(t.expect_ty())),
+ ty::Tuple(ref tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t.expect_ty())),
ty::Closure(def_id, ref substs) => substs
.as_closure()
.upvar_tys(def_id, tcx)
- .all(|t| tcx.trivial_dropck_outlives(t)),
+ .all(|t| trivial_dropck_outlives(tcx, t)),
ty::Adt(def, _) => {
if Some(def.did) == tcx.lang_items().manually_drop() {
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
}
}
-
-crate fn provide(p: &mut Providers<'_>) {
- *p = Providers {
- trivial_dropck_outlives,
- ..*p
- };
-}