Skip to content

Commit 04a3dd8

Browse files
committed
Auto merge of rust-lang#61891 - eddyb:lifetime-cleanups, r=oli-obk
rustc: remove 'x: 'y bounds (except where necessary or from comments/strings). This PR removes all lifetime-lifetime "outlives" bounds (e.g. `'tcx: 'a`) bounds except a few necessary ones (see the `reintroduce lifetime bounds where necessary` commit). Some of these bounds kept around otherwise-unused lifetimes (e.g. `<'a, 'tcx: 'a>` followed by uses of `'tcx` but not `'a`) - these lifetimes (i.e. `'a`) were then removed. (maybe they should be considered unused by the lint? cc @matthewjasper @zackmdavis) r? @oli-obk cc @rust-lang/compiler
2 parents 673cf7d + 2be847b commit 04a3dd8

File tree

154 files changed

+399
-387
lines changed

Some content is hidden

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

154 files changed

+399
-387
lines changed

src/librustc/cfg/construct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::ty::{self, TyCtxt};
77
use crate::hir::{self, PatKind};
88
use crate::hir::def_id::DefId;
99

10-
struct CFGBuilder<'a, 'tcx: 'a> {
10+
struct CFGBuilder<'a, 'tcx> {
1111
tcx: TyCtxt<'tcx>,
1212
owner_def_id: DefId,
1313
tables: &'a ty::TypeckTables<'tcx>,

src/librustc/cfg/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::ty::TyCtxt;
1111
pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
1212
pub type Edge<'a> = &'a cfg::CFGEdge;
1313

14-
pub struct LabelledCFG<'a, 'tcx: 'a> {
14+
pub struct LabelledCFG<'a, 'tcx> {
1515
pub tcx: TyCtxt<'tcx>,
1616
pub cfg: &'a cfg::CFG,
1717
pub name: String,

src/librustc/dep_graph/dep_node.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,9 @@ macro_rules! define_dep_nodes {
204204
impl DepNode {
205205
#[allow(unreachable_code, non_snake_case)]
206206
#[inline(always)]
207-
pub fn new<'a, 'tcx>(tcx: TyCtxt<'tcx>,
207+
pub fn new<'tcx>(tcx: TyCtxt<'tcx>,
208208
dep: DepConstructor<'tcx>)
209209
-> DepNode
210-
where 'tcx: 'a,
211-
'tcx: 'a
212210
{
213211
match dep {
214212
$(

src/librustc/hir/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a> FnKind<'a> {
7474
///
7575
/// See the comments on `ItemLikeVisitor` for more details on the overall
7676
/// visit strategy.
77-
pub enum NestedVisitorMap<'this, 'tcx: 'this> {
77+
pub enum NestedVisitorMap<'this, 'tcx> {
7878
/// Do not visit any nested things. When you add a new
7979
/// "non-nested" thing, you will want to audit such uses to see if
8080
/// they remain valid.

src/librustc/hir/lowering.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<'a> LoweringContext<'a> {
415415
/// needed from arbitrary locations in the crate,
416416
/// e.g., the number of lifetime generic parameters
417417
/// declared for every type and trait definition.
418-
struct MiscCollector<'tcx, 'interner: 'tcx> {
418+
struct MiscCollector<'tcx, 'interner> {
419419
lctx: &'tcx mut LoweringContext<'interner>,
420420
hir_id_owner: Option<NodeId>,
421421
}
@@ -561,7 +561,7 @@ impl<'a> LoweringContext<'a> {
561561
}
562562
}
563563

564-
struct ItemLowerer<'tcx, 'interner: 'tcx> {
564+
struct ItemLowerer<'tcx, 'interner> {
565565
lctx: &'tcx mut LoweringContext<'interner>,
566566
}
567567

@@ -1788,7 +1788,7 @@ impl<'a> LoweringContext<'a> {
17881788
// This visitor walks over `impl Trait` bounds and creates defs for all lifetimes that
17891789
// appear in the bounds, excluding lifetimes that are created within the bounds.
17901790
// E.g., `'a`, `'b`, but not `'c` in `impl for<'c> SomeTrait<'a, 'b, 'c>`.
1791-
struct ImplTraitLifetimeCollector<'r, 'a: 'r> {
1791+
struct ImplTraitLifetimeCollector<'r, 'a> {
17921792
context: &'r mut LoweringContext<'a>,
17931793
parent: DefIndex,
17941794
exist_ty_id: NodeId,
@@ -1799,7 +1799,7 @@ impl<'a> LoweringContext<'a> {
17991799
output_lifetime_params: Vec<hir::GenericParam>,
18001800
}
18011801

1802-
impl<'r, 'a: 'r, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> {
1802+
impl<'r, 'a, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> {
18031803
fn nested_visit_map<'this>(
18041804
&'this mut self,
18051805
) -> hir::intravisit::NestedVisitorMap<'this, 'v> {

src/librustc/hir/map/hir_id_validator.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) {
2626
}
2727
}
2828

29-
struct HirIdValidator<'a, 'hir: 'a> {
29+
struct HirIdValidator<'a, 'hir> {
3030
hir_map: &'a hir::map::Map<'hir>,
3131
owner_def_index: Option<DefIndex>,
3232
hir_ids_seen: FxHashSet<ItemLocalId>,
3333
errors: &'a Lock<Vec<String>>,
3434
}
3535

36-
struct OuterVisitor<'a, 'hir: 'a> {
36+
struct OuterVisitor<'a, 'hir> {
3737
hir_map: &'a hir::map::Map<'hir>,
3838
errors: &'a Lock<Vec<String>>,
3939
}
4040

41-
impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> {
41+
impl<'a, 'hir> OuterVisitor<'a, 'hir> {
4242
fn new_inner_visitor(&self,
4343
hir_map: &'a hir::map::Map<'hir>)
4444
-> HirIdValidator<'a, 'hir> {
@@ -51,7 +51,7 @@ impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> {
5151
}
5252
}
5353

54-
impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
54+
impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
5555
fn visit_item(&mut self, i: &'hir hir::Item) {
5656
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
5757
inner_visitor.check(i.hir_id, |this| intravisit::walk_item(this, i));
@@ -68,7 +68,7 @@ impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
6868
}
6969
}
7070

71-
impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
71+
impl<'a, 'hir> HirIdValidator<'a, 'hir> {
7272
#[cold]
7373
#[inline(never)]
7474
fn error(&self, f: impl FnOnce() -> String) {
@@ -133,7 +133,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
133133
}
134134
}
135135

136-
impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
136+
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
137137

138138
fn nested_visit_map<'this>(&'this mut self)
139139
-> intravisit::NestedVisitorMap<'this, 'hir> {

src/librustc/infer/at.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ use super::*;
3030
use crate::ty::Const;
3131
use crate::ty::relate::{Relate, TypeRelation};
3232

33-
pub struct At<'a, 'tcx: 'a> {
33+
pub struct At<'a, 'tcx> {
3434
pub infcx: &'a InferCtxt<'a, 'tcx>,
3535
pub cause: &'a ObligationCause<'tcx>,
3636
pub param_env: ty::ParamEnv<'tcx>,
3737
}
3838

39-
pub struct Trace<'a, 'tcx: 'a> {
39+
pub struct Trace<'a, 'tcx> {
4040
at: At<'a, 'tcx>,
4141
a_is_expected: bool,
4242
trace: TypeTrace<'tcx>,

src/librustc/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
275275
}
276276
}
277277

278-
struct Canonicalizer<'cx, 'tcx: 'cx> {
278+
struct Canonicalizer<'cx, 'tcx> {
279279
infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
280280
tcx: TyCtxt<'tcx>,
281281
variables: SmallVec<[CanonicalVarInfo; 8]>,

src/librustc/infer/combine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use syntax::ast;
4444
use syntax_pos::{Span, DUMMY_SP};
4545

4646
#[derive(Clone)]
47-
pub struct CombineFields<'infcx, 'tcx: 'infcx> {
47+
pub struct CombineFields<'infcx, 'tcx> {
4848
pub infcx: &'infcx InferCtxt<'infcx, 'tcx>,
4949
pub trace: TypeTrace<'tcx>,
5050
pub cause: Option<ty::relate::Cause>,
@@ -355,7 +355,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
355355
}
356356
}
357357

358-
struct Generalizer<'cx, 'tcx: 'cx> {
358+
struct Generalizer<'cx, 'tcx> {
359359
infcx: &'cx InferCtxt<'cx, 'tcx>,
360360

361361
/// The span, used when creating new type variables and things.

src/librustc/infer/equate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::mir::interpret::ConstValue;
1111
use crate::infer::unify_key::replace_if_possible;
1212

1313
/// Ensures `a` is made equal to `b`. Returns `a` on success.
14-
pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
14+
pub struct Equate<'combine, 'infcx, 'tcx> {
1515
fields: &'combine mut CombineFields<'infcx, 'tcx>,
1616
a_is_expected: bool,
1717
}

src/librustc/infer/error_reporting/nice_region_error/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
3030
}
3131
}
3232

33-
pub struct NiceRegionError<'cx, 'tcx: 'cx> {
33+
pub struct NiceRegionError<'cx, 'tcx> {
3434
infcx: &'cx InferCtxt<'cx, 'tcx>,
3535
error: Option<RegionResolutionError<'tcx>>,
3636
regions: Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)>,

src/librustc/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use std::collections::hash_map::Entry;
4141
use super::InferCtxt;
4242
use super::unify_key::ToType;
4343

44-
pub struct TypeFreshener<'a, 'tcx: 'a> {
44+
pub struct TypeFreshener<'a, 'tcx> {
4545
infcx: &'a InferCtxt<'a, 'tcx>,
4646
ty_freshen_count: u32,
4747
const_freshen_count: u32,

src/librustc/infer/fudge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
133133
}
134134
}
135135

136-
pub struct InferenceFudger<'a, 'tcx: 'a> {
136+
pub struct InferenceFudger<'a, 'tcx> {
137137
infcx: &'a InferCtxt<'a, 'tcx>,
138138
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
139139
int_vars: Range<IntVid>,

src/librustc/infer/glb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::ty::{self, Ty, TyCtxt};
88
use crate::ty::relate::{Relate, RelateResult, TypeRelation};
99

1010
/// "Greatest lower bound" (common subtype)
11-
pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
11+
pub struct Glb<'combine, 'infcx, 'tcx> {
1212
fields: &'combine mut CombineFields<'infcx, 'tcx>,
1313
a_is_expected: bool,
1414
}

src/librustc/infer/lattice.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::ty::TyVar;
2727
use crate::ty::{self, Ty};
2828
use crate::ty::relate::{RelateResult, TypeRelation};
2929

30-
pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> {
30+
pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
3131
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
3232

3333
fn cause(&self) -> &ObligationCause<'tcx>;
@@ -41,14 +41,13 @@ pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> {
4141
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
4242
}
4343

44-
pub fn super_lattice_tys<'a, 'tcx, L>(
44+
pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
4545
this: &mut L,
4646
a: Ty<'tcx>,
4747
b: Ty<'tcx>,
4848
) -> RelateResult<'tcx, Ty<'tcx>>
4949
where
5050
L: LatticeDir<'a, 'tcx>,
51-
'tcx: 'a,
5251
{
5352
debug!("{}.lattice_tys({:?}, {:?})",
5453
this.tag(),

src/librustc/infer/lexical_region_resolve/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(
107107
}
108108
}
109109

110-
struct ConstraintGraph<'a, 'tcx: 'a> {
110+
struct ConstraintGraph<'a, 'tcx> {
111111
graph_name: String,
112112
region_rels: &'a RegionRelations<'a, 'tcx>,
113113
map: &'a BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,

src/librustc/infer/lexical_region_resolve/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct RegionAndOrigin<'tcx> {
9393

9494
type RegionGraph<'tcx> = Graph<(), Constraint<'tcx>>;
9595

96-
struct LexicalResolver<'cx, 'tcx: 'cx> {
96+
struct LexicalResolver<'cx, 'tcx> {
9797
region_rels: &'cx RegionRelations<'cx, 'tcx>,
9898
var_infos: VarInfos,
9999
data: RegionConstraintData<'tcx>,

src/librustc/infer/lub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::ty::{self, Ty, TyCtxt};
88
use crate::ty::relate::{Relate, RelateResult, TypeRelation};
99

1010
/// "Least upper bound" (common supertype)
11-
pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
11+
pub struct Lub<'combine, 'infcx, 'tcx> {
1212
fields: &'combine mut CombineFields<'infcx, 'tcx>,
1313
a_is_expected: bool,
1414
}

src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ impl<'tcx> InferOk<'tcx, ()> {
585585
}
586586

587587
#[must_use = "once you start a snapshot, you should always consume it"]
588-
pub struct CombinedSnapshot<'a, 'tcx: 'a> {
588+
pub struct CombinedSnapshot<'a, 'tcx> {
589589
projection_cache_snapshot: traits::ProjectionCacheSnapshot,
590590
type_snapshot: type_variable::Snapshot<'tcx>,
591591
const_snapshot: ut::Snapshot<ut::InPlace<ty::ConstVid<'tcx>>>,

src/librustc/infer/nll_relate/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum NormalizationStrategy {
3838
Eager,
3939
}
4040

41-
pub struct TypeRelating<'me, 'tcx: 'me, D>
41+
pub struct TypeRelating<'me, 'tcx, D>
4242
where
4343
D: TypeRelatingDelegate<'tcx>,
4444
{
@@ -741,7 +741,7 @@ where
741741
/// binder depth, and finds late-bound regions targeting the
742742
/// `for<..`>. For each of those, it creates an entry in
743743
/// `bound_region_scope`.
744-
struct ScopeInstantiator<'me, 'tcx: 'me> {
744+
struct ScopeInstantiator<'me, 'tcx> {
745745
next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
746746
// The debruijn index of the scope we are instantiating.
747747
target_index: ty::DebruijnIndex,
@@ -798,7 +798,7 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
798798
/// scopes.
799799
///
800800
/// [blog post]: https://is.gd/0hKvIr
801-
struct TypeGeneralizer<'me, 'tcx: 'me, D>
801+
struct TypeGeneralizer<'me, 'tcx, D>
802802
where
803803
D: TypeRelatingDelegate<'tcx> + 'me,
804804
{

src/librustc/infer/opaque_types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
723723
}
724724
}
725725

726-
struct Instantiator<'a, 'tcx: 'a> {
726+
struct Instantiator<'a, 'tcx> {
727727
infcx: &'a InferCtxt<'a, 'tcx>,
728728
parent_def_id: DefId,
729729
body_id: hir::HirId,

src/librustc/infer/outlives/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct OutlivesEnvironment<'tcx> {
6767
/// because of implied bounds.
6868
pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>;
6969

70-
impl<'a, 'tcx: 'a> OutlivesEnvironment<'tcx> {
70+
impl<'a, 'tcx> OutlivesEnvironment<'tcx> {
7171
pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self {
7272
let mut env = OutlivesEnvironment {
7373
param_env,

src/librustc/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
226226
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
227227
/// accrues them into the `region_obligations` code, but for NLL we
228228
/// use something else.
229-
pub struct TypeOutlives<'cx, 'tcx: 'cx, D>
229+
pub struct TypeOutlives<'cx, 'tcx, D>
230230
where
231231
D: TypeOutlivesDelegate<'tcx>,
232232
{

src/librustc/infer/outlives/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::util::captures::Captures;
1212
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
1313
/// accrues them into the `region_obligations` code, but for NLL we
1414
/// use something else.
15-
pub struct VerifyBoundCx<'cx, 'tcx: 'cx> {
15+
pub struct VerifyBoundCx<'cx, 'tcx> {
1616
tcx: TyCtxt<'tcx>,
1717
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
1818
implicit_region_bound: Option<ty::Region<'tcx>>,

src/librustc/infer/resolve.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::ty::fold::{TypeFolder, TypeVisitor};
1212
/// been unified with (similar to `shallow_resolve`, but deep). This is
1313
/// useful for printing messages etc but also required at various
1414
/// points for correctness.
15-
pub struct OpportunisticVarResolver<'a, 'tcx: 'a> {
15+
pub struct OpportunisticVarResolver<'a, 'tcx> {
1616
infcx: &'a InferCtxt<'a, 'tcx>,
1717
}
1818

@@ -50,7 +50,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
5050
/// The opportunistic type and region resolver is similar to the
5151
/// opportunistic type resolver, but also opportunistically resolves
5252
/// regions. It is useful for canonicalization.
53-
pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx: 'a> {
53+
pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx> {
5454
infcx: &'a InferCtxt<'a, 'tcx>,
5555
}
5656

@@ -101,7 +101,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx>
101101
/// type variables that don't yet have a value. The first unresolved type is stored.
102102
/// It does not construct the fully resolved type (which might
103103
/// involve some hashing and so forth).
104-
pub struct UnresolvedTypeFinder<'a, 'tcx: 'a> {
104+
pub struct UnresolvedTypeFinder<'a, 'tcx> {
105105
infcx: &'a InferCtxt<'a, 'tcx>,
106106

107107
/// Used to find the type parameter name and location for error reporting.
@@ -171,7 +171,7 @@ where
171171

172172
// N.B. This type is not public because the protocol around checking the
173173
// `err` field is not enforcable otherwise.
174-
struct FullTypeResolver<'a, 'tcx: 'a> {
174+
struct FullTypeResolver<'a, 'tcx> {
175175
infcx: &'a InferCtxt<'a, 'tcx>,
176176
err: Option<FixupError<'tcx>>,
177177
}

src/librustc/infer/sub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::mir::interpret::ConstValue;
1111
use std::mem;
1212

1313
/// Ensures `a` is made a subtype of `b`. Returns `a` on success.
14-
pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
14+
pub struct Sub<'combine, 'infcx, 'tcx> {
1515
fields: &'combine mut CombineFields<'infcx, 'tcx>,
1616
a_is_expected: bool,
1717
}

0 commit comments

Comments
 (0)