Skip to content

Commit 96b819a

Browse files
committed
Inline a trivial function
1 parent 759c04a commit 96b819a

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

compiler/rustc_infer/src/infer/outlives/obligations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ where
343343
// These are guaranteed to apply, no matter the inference
344344
// results.
345345
let trait_bounds: Vec<_> =
346-
self.verify_bound.projection_declared_bounds_from_trait(projection_ty).collect();
346+
self.verify_bound.bounds(projection_ty.item_def_id, projection_ty.substs).collect();
347347

348348
debug!(?trait_bounds);
349349

@@ -369,7 +369,7 @@ where
369369
match *bound.0.kind() {
370370
ty::Projection(projection_ty) => self
371371
.verify_bound
372-
.projection_declared_bounds_from_trait(projection_ty)
372+
.bounds(projection_ty.item_def_id, projection_ty.substs)
373373
.all(|r| r != bound.1),
374374

375375
_ => panic!("expected only projection types from env, not {:?}", bound.0),

compiler/rustc_infer/src/infer/outlives/verify.rs

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_data_structures::captures::Captures;
66
use rustc_data_structures::sso::SsoHashSet;
77
use rustc_hir::def_id::DefId;
88
use rustc_middle::ty::GenericArg;
9-
use rustc_middle::ty::{self, EarlyBinder, OutlivesPredicate, Ty, TyCtxt};
9+
use rustc_middle::ty::{self, EarlyBinder, OutlivesPredicate, SubstsRef, Ty, TyCtxt};
1010

1111
use smallvec::smallvec;
1212

@@ -114,16 +114,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
114114
self.declared_generic_bounds_from_env_for_erased_ty(erased_projection_ty)
115115
}
116116

117-
/// Searches the where-clauses in scope for regions that
118-
/// `projection_ty` is known to outlive. Currently requires an
119-
/// exact match.
120-
pub fn projection_declared_bounds_from_trait(
121-
&self,
122-
projection_ty: ty::ProjectionTy<'tcx>,
123-
) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'tcx> {
124-
self.declared_projection_bounds_from_trait(projection_ty)
125-
}
126-
127117
#[instrument(level = "debug", skip(self, visited))]
128118
fn projection_bound(
129119
&self,
@@ -151,7 +141,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
151141

152142
// Extend with bounds that we can find from the trait.
153143
let trait_bounds = self
154-
.projection_declared_bounds_from_trait(projection_ty)
144+
.bounds(projection_ty.item_def_id, projection_ty.substs)
155145
.map(|r| VerifyBound::OutlivedBy(r));
156146

157147
// see the extensive comment in projection_must_outlive
@@ -294,15 +284,15 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
294284
///
295285
/// then this function would return `'x`. This is subject to the
296286
/// limitations around higher-ranked bounds described in
297-
/// `region_bounds_declared_on_associated_item`.
298-
fn declared_projection_bounds_from_trait(
287+
/// `declared_region_bounds`.
288+
#[instrument(level = "debug", skip(self))]
289+
pub fn bounds(
299290
&self,
300-
projection_ty: ty::ProjectionTy<'tcx>,
291+
def_id: DefId,
292+
substs: SubstsRef<'tcx>,
301293
) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'tcx> {
302-
debug!("projection_bounds(projection_ty={:?})", projection_ty);
303294
let tcx = self.tcx;
304-
self.region_bounds_declared_on_associated_item(projection_ty.item_def_id)
305-
.map(move |r| EarlyBinder(r).subst(tcx, projection_ty.substs))
295+
self.declared_region_bounds(def_id).map(move |r| EarlyBinder(r).subst(tcx, substs))
306296
}
307297

308298
/// Given the `DefId` of an associated item, returns any region
@@ -335,12 +325,10 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
335325
///
336326
/// This is for simplicity, and because we are not really smart
337327
/// enough to cope with such bounds anywhere.
338-
fn region_bounds_declared_on_associated_item(
339-
&self,
340-
assoc_item_def_id: DefId,
341-
) -> impl Iterator<Item = ty::Region<'tcx>> {
328+
fn declared_region_bounds(&self, def_id: DefId) -> impl Iterator<Item = ty::Region<'tcx>> {
342329
let tcx = self.tcx;
343-
let bounds = tcx.item_bounds(assoc_item_def_id);
330+
let bounds = tcx.item_bounds(def_id);
331+
trace!("{:#?}", bounds);
344332
bounds
345333
.into_iter()
346334
.filter_map(|p| p.to_opt_type_outlives())

0 commit comments

Comments
 (0)