Skip to content

Commit f55a571

Browse files
Greatly simplify lifetime captures in edition 2024
1 parent 15469f8 commit f55a571

File tree

85 files changed

+224
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+224
-295
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {
13451345

13461346
/// Gets source indices of the fields by increasing offsets.
13471347
#[inline]
1348-
pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator<Item = usize> + '_ {
1348+
pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator<Item = usize> {
13491349
let mut inverse_small = [0u8; 64];
13501350
let mut inverse_big = IndexVec::new();
13511351
let use_small = self.count() <= inverse_small.len();

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ use std::sync::Arc;
4545

4646
use rustc_ast::node_id::NodeMap;
4747
use rustc_ast::{self as ast, *};
48-
use rustc_data_structures::captures::Captures;
4948
use rustc_data_structures::fingerprint::Fingerprint;
5049
use rustc_data_structures::sorted_map::SortedMap;
5150
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -1821,11 +1820,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18211820
self.new_named_lifetime_with_res(new_id, ident, res)
18221821
}
18231822

1824-
fn lower_generic_params_mut<'s>(
1825-
&'s mut self,
1826-
params: &'s [GenericParam],
1823+
fn lower_generic_params_mut(
1824+
&mut self,
1825+
params: &[GenericParam],
18271826
source: hir::GenericParamSource,
1828-
) -> impl Iterator<Item = hir::GenericParam<'hir>> + Captures<'a> + Captures<'s> {
1827+
) -> impl Iterator<Item = hir::GenericParam<'hir>> {
18291828
params.iter().map(move |param| self.lower_generic_param(param, source))
18301829
}
18311830

@@ -1986,11 +1985,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19861985
self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx))
19871986
}
19881987

1989-
fn lower_param_bounds_mut<'s>(
1990-
&'s mut self,
1991-
bounds: &'s [GenericBound],
1988+
fn lower_param_bounds_mut(
1989+
&mut self,
1990+
bounds: &[GenericBound],
19921991
itctx: ImplTraitContext,
1993-
) -> impl Iterator<Item = hir::GenericBound<'hir>> + Captures<'s> + Captures<'a> {
1992+
) -> impl Iterator<Item = hir::GenericBound<'hir>> {
19941993
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
19951994
}
19961995

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ use rustc_span::{Symbol, sym};
44

55
use crate::session_diagnostics;
66

7-
pub fn allow_internal_unstable<'a>(
8-
sess: &'a Session,
9-
attrs: &'a [impl AttributeExt],
10-
) -> impl Iterator<Item = Symbol> + 'a {
7+
pub fn allow_internal_unstable(
8+
sess: &Session,
9+
attrs: &[impl AttributeExt],
10+
) -> impl Iterator<Item = Symbol> {
1111
allow_unstable(sess, attrs, sym::allow_internal_unstable)
1212
}
1313

14-
pub fn rustc_allow_const_fn_unstable<'a>(
15-
sess: &'a Session,
16-
attrs: &'a [impl AttributeExt],
17-
) -> impl Iterator<Item = Symbol> + 'a {
14+
pub fn rustc_allow_const_fn_unstable(
15+
sess: &Session,
16+
attrs: &[impl AttributeExt],
17+
) -> impl Iterator<Item = Symbol> {
1818
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)
1919
}
2020

21-
fn allow_unstable<'a>(
22-
sess: &'a Session,
23-
attrs: &'a [impl AttributeExt],
21+
fn allow_unstable(
22+
sess: &Session,
23+
attrs: &[impl AttributeExt],
2424
symbol: Symbol,
25-
) -> impl Iterator<Item = Symbol> + 'a {
25+
) -> impl Iterator<Item = Symbol> {
2626
let attrs = filter_by_name(attrs, symbol);
2727
let list = attrs
2828
.filter_map(move |attr| {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::ops::ControlFlow;
88

99
use either::Either;
1010
use hir::{ClosureKind, Path};
11-
use rustc_data_structures::captures::Captures;
1211
use rustc_data_structures::fx::FxIndexSet;
1312
use rustc_errors::codes::*;
1413
use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err};
@@ -3530,10 +3529,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
35303529
location: Location,
35313530
mpi: MovePathIndex,
35323531
) -> (Vec<MoveSite>, Vec<Location>) {
3533-
fn predecessor_locations<'a, 'tcx>(
3534-
body: &'a mir::Body<'tcx>,
3532+
fn predecessor_locations<'tcx>(
3533+
body: &mir::Body<'tcx>,
35353534
location: Location,
3536-
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {
3535+
) -> impl Iterator<Item = Location> {
35373536
if location.statement_index == 0 {
35383537
let predecessors = body.basic_blocks.predecessors()[location.block].to_vec();
35393538
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))

compiler/rustc_borrowck/src/member_constraints.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::hash::Hash;
22
use std::ops::Index;
33

4-
use rustc_data_structures::captures::Captures;
54
use rustc_data_structures::fx::FxIndexMap;
65
use rustc_index::{IndexSlice, IndexVec};
76
use rustc_middle::ty::{self, Ty};
@@ -147,9 +146,7 @@ impl<'tcx, R> MemberConstraintSet<'tcx, R>
147146
where
148147
R: Copy + Hash + Eq,
149148
{
150-
pub(crate) fn all_indices(
151-
&self,
152-
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
149+
pub(crate) fn all_indices(&self) -> impl Iterator<Item = NllMemberConstraintIndex> {
153150
self.constraints.indices()
154151
}
155152

@@ -159,7 +156,7 @@ where
159156
pub(crate) fn indices(
160157
&self,
161158
member_region_vid: R,
162-
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
159+
) -> impl Iterator<Item = NllMemberConstraintIndex> {
163160
let mut next = self.first_constraints.get(&member_region_vid).cloned();
164161
std::iter::from_fn(move || -> Option<NllMemberConstraintIndex> {
165162
if let Some(current) = next {

compiler/rustc_borrowck/src/polonius/loan_liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl LocalizedConstraintGraph {
175175
}
176176

177177
/// Returns the outgoing edges of a given node, not its transitive closure.
178-
fn outgoing_edges(&self, node: LocalizedNode) -> impl Iterator<Item = LocalizedNode> + use<'_> {
178+
fn outgoing_edges(&self, node: LocalizedNode) -> impl Iterator<Item = LocalizedNode> {
179179
// The outgoing edges are:
180180
// - the physical edges present at this node,
181181
// - the materialized logical edges that exist virtually at all points for this node's

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
576576
}
577577

578578
/// Returns an iterator over all the outlives constraints.
579-
pub(crate) fn outlives_constraints(
580-
&self,
581-
) -> impl Iterator<Item = OutlivesConstraint<'tcx>> + '_ {
579+
pub(crate) fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> {
582580
self.constraints.outlives().iter().copied()
583581
}
584582

@@ -615,10 +613,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
615613
self.scc_values.region_value_str(scc)
616614
}
617615

618-
pub(crate) fn placeholders_contained_in<'a>(
619-
&'a self,
616+
pub(crate) fn placeholders_contained_in(
617+
&self,
620618
r: RegionVid,
621-
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
619+
) -> impl Iterator<Item = ty::PlaceholderRegion> {
622620
let scc = self.constraint_sccs.scc(r);
623621
self.scc_values.placeholders_contained_in(scc)
624622
}

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

Lines changed: 1 addition & 4 deletions
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> + 'a {
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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ impl LivenessValues {
8888
}
8989

9090
/// Iterate through each region that has a value in this set.
91-
pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> + '_ {
91+
pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> {
9292
self.points.as_ref().expect("use with_specific_points").rows()
9393
}
9494

9595
/// Iterate through each region that has a value in this set.
9696
// We are passing query instability implications to the caller.
9797
#[rustc_lint_query_instability]
9898
#[allow(rustc::potential_query_instability)]
99-
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> + '_ {
99+
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> {
100100
self.live_regions.as_ref().unwrap().iter().copied()
101101
}
102102

@@ -143,7 +143,7 @@ impl LivenessValues {
143143
}
144144

145145
/// Returns an iterator of all the points where `region` is live.
146-
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> + '_ {
146+
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> {
147147
let Some(points) = &self.points else {
148148
unreachable!(
149149
"Should be using LivenessValues::with_specific_points to ask whether live at a location"
@@ -340,7 +340,7 @@ impl<N: Idx> RegionValues<N> {
340340
}
341341

342342
/// Returns the locations contained within a given region `r`.
343-
pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator<Item = Location> + 'a {
343+
pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator<Item = Location> {
344344
self.points.row(r).into_iter().flat_map(move |set| {
345345
set.iter()
346346
.take_while(move |&p| self.location_map.point_in_range(p))
@@ -349,18 +349,15 @@ impl<N: Idx> RegionValues<N> {
349349
}
350350

351351
/// Returns just the universal regions that are contained in a given region's value.
352-
pub(crate) fn universal_regions_outlived_by<'a>(
353-
&'a self,
354-
r: N,
355-
) -> impl Iterator<Item = RegionVid> + 'a {
352+
pub(crate) fn universal_regions_outlived_by(&self, r: N) -> impl Iterator<Item = RegionVid> {
356353
self.free_regions.row(r).into_iter().flat_map(|set| set.iter())
357354
}
358355

359356
/// Returns all the elements contained in a given region's value.
360-
pub(crate) fn placeholders_contained_in<'a>(
361-
&'a self,
357+
pub(crate) fn placeholders_contained_in(
358+
&self,
362359
r: N,
363-
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
360+
) -> impl Iterator<Item = ty::PlaceholderRegion> {
364361
self.placeholders
365362
.row(r)
366363
.into_iter()
@@ -369,10 +366,7 @@ impl<N: Idx> RegionValues<N> {
369366
}
370367

371368
/// Returns all the elements contained in a given region's value.
372-
pub(crate) fn elements_contained_in<'a>(
373-
&'a self,
374-
r: N,
375-
) -> impl Iterator<Item = RegionElement> + 'a {
369+
pub(crate) fn elements_contained_in<'a>(&'a self, r: N) -> impl Iterator<Item = RegionElement> {
376370
let points_iter = self.locations_outlived_by(r).map(RegionElement::Location);
377371

378372
let free_regions_iter =

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl UniversalRegionRelations<'_> {
172172
}
173173

174174
/// Returns the _non-transitive_ set of known `outlives` constraints between free regions.
175-
pub(crate) fn known_outlives(&self) -> impl Iterator<Item = (RegionVid, RegionVid)> + '_ {
175+
pub(crate) fn known_outlives(&self) -> impl Iterator<Item = (RegionVid, RegionVid)> {
176176
self.outlives.base_edges()
177177
}
178178
}

0 commit comments

Comments
 (0)