Skip to content

Commit 8971972

Browse files
committed
De-querify trivial_dropck_outlives.
It's sufficiently simple and fast that memoizing it is a slight pessimization.
1 parent b497e18 commit 8971972

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

src/librustc/query/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,6 @@ rustc_queries! {
228228
cycle_delay_bug
229229
}
230230

231-
query trivial_dropck_outlives(ty: Ty<'tcx>) -> bool {
232-
anon
233-
no_force
234-
desc { "checking if `{:?}` has trivial dropck", ty }
235-
}
236-
237231
query adt_dtorck_constraint(
238232
_: DefId
239233
) -> Result<DtorckConstraint<'tcx>, NoSolution> {}

src/librustc/traits/query/dropck_outlives.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::iter::FromIterator;
55
use syntax::source_map::Span;
66
use crate::ty::subst::GenericArg;
77
use crate::ty::{self, Ty, TyCtxt};
8-
use crate::ty::query::Providers;
98

109
impl<'cx, 'tcx> At<'cx, 'tcx> {
1110
/// Given a type `ty` of some value being dropped, computes a set
@@ -34,7 +33,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> {
3433
// Quick check: there are a number of cases that we know do not require
3534
// any destructor.
3635
let tcx = self.infcx.tcx;
37-
if tcx.trivial_dropck_outlives(ty) {
36+
if trivial_dropck_outlives(tcx, ty) {
3837
return InferOk {
3938
value: vec![],
4039
obligations: vec![],
@@ -208,15 +207,15 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
208207
| ty::Error => true,
209208

210209
// [T; N] and [T] have same properties as T.
211-
ty::Array(ty, _) | ty::Slice(ty) => tcx.trivial_dropck_outlives(ty),
210+
ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty),
212211

213212
// (T1..Tn) and closures have same properties as T1..Tn --
214213
// check if *any* of those are trivial.
215-
ty::Tuple(ref tys) => tys.iter().all(|t| tcx.trivial_dropck_outlives(t.expect_ty())),
214+
ty::Tuple(ref tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t.expect_ty())),
216215
ty::Closure(def_id, ref substs) => substs
217216
.as_closure()
218217
.upvar_tys(def_id, tcx)
219-
.all(|t| tcx.trivial_dropck_outlives(t)),
218+
.all(|t| trivial_dropck_outlives(tcx, t)),
220219

221220
ty::Adt(def, _) => {
222221
if Some(def.did) == tcx.lang_items().manually_drop() {
@@ -244,10 +243,3 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
244243
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
245244
}
246245
}
247-
248-
crate fn provide(p: &mut Providers<'_>) {
249-
*p = Providers {
250-
trivial_dropck_outlives,
251-
..*p
252-
};
253-
}

src/librustc/traits/query/type_op/outlives.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
2-
use crate::traits::query::dropck_outlives::DropckOutlivesResult;
2+
use crate::traits::query::dropck_outlives::{DropckOutlivesResult, trivial_dropck_outlives};
33
use crate::traits::query::Fallible;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
55

@@ -21,7 +21,7 @@ impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
2121
tcx: TyCtxt<'tcx>,
2222
key: &ParamEnvAnd<'tcx, Self>,
2323
) -> Option<Self::QueryResponse> {
24-
if tcx.trivial_dropck_outlives(key.value.dropped_ty) {
24+
if trivial_dropck_outlives(tcx, key.value.dropped_ty) {
2525
Some(DropckOutlivesResult::default())
2626
} else {
2727
None

src/librustc/ty/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,6 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
34073407
layout::provide(providers);
34083408
util::provide(providers);
34093409
constness::provide(providers);
3410-
crate::traits::query::dropck_outlives::provide(providers);
34113410
*providers = ty::query::Providers {
34123411
asyncness,
34133412
associated_item,

src/librustc_traits/dropck_outlives.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc::hir::def_id::DefId;
22
use rustc::infer::canonical::{Canonical, QueryResponse};
33
use rustc::traits::query::dropck_outlives::{DropckOutlivesResult, DtorckConstraint};
4+
use rustc::traits::query::dropck_outlives::trivial_dropck_outlives;
45
use rustc::traits::query::{CanonicalTyGoal, NoSolution};
56
use rustc::traits::{TraitEngine, Normalized, ObligationCause, TraitEngineExt};
67
use rustc::ty::query::Providers;
@@ -172,7 +173,7 @@ fn dtorck_constraint_for_ty<'tcx>(
172173
return Ok(());
173174
}
174175

175-
if tcx.trivial_dropck_outlives(ty) {
176+
if trivial_dropck_outlives(tcx, ty) {
176177
return Ok(());
177178
}
178179

0 commit comments

Comments
 (0)