Skip to content

Commit 6ecfe02

Browse files
Simplify some lifetimes
1 parent 9ba6d11 commit 6ecfe02

File tree

28 files changed

+72
-83
lines changed

28 files changed

+72
-83
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2073,9 +2073,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20732073
self.new_named_lifetime_with_res(new_id, ident, res)
20742074
}
20752075

2076-
fn lower_generic_params_mut<'s>(
2077-
&'s mut self,
2078-
params: &'s [GenericParam],
2076+
fn lower_generic_params_mut(
2077+
&mut self,
2078+
params: &[GenericParam],
20792079
source: hir::GenericParamSource,
20802080
) -> impl Iterator<Item = hir::GenericParam<'hir>> {
20812081
params.iter().map(move |param| self.lower_generic_param(param, source))
@@ -2237,9 +2237,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22372237
self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx))
22382238
}
22392239

2240-
fn lower_param_bounds_mut<'s>(
2241-
&'s mut self,
2242-
bounds: &'s [GenericBound],
2240+
fn lower_param_bounds_mut(
2241+
&mut self,
2242+
bounds: &[GenericBound],
22432243
itctx: ImplTraitContext,
22442244
) -> impl Iterator<Item = hir::GenericBound<'hir>> {
22452245
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))

compiler/rustc_attr/src/builtin.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1163,23 +1163,23 @@ pub fn find_transparency(
11631163
(transparency.map_or(fallback, |t| t.0), error)
11641164
}
11651165

1166-
pub fn allow_internal_unstable<'a>(
1167-
sess: &'a Session,
1168-
attrs: &'a [Attribute],
1166+
pub fn allow_internal_unstable(
1167+
sess: &Session,
1168+
attrs: &[Attribute],
11691169
) -> impl Iterator<Item = Symbol> {
11701170
allow_unstable(sess, attrs, sym::allow_internal_unstable)
11711171
}
11721172

1173-
pub fn rustc_allow_const_fn_unstable<'a>(
1174-
sess: &'a Session,
1175-
attrs: &'a [Attribute],
1173+
pub fn rustc_allow_const_fn_unstable(
1174+
sess: &Session,
1175+
attrs: &[Attribute],
11761176
) -> impl Iterator<Item = Symbol> {
11771177
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)
11781178
}
11791179

1180-
fn allow_unstable<'a>(
1181-
sess: &'a Session,
1182-
attrs: &'a [Attribute],
1180+
fn allow_unstable(
1181+
sess: &Session,
1182+
attrs: &[Attribute],
11831183
symbol: Symbol,
11841184
) -> impl Iterator<Item = Symbol> {
11851185
let attrs = attr::filter_by_name(attrs, symbol);

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3552,8 +3552,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
35523552
location: Location,
35533553
mpi: MovePathIndex,
35543554
) -> (Vec<MoveSite>, Vec<Location>) {
3555-
fn predecessor_locations<'a, 'tcx>(
3556-
body: &'a mir::Body<'tcx>,
3555+
fn predecessor_locations<'tcx>(
3556+
body: &mir::Body<'tcx>,
35573557
location: Location,
35583558
) -> impl Iterator<Item = Location> {
35593559
if location.statement_index == 0 {

compiler/rustc_borrowck/src/region_infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
603603
self.scc_values.region_value_str(scc)
604604
}
605605

606-
pub(crate) fn placeholders_contained_in<'a>(
607-
&'a self,
606+
pub(crate) fn placeholders_contained_in(
607+
&self,
608608
r: RegionVid,
609609
) -> impl Iterator<Item = ty::PlaceholderRegion> {
610610
let scc = self.constraint_sccs.scc(r);

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ pub(crate) struct ReverseSccGraph {
2020

2121
impl ReverseSccGraph {
2222
/// Find all universal regions that are required to outlive the given SCC.
23-
pub(super) fn upper_bounds<'a>(
24-
&'a self,
25-
scc0: ConstraintSccIndex,
26-
) -> impl Iterator<Item = RegionVid> {
23+
pub(super) fn upper_bounds(&self, scc0: ConstraintSccIndex) -> impl Iterator<Item = RegionVid> {
2724
let mut duplicates = FxIndexSet::default();
2825
graph::depth_first_search(&self.graph, scc0)
2926
.flat_map(move |scc1| {

compiler/rustc_borrowck/src/region_infer/values.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl<N: Idx> RegionValues<N> {
359359
}
360360

361361
/// Returns the locations contained within a given region `r`.
362-
pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator<Item = Location> {
362+
pub(crate) fn locations_outlived_by(&self, r: N) -> impl Iterator<Item = Location> {
363363
self.points.row(r).into_iter().flat_map(move |set| {
364364
set.iter()
365365
.take_while(move |&p| self.elements.point_in_range(p))
@@ -368,16 +368,13 @@ impl<N: Idx> RegionValues<N> {
368368
}
369369

370370
/// Returns just the universal regions that are contained in a given region's value.
371-
pub(crate) fn universal_regions_outlived_by<'a>(
372-
&'a self,
373-
r: N,
374-
) -> impl Iterator<Item = RegionVid> {
371+
pub(crate) fn universal_regions_outlived_by(&self, r: N) -> impl Iterator<Item = RegionVid> {
375372
self.free_regions.row(r).into_iter().flat_map(|set| set.iter())
376373
}
377374

378375
/// Returns all the elements contained in a given region's value.
379-
pub(crate) fn placeholders_contained_in<'a>(
380-
&'a self,
376+
pub(crate) fn placeholders_contained_in(
377+
&self,
381378
r: N,
382379
) -> impl Iterator<Item = ty::PlaceholderRegion> {
383380
self.placeholders
@@ -388,7 +385,7 @@ impl<N: Idx> RegionValues<N> {
388385
}
389386

390387
/// Returns all the elements contained in a given region's value.
391-
pub(crate) fn elements_contained_in<'a>(&'a self, r: N) -> impl Iterator<Item = RegionElement> {
388+
pub(crate) fn elements_contained_in(&self, r: N) -> impl Iterator<Item = RegionElement> {
392389
let points_iter = self.locations_outlived_by(r).map(RegionElement::Location);
393390

394391
let free_regions_iter =

compiler/rustc_borrowck/src/universal_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ impl<'tcx> UniversalRegions<'tcx> {
336336
}
337337

338338
/// Gets an iterator over all the early-bound regions that have names.
339-
pub(crate) fn named_universal_regions<'s>(
340-
&'s self,
339+
pub(crate) fn named_universal_regions(
340+
&self,
341341
) -> impl Iterator<Item = (ty::Region<'tcx>, ty::RegionVid)> {
342342
self.indices.indices.iter().map(|(&r, &v)| (r, v))
343343
}

compiler/rustc_hir_analysis/src/collect.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1762,10 +1762,10 @@ fn polarity_of_impl(
17621762
/// the lifetimes that are declared. For fns or methods, we have to
17631763
/// screen out those that do not appear in any where-clauses etc using
17641764
/// `resolve_lifetime::early_bound_lifetimes`.
1765-
fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
1765+
fn early_bound_lifetimes_from_generics<'a, 'tcx>(
17661766
tcx: TyCtxt<'tcx>,
1767-
generics: &'a hir::Generics<'a>,
1768-
) -> impl Iterator<Item = &'a hir::GenericParam<'a>> {
1767+
generics: &'a hir::Generics<'tcx>,
1768+
) -> impl Iterator<Item = &'a hir::GenericParam<'tcx>> {
17691769
generics.params.iter().filter(move |param| match param.kind {
17701770
GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id),
17711771
_ => false,

compiler/rustc_infer/src/infer/canonical/query_response.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,12 @@ impl<'tcx> InferCtxt<'tcx> {
549549

550550
/// Converts the region constraints resulting from a query into an
551551
/// iterator of obligations.
552-
fn query_outlives_constraints_into_obligations<'a>(
553-
&'a self,
554-
cause: &'a ObligationCause<'tcx>,
552+
fn query_outlives_constraints_into_obligations(
553+
&self,
554+
cause: &ObligationCause<'tcx>,
555555
param_env: ty::ParamEnv<'tcx>,
556-
uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>],
557-
result_args: &'a CanonicalVarValues<'tcx>,
556+
uninstantiated_region_constraints: &[QueryOutlivesConstraint<'tcx>],
557+
result_args: &CanonicalVarValues<'tcx>,
558558
) -> impl Iterator<Item = PredicateObligation<'tcx>> {
559559
uninstantiated_region_constraints.iter().map(move |&constraint| {
560560
let predicate = instantiate_value(self.tcx, result_args, constraint);

compiler/rustc_infer/src/infer/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1474,9 +1474,7 @@ impl<'tcx> InferCtxt<'tcx> {
14741474
/// The returned function is used in a fast path. If it returns `true` the variable is
14751475
/// unchanged, `false` indicates that the status is unknown.
14761476
#[inline]
1477-
pub fn is_ty_infer_var_definitely_unchanged<'a>(
1478-
&'a self,
1479-
) -> impl Fn(TyOrConstInferVar) -> bool {
1477+
pub fn is_ty_infer_var_definitely_unchanged(&self) -> impl Fn(TyOrConstInferVar) -> bool {
14801478
// This hoists the borrow/release out of the loop body.
14811479
let inner = self.inner.try_borrow();
14821480

compiler/rustc_lint/src/context.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ impl LintStore {
157157
&self.lints
158158
}
159159

160-
pub fn get_lint_groups<'t>(
161-
&'t self,
162-
) -> impl Iterator<Item = (&'static str, Vec<LintId>, bool)> {
160+
pub fn get_lint_groups(&self) -> impl Iterator<Item = (&'static str, Vec<LintId>, bool)> {
163161
self.lint_groups
164162
.iter()
165163
.filter(|(_, LintGroup { depr, .. })| {

compiler/rustc_metadata/src/rmeta/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,9 @@ impl CrateRoot {
953953
self.stable_crate_id
954954
}
955955

956-
pub(crate) fn decode_crate_deps<'a>(
956+
pub(crate) fn decode_crate_deps(
957957
&self,
958-
metadata: &'a MetadataBlob,
958+
metadata: &MetadataBlob,
959959
) -> impl ExactSizeIterator<Item = CrateDep> {
960960
self.crate_deps.decode(metadata)
961961
}

compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ impl<'tcx> Body<'tcx> {
470470

471471
/// Returns an iterator over all user-declared mutable locals.
472472
#[inline]
473-
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> {
473+
pub fn mut_vars_iter(&self) -> impl Iterator<Item = Local> {
474474
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
475475
let local = Local::new(index);
476476
let decl = &self.local_decls[local];
@@ -480,7 +480,7 @@ impl<'tcx> Body<'tcx> {
480480

481481
/// Returns an iterator over all user-declared mutable arguments and locals.
482482
#[inline]
483-
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> {
483+
pub fn mut_vars_and_args_iter(&self) -> impl Iterator<Item = Local> {
484484
(1..self.local_decls.len()).filter_map(move |index| {
485485
let local = Local::new(index);
486486
let decl = &self.local_decls[local];

compiler/rustc_middle/src/ty/generic_args.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -483,24 +483,24 @@ impl<'tcx> GenericArgs<'tcx> {
483483
}
484484

485485
#[inline]
486-
pub fn types(&'tcx self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> {
486+
pub fn types(&self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> {
487487
self.iter().filter_map(|k| k.as_type())
488488
}
489489

490490
#[inline]
491-
pub fn regions(&'tcx self) -> impl DoubleEndedIterator<Item = ty::Region<'tcx>> {
491+
pub fn regions(&self) -> impl DoubleEndedIterator<Item = ty::Region<'tcx>> {
492492
self.iter().filter_map(|k| k.as_region())
493493
}
494494

495495
#[inline]
496-
pub fn consts(&'tcx self) -> impl DoubleEndedIterator<Item = ty::Const<'tcx>> {
496+
pub fn consts(&self) -> impl DoubleEndedIterator<Item = ty::Const<'tcx>> {
497497
self.iter().filter_map(|k| k.as_const())
498498
}
499499

500500
/// Returns generic arguments that are not lifetimes or host effect params.
501501
#[inline]
502502
pub fn non_erasable_generics(
503-
&'tcx self,
503+
&self,
504504
tcx: TyCtxt<'tcx>,
505505
def_id: DefId,
506506
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> {

compiler/rustc_middle/src/ty/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1827,14 +1827,11 @@ impl<'tcx> TyCtxt<'tcx> {
18271827
}
18281828
}
18291829

1830-
pub fn get_attrs_by_path<'attr>(
1830+
pub fn get_attrs_by_path(
18311831
self,
18321832
did: DefId,
1833-
attr: &'attr [Symbol],
1834-
) -> impl Iterator<Item = &'tcx ast::Attribute>
1835-
where
1836-
'tcx: 'attr,
1837-
{
1833+
attr: &[Symbol],
1834+
) -> impl Iterator<Item = &'tcx ast::Attribute> {
18381835
let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr);
18391836
if let Some(did) = did.as_local() {
18401837
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)

compiler/rustc_middle/src/ty/predicate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ impl<'tcx> ty::List<ty::PolyExistentialPredicate<'tcx>> {
329329
}
330330

331331
#[inline]
332-
pub fn projection_bounds<'a>(
333-
&'a self,
332+
pub fn projection_bounds(
333+
&self,
334334
) -> impl Iterator<Item = ty::Binder<'tcx, ExistentialProjection<'tcx>>> {
335335
self.iter().filter_map(|predicate| {
336336
predicate
@@ -343,7 +343,7 @@ impl<'tcx> ty::List<ty::PolyExistentialPredicate<'tcx>> {
343343
}
344344

345345
#[inline]
346-
pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> {
346+
pub fn auto_traits(&self) -> impl Iterator<Item = DefId> {
347347
self.iter().filter_map(|predicate| match predicate.skip_binder() {
348348
ExistentialPredicate::AutoTrait(did) => Some(did),
349349
_ => None,

compiler/rustc_mir_build/src/build/expr/as_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ fn to_upvars_resolved_place_builder<'tcx>(
216216
/// Supports only HIR projection kinds that represent a path that might be
217217
/// captured by a closure or a coroutine, i.e., an `Index` or a `Subslice`
218218
/// projection kinds are unsupported.
219-
fn strip_prefix<'a, 'tcx>(
219+
fn strip_prefix<'tcx>(
220220
mut base_ty: Ty<'tcx>,
221-
projections: &'a [PlaceElem<'tcx>],
221+
projections: &[PlaceElem<'tcx>],
222222
prefix_projections: &[HirProjection<'tcx>],
223223
) -> impl Iterator<Item = PlaceElem<'tcx>> {
224224
let mut iter = projections

compiler/rustc_mir_build/src/thir/cx/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ impl<'tcx> Cx<'tcx> {
156156
})
157157
}
158158

159-
fn explicit_params<'a>(
160-
&'a mut self,
159+
fn explicit_params(
160+
&mut self,
161161
owner_id: HirId,
162162
fn_decl: &'tcx hir::FnDecl<'tcx>,
163163
body: &'tcx hir::Body<'tcx>,

compiler/rustc_mir_transform/src/coverage/graph.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ fn find_loop_backedges(
567567
backedges
568568
}
569569

570-
fn short_circuit_preorder<'a, 'tcx, F, Iter>(
571-
body: &'a mir::Body<'tcx>,
570+
fn short_circuit_preorder<'tcx, F, Iter>(
571+
body: &mir::Body<'tcx>,
572572
filtered_successors: F,
573573
) -> impl Iterator<Item = BasicBlock>
574574
where

compiler/rustc_mir_transform/src/coverage/spans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ fn divide_spans_into_buckets(input_covspans: Vec<Covspan>, holes: &[Hole]) -> Ve
179179

180180
/// Similar to `.drain(..)`, but stops just before it would remove an item not
181181
/// satisfying the predicate.
182-
fn drain_front_while<'a, T>(
183-
queue: &'a mut VecDeque<T>,
182+
fn drain_front_while<T>(
183+
queue: &mut VecDeque<T>,
184184
mut pred_fn: impl FnMut(&T) -> bool,
185185
) -> impl Iterator<Item = T> {
186186
std::iter::from_fn(move || if pred_fn(queue.front()?) { queue.pop_front() } else { None })

compiler/rustc_mir_transform/src/ssa.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl SsaLocals {
136136
}
137137

138138
pub(super) fn assignments<'a, 'tcx>(
139-
&'a self,
139+
&self,
140140
body: &'a Body<'tcx>,
141141
) -> impl Iterator<Item = (Local, &'a Rvalue<'tcx>, Location)> {
142142
self.assignment_order.iter().filter_map(|&local| {

compiler/rustc_pattern_analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait PatCx: Sized + fmt::Debug {
6565
&'a self,
6666
ctor: &'a Constructor<Self>,
6767
ty: &'a Self::Ty,
68-
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator;
68+
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator + Captures<'a>;
6969

7070
/// The set of all the constructors for `ty`.
7171
///

compiler/rustc_pattern_analysis/src/pat_column.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'p, Cx: PatCx> PatternColumn<'p, Cx> {
4141
pub fn head_ty(&self) -> Option<&Cx::Ty> {
4242
self.patterns.first().map(|pat| pat.ty())
4343
}
44-
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'p DeconstructedPat<Cx>> {
44+
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'p DeconstructedPat<Cx>> + Captures<'a> {
4545
self.patterns.iter().copied()
4646
}
4747

compiler/rustc_pattern_analysis/src/rustc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> {
936936
&'a self,
937937
ctor: &'a crate::constructor::Constructor<Self>,
938938
ty: &'a Self::Ty,
939-
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator {
939+
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator + Captures<'a>
940+
{
940941
self.ctor_sub_tys(ctor, *ty)
941942
}
942943
fn ctors_for_ty(

compiler/rustc_pattern_analysis/src/usefulness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
905905
&'a self,
906906
cx: &'a Cx,
907907
ctor: &'a Constructor<Cx>,
908-
) -> impl Iterator<Item = Self> + ExactSizeIterator {
908+
) -> impl Iterator<Item = Self> + ExactSizeIterator + Captures<'a> {
909909
let ctor_sub_tys = cx.ctor_sub_tys(ctor, &self.ty);
910910
let ctor_sub_validity = self.validity.specialize(ctor);
911911
ctor_sub_tys.map(move |(ty, PrivateUninhabitedField(private_uninhabited))| PlaceInfo {

compiler/rustc_pattern_analysis/tests/common/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ impl PatCx for Cx {
160160
&'a self,
161161
ctor: &'a Constructor<Self>,
162162
ty: &'a Self::Ty,
163-
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator {
163+
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator + Captures<'a>
164+
{
164165
ty.sub_tys(ctor).into_iter().map(|ty| (ty, PrivateUninhabitedField(false)))
165166
}
166167

0 commit comments

Comments
 (0)