Skip to content

Commit 04a3dd8

Browse files
committed
Auto merge of #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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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
}

0 commit comments

Comments
 (0)