Skip to content

Commit 3642849

Browse files
Simplify some lifetimes
1 parent eb22f31 commit 3642849

File tree

28 files changed

+85
-98
lines changed

28 files changed

+85
-98
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2095,9 +2095,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20952095
self.new_named_lifetime_with_res(new_id, ident, res)
20962096
}
20972097

2098-
fn lower_generic_params_mut<'s>(
2099-
&'s mut self,
2100-
params: &'s [GenericParam],
2098+
fn lower_generic_params_mut(
2099+
&mut self,
2100+
params: &[GenericParam],
21012101
source: hir::GenericParamSource,
21022102
) -> impl Iterator<Item = hir::GenericParam<'hir>> {
21032103
params.iter().map(move |param| self.lower_generic_param(param, source))
@@ -2259,9 +2259,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22592259
self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx))
22602260
}
22612261

2262-
fn lower_param_bounds_mut<'s>(
2263-
&'s mut self,
2264-
bounds: &'s [GenericBound],
2262+
fn lower_param_bounds_mut(
2263+
&mut self,
2264+
bounds: &[GenericBound],
22652265
itctx: ImplTraitContext,
22662266
) -> impl Iterator<Item = hir::GenericBound<'hir>> {
22672267
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
@@ -3541,8 +3541,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
35413541
location: Location,
35423542
mpi: MovePathIndex,
35433543
) -> (Vec<MoveSite>, Vec<Location>) {
3544-
fn predecessor_locations<'tcx, 'a>(
3545-
body: &'a mir::Body<'tcx>,
3544+
fn predecessor_locations<'tcx>(
3545+
body: &mir::Body<'tcx>,
35463546
location: Location,
35473547
) -> impl Iterator<Item = Location> {
35483548
if location.statement_index == 0 {

compiler/rustc_borrowck/src/region_infer/mod.rs

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

605-
pub(crate) fn placeholders_contained_in<'a>(
606-
&'a self,
605+
pub(crate) fn placeholders_contained_in(
606+
&self,
607607
r: RegionVid,
608608
) -> impl Iterator<Item = ty::PlaceholderRegion> {
609609
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
@@ -362,7 +362,7 @@ impl<N: Idx> RegionValues<N> {
362362
}
363363

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

373373
/// Returns just the universal regions that are contained in a given region's value.
374-
pub(crate) fn universal_regions_outlived_by<'a>(
375-
&'a self,
376-
r: N,
377-
) -> impl Iterator<Item = RegionVid> {
374+
pub(crate) fn universal_regions_outlived_by(&self, r: N) -> impl Iterator<Item = RegionVid> {
378375
self.free_regions.row(r).into_iter().flat_map(|set| set.iter())
379376
}
380377

381378
/// Returns all the elements contained in a given region's value.
382-
pub(crate) fn placeholders_contained_in<'a>(
383-
&'a self,
379+
pub(crate) fn placeholders_contained_in(
380+
&self,
384381
r: N,
385382
) -> impl Iterator<Item = ty::PlaceholderRegion> {
386383
self.placeholders
@@ -391,7 +388,7 @@ impl<N: Idx> RegionValues<N> {
391388
}
392389

393390
/// Returns all the elements contained in a given region's value.
394-
pub(crate) fn elements_contained_in<'a>(&'a self, r: N) -> impl Iterator<Item = RegionElement> {
391+
pub(crate) fn elements_contained_in(&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/universal_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ impl<'tcx> UniversalRegions<'tcx> {
334334
}
335335

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

compiler/rustc_hir_analysis/src/collect.rs

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

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

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

549549
/// Converts the region constraints resulting from a query into an
550550
/// iterator of obligations.
551-
fn query_outlives_constraints_into_obligations<'a>(
552-
&'a self,
553-
cause: &'a ObligationCause<'tcx>,
551+
fn query_outlives_constraints_into_obligations(
552+
&self,
553+
cause: &ObligationCause<'tcx>,
554554
param_env: ty::ParamEnv<'tcx>,
555-
uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>],
556-
result_args: &'a CanonicalVarValues<'tcx>,
555+
uninstantiated_region_constraints: &[QueryOutlivesConstraint<'tcx>],
556+
result_args: &CanonicalVarValues<'tcx>,
557557
) -> impl Iterator<Item = PredicateObligation<'tcx>> {
558558
uninstantiated_region_constraints.iter().map(move |&constraint| {
559559
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
@@ -1473,9 +1473,7 @@ impl<'tcx> InferCtxt<'tcx> {
14731473
/// The returned function is used in a fast path. If it returns `true` the variable is
14741474
/// unchanged, `false` indicates that the status is unknown.
14751475
#[inline]
1476-
pub fn is_ty_infer_var_definitely_unchanged<'a>(
1477-
&'a self,
1478-
) -> impl Fn(TyOrConstInferVar) -> bool {
1476+
pub fn is_ty_infer_var_definitely_unchanged(&self) -> impl Fn(TyOrConstInferVar) -> bool {
14791477
// This hoists the borrow/release out of the loop body.
14801478
let inner = self.inner.try_borrow();
14811479

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
@@ -545,7 +545,7 @@ impl<'tcx> Body<'tcx> {
545545

546546
/// Returns an iterator over all user-declared mutable locals.
547547
#[inline]
548-
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> {
548+
pub fn mut_vars_iter(&self) -> impl Iterator<Item = Local> {
549549
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
550550
let local = Local::new(index);
551551
let decl = &self.local_decls[local];
@@ -555,7 +555,7 @@ impl<'tcx> Body<'tcx> {
555555

556556
/// Returns an iterator over all user-declared mutable arguments and locals.
557557
#[inline]
558-
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> {
558+
pub fn mut_vars_and_args_iter(&self) -> impl Iterator<Item = Local> {
559559
(1..self.local_decls.len()).filter_map(move |index| {
560560
let local = Local::new(index);
561561
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
@@ -1790,14 +1790,11 @@ impl<'tcx> TyCtxt<'tcx> {
17901790
}
17911791
}
17921792

1793-
pub fn get_attrs_by_path<'attr>(
1793+
pub fn get_attrs_by_path(
17941794
self,
17951795
did: DefId,
1796-
attr: &'attr [Symbol],
1797-
) -> impl Iterator<Item = &'tcx ast::Attribute>
1798-
where
1799-
'tcx: 'attr,
1800-
{
1796+
attr: &[Symbol],
1797+
) -> impl Iterator<Item = &'tcx ast::Attribute> {
18011798
let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr);
18021799
if let Some(did) = did.as_local() {
18031800
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
@@ -534,8 +534,8 @@ fn find_loop_backedges(
534534
backedges
535535
}
536536

537-
fn short_circuit_preorder<'a, 'tcx, F, Iter>(
538-
body: &'a mir::Body<'tcx>,
537+
fn short_circuit_preorder<'tcx, F, Iter>(
538+
body: &mir::Body<'tcx>,
539539
filtered_successors: F,
540540
) -> impl Iterator<Item = BasicBlock>
541541
where

compiler/rustc_mir_transform/src/coverage/spans.rs

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

171171
/// Similar to `.drain(..)`, but stops just before it would remove an item not
172172
/// satisfying the predicate.
173-
fn drain_front_while<'a, T>(
174-
queue: &'a mut VecDeque<T>,
173+
fn drain_front_while<T>(
174+
queue: &mut VecDeque<T>,
175175
mut pred_fn: impl FnMut(&T) -> bool,
176176
) -> impl Iterator<Item = T> {
177177
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
@@ -131,7 +131,7 @@ impl SsaLocals {
131131
}
132132

133133
pub fn assignments<'a, 'tcx>(
134-
&'a self,
134+
&self,
135135
body: &'a Body<'tcx>,
136136
) -> impl Iterator<Item = (Local, &'a Rvalue<'tcx>, Location)> {
137137
self.assignment_order.iter().filter_map(|&local| {

compiler/rustc_pattern_analysis/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ pub trait PatCx: Sized + fmt::Debug {
5757
fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize;
5858

5959
/// The types of the fields for this constructor. The result must contain `ctor_arity()` fields.
60-
fn ctor_sub_tys<'a>(
61-
&'a self,
62-
ctor: &'a Constructor<Self>,
63-
ty: &'a Self::Ty,
60+
fn ctor_sub_tys(
61+
&self,
62+
ctor: &Constructor<Self>,
63+
ty: &Self::Ty,
6464
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator;
6565

6666
/// The set of all the constructors for `ty`.

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(&self) -> impl Iterator<Item = &'p DeconstructedPat<Cx>> {
4545
self.patterns.iter().copied()
4646
}
4747

compiler/rustc_pattern_analysis/src/rustc.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
200200

201201
/// Returns the types of the fields for a given constructor. The result must have a length of
202202
/// `ctor.arity()`.
203-
pub(crate) fn ctor_sub_tys<'a>(
204-
&'a self,
205-
ctor: &'a Constructor<'p, 'tcx>,
203+
pub(crate) fn ctor_sub_tys(
204+
&self,
205+
ctor: &Constructor<'p, 'tcx>,
206206
ty: RevealedTy<'tcx>,
207207
) -> impl Iterator<Item = (RevealedTy<'tcx>, PrivateUninhabitedField)> + ExactSizeIterator {
208208
fn reveal_and_alloc<'a, 'tcx>(
@@ -935,10 +935,10 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> {
935935
fn ctor_arity(&self, ctor: &crate::constructor::Constructor<Self>, ty: &Self::Ty) -> usize {
936936
self.ctor_arity(ctor, *ty)
937937
}
938-
fn ctor_sub_tys<'a>(
939-
&'a self,
940-
ctor: &'a crate::constructor::Constructor<Self>,
941-
ty: &'a Self::Ty,
938+
fn ctor_sub_tys(
939+
&self,
940+
ctor: &crate::constructor::Constructor<Self>,
941+
ty: &Self::Ty,
942942
) -> impl Iterator<Item = (Self::Ty, PrivateUninhabitedField)> + ExactSizeIterator {
943943
self.ctor_sub_tys(ctor, *ty)
944944
}

0 commit comments

Comments
 (0)