Skip to content

Commit 27a15da

Browse files
Remove unncessary outlives and captures from RPITs
1 parent 7e64881 commit 27a15da

File tree

91 files changed

+174
-223
lines changed

Some content is hidden

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

91 files changed

+174
-223
lines changed

compiler/rustc_abi/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {
12751275

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

compiler/rustc_ast_lowering/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ use std::collections::hash_map::Entry;
4545
use rustc_ast::node_id::NodeMap;
4646
use rustc_ast::ptr::P;
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::fx::FxIndexSet;
5150
use rustc_data_structures::sorted_map::SortedMap;
@@ -2078,7 +2077,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20782077
&'s mut self,
20792078
params: &'s [GenericParam],
20802079
source: hir::GenericParamSource,
2081-
) -> impl Iterator<Item = hir::GenericParam<'hir>> + Captures<'a> + Captures<'s> {
2080+
) -> impl Iterator<Item = hir::GenericParam<'hir>> {
20822081
params.iter().map(move |param| self.lower_generic_param(param, source))
20832082
}
20842083

@@ -2242,7 +2241,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22422241
&'s mut self,
22432242
bounds: &'s [GenericBound],
22442243
itctx: ImplTraitContext,
2245-
) -> impl Iterator<Item = hir::GenericBound<'hir>> + Captures<'s> + Captures<'a> {
2244+
) -> impl Iterator<Item = hir::GenericBound<'hir>> {
22462245
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
22472246
}
22482247

compiler/rustc_attr/src/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1166,22 +1166,22 @@ pub fn find_transparency(
11661166
pub fn allow_internal_unstable<'a>(
11671167
sess: &'a Session,
11681168
attrs: &'a [Attribute],
1169-
) -> impl Iterator<Item = Symbol> + 'a {
1169+
) -> impl Iterator<Item = Symbol> {
11701170
allow_unstable(sess, attrs, sym::allow_internal_unstable)
11711171
}
11721172

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

11801180
fn allow_unstable<'a>(
11811181
sess: &'a Session,
11821182
attrs: &'a [Attribute],
11831183
symbol: Symbol,
1184-
) -> impl Iterator<Item = Symbol> + 'a {
1184+
) -> impl Iterator<Item = Symbol> {
11851185
let attrs = attr::filter_by_name(attrs, symbol);
11861186
let list = attrs
11871187
.filter_map(move |attr| {

compiler/rustc_borrowck/src/borrow_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<'tcx> BorrowSet<'tcx> {
160160
self.location_map.len()
161161
}
162162

163-
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
163+
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> + 'static {
164164
BorrowIndex::ZERO..BorrowIndex::from_usize(self.len())
165165
}
166166

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-2
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::{struct_span_code_err, Applicability, Diag, MultiSpan};
@@ -3556,7 +3555,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
35563555
fn predecessor_locations<'a, 'tcx>(
35573556
body: &'a mir::Body<'tcx>,
35583557
location: Location,
3559-
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {
3558+
) -> impl Iterator<Item = Location> {
35603559
if location.statement_index == 0 {
35613560
let predecessors = body.basic_blocks.predecessors()[location.block].to_vec();
35623561
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
827827
/// help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as
828828
/// a constraint
829829
/// |
830-
/// LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + 'a {
830+
/// LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
831831
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
832832
/// ```
833833
#[allow(rustc::diagnostic_outside_of_impl)]

compiler/rustc_borrowck/src/member_constraints.rs

+2-5
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::infer::MemberConstraint;
@@ -151,9 +150,7 @@ impl<'tcx, R> MemberConstraintSet<'tcx, R>
151150
where
152151
R: Copy + Hash + Eq,
153152
{
154-
pub(crate) fn all_indices(
155-
&self,
156-
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
153+
pub(crate) fn all_indices(&self) -> impl Iterator<Item = NllMemberConstraintIndex> {
157154
self.constraints.indices()
158155
}
159156

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

compiler/rustc_borrowck/src/region_infer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
553553
}
554554

555555
/// Returns an iterator over all the region indices.
556-
pub fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx {
556+
pub fn regions(&self) -> impl Iterator<Item = RegionVid> {
557557
self.definitions.indices()
558558
}
559559

@@ -566,7 +566,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
566566
}
567567

568568
/// Returns an iterator over all the outlives constraints.
569-
pub fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> + '_ {
569+
pub fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> {
570570
self.constraints.outlives().iter().copied()
571571
}
572572

@@ -606,7 +606,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
606606
pub(crate) fn placeholders_contained_in<'a>(
607607
&'a self,
608608
r: RegionVid,
609-
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
609+
) -> impl Iterator<Item = ty::PlaceholderRegion> {
610610
let scc = self.constraint_sccs.scc(r);
611611
self.scc_values.placeholders_contained_in(scc)
612612
}

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl ReverseSccGraph {
2323
pub(super) fn upper_bounds<'a>(
2424
&'a self,
2525
scc0: ConstraintSccIndex,
26-
) -> impl Iterator<Item = RegionVid> + 'a {
26+
) -> impl Iterator<Item = RegionVid> {
2727
let mut duplicates = FxIndexSet::default();
2828
graph::depth_first_search(&self.graph, scc0)
2929
.flat_map(move |scc1| {

compiler/rustc_borrowck/src/region_infer/values.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ impl LivenessValues {
100100
}
101101

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

107107
/// Iterate through each region that has a value in this set.
108108
// We are passing query instability implications to the caller.
109109
#[rustc_lint_query_instability]
110110
#[allow(rustc::potential_query_instability)]
111-
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> + '_ {
111+
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> {
112112
self.live_regions.as_ref().unwrap().iter().copied()
113113
}
114114

@@ -173,7 +173,7 @@ impl LivenessValues {
173173
}
174174

175175
/// Returns an iterator of all the points where `region` is live.
176-
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> + '_ {
176+
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> {
177177
let Some(points) = &self.points else {
178178
unreachable!(
179179
"Should be using LivenessValues::with_specific_points to ask whether live at a location"
@@ -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> + 'a {
362+
pub(crate) fn locations_outlived_by<'a>(&'a 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))
@@ -371,15 +371,15 @@ impl<N: Idx> RegionValues<N> {
371371
pub(crate) fn universal_regions_outlived_by<'a>(
372372
&'a self,
373373
r: N,
374-
) -> impl Iterator<Item = RegionVid> + 'a {
374+
) -> impl Iterator<Item = RegionVid> {
375375
self.free_regions.row(r).into_iter().flat_map(|set| set.iter())
376376
}
377377

378378
/// Returns all the elements contained in a given region's value.
379379
pub(crate) fn placeholders_contained_in<'a>(
380380
&'a self,
381381
r: N,
382-
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
382+
) -> impl Iterator<Item = ty::PlaceholderRegion> {
383383
self.placeholders
384384
.row(r)
385385
.into_iter()
@@ -388,10 +388,7 @@ impl<N: Idx> RegionValues<N> {
388388
}
389389

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

397394
let free_regions_iter =

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl UniversalRegionRelations<'_> {
176176
}
177177

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

compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ rustc_index::newtype_index! {
5454
fn appearances_iter(
5555
first: Option<AppearanceIndex>,
5656
appearances: &Appearances,
57-
) -> impl Iterator<Item = AppearanceIndex> + '_ {
57+
) -> impl Iterator<Item = AppearanceIndex> {
5858
AppearancesIter { appearances, current: first }
5959
}
6060

@@ -107,17 +107,17 @@ impl LocalUseMap {
107107
local_use_map
108108
}
109109

110-
pub(crate) fn defs(&self, local: Local) -> impl Iterator<Item = PointIndex> + '_ {
110+
pub(crate) fn defs(&self, local: Local) -> impl Iterator<Item = PointIndex> {
111111
appearances_iter(self.first_def_at[local], &self.appearances)
112112
.map(move |aa| self.appearances[aa].point_index)
113113
}
114114

115-
pub(crate) fn uses(&self, local: Local) -> impl Iterator<Item = PointIndex> + '_ {
115+
pub(crate) fn uses(&self, local: Local) -> impl Iterator<Item = PointIndex> {
116116
appearances_iter(self.first_use_at[local], &self.appearances)
117117
.map(move |aa| self.appearances[aa].point_index)
118118
}
119119

120-
pub(crate) fn drops(&self, local: Local) -> impl Iterator<Item = PointIndex> + '_ {
120+
pub(crate) fn drops(&self, local: Local) -> impl Iterator<Item = PointIndex> {
121121
appearances_iter(self.first_drop_at[local], &self.appearances)
122122
.map(move |aa| self.appearances[aa].point_index)
123123
}

compiler/rustc_borrowck/src/universal_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'tcx> UniversalRegions<'tcx> {
312312

313313
/// Returns an iterator over all the RegionVids corresponding to
314314
/// universally quantified free regions.
315-
pub(crate) fn universal_regions(&self) -> impl Iterator<Item = RegionVid> {
315+
pub(crate) fn universal_regions(&self) -> impl Iterator<Item = RegionVid> + 'static {
316316
(FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize)
317317
}
318318

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

compiler/rustc_codegen_gcc/build_system/src/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String
10861086
fn retain_files_callback<'a>(
10871087
file_path: &'a str,
10881088
test_type: &'a str,
1089-
) -> impl Fn(&Path) -> Result<bool, String> + 'a {
1089+
) -> impl Fn(&Path) -> Result<bool, String> {
10901090
move |rust_path| {
10911091
let files = std::fs::read_to_string(file_path).unwrap_or_default();
10921092
let first_file_name = files.lines().next().unwrap_or("");
@@ -1149,7 +1149,7 @@ fn retain_files_callback<'a>(
11491149
fn remove_files_callback<'a>(
11501150
file_path: &'a str,
11511151
test_type: &'a str,
1152-
) -> impl Fn(&Path) -> Result<bool, String> + 'a {
1152+
) -> impl Fn(&Path) -> Result<bool, String> {
11531153
move |rust_path| {
11541154
let files = std::fs::read_to_string(file_path).unwrap_or_default();
11551155
let first_file_name = files.lines().next().unwrap_or("");

compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use rustc_data_structures::captures::Captures;
21
use rustc_data_structures::fx::FxIndexSet;
32
use rustc_index::bit_set::BitSet;
43
use rustc_middle::mir::coverage::{
@@ -200,15 +199,15 @@ impl<'tcx> FunctionCoverage<'tcx> {
200199
}
201200

202201
/// Returns an iterator over all filenames used by this function's mappings.
203-
pub(crate) fn all_file_names(&self) -> impl Iterator<Item = Symbol> + Captures<'_> {
202+
pub(crate) fn all_file_names(&self) -> impl Iterator<Item = Symbol> {
204203
self.function_coverage_info.mappings.iter().map(|mapping| mapping.source_region.file_name)
205204
}
206205

207206
/// Convert this function's coverage expression data into a form that can be
208207
/// passed through FFI to LLVM.
209208
pub(crate) fn counter_expressions(
210209
&self,
211-
) -> impl Iterator<Item = CounterExpression> + ExactSizeIterator + Captures<'_> {
210+
) -> impl Iterator<Item = CounterExpression> + ExactSizeIterator {
212211
// We know that LLVM will optimize out any unused expressions before
213212
// producing the final coverage map, so there's no need to do the same
214213
// thing on the Rust side unless we're confident we can do much better.

compiler/rustc_codegen_ssa/src/mir/locals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'tcx, V> Locals<'tcx, V> {
3232
Locals { values: IndexVec::default() }
3333
}
3434

35-
pub(super) fn indices(&self) -> impl DoubleEndedIterator<Item = mir::Local> + Clone + 'tcx {
35+
pub(super) fn indices(&self) -> impl DoubleEndedIterator<Item = mir::Local> + Clone + 'static {
3636
self.values.indices()
3737
}
3838
}

compiler/rustc_data_structures/src/graph/implementation/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ impl<N: Debug, E: Debug> Graph<N, E> {
193193
AdjacentEdges { graph: self, direction, next: first_edge }
194194
}
195195

196-
pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator<Item = NodeIndex> + '_ {
196+
pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator<Item = NodeIndex> {
197197
self.outgoing_edges(source).targets()
198198
}
199199

200-
pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator<Item = NodeIndex> + '_ {
200+
pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator<Item = NodeIndex> {
201201
self.incoming_edges(target).sources()
202202
}
203203

@@ -255,11 +255,11 @@ pub struct AdjacentEdges<'g, N, E> {
255255
}
256256

257257
impl<'g, N: Debug, E: Debug> AdjacentEdges<'g, N, E> {
258-
fn targets(self) -> impl Iterator<Item = NodeIndex> + 'g {
258+
fn targets(self) -> impl Iterator<Item = NodeIndex> {
259259
self.map(|(_, edge)| edge.target)
260260
}
261261

262-
fn sources(self) -> impl Iterator<Item = NodeIndex> + 'g {
262+
fn sources(self) -> impl Iterator<Item = NodeIndex> {
263263
self.map(|(_, edge)| edge.source)
264264
}
265265
}

compiler/rustc_data_structures/src/graph/scc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<N: Idx, S: Idx + Ord, A: Annotation> Sccs<N, S, A> {
133133
/// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after.
134134
/// This is convenient when the edges represent dependencies: when you visit
135135
/// `S1`, the value for `S2` will already have been computed.
136-
pub fn all_sccs(&self) -> impl Iterator<Item = S> {
136+
pub fn all_sccs(&self) -> impl Iterator<Item = S> + 'static {
137137
(0..self.scc_data.len()).map(S::new)
138138
}
139139

0 commit comments

Comments
 (0)