Skip to content

Commit

Permalink
Auto merge of #61891 - eddyb:lifetime-cleanups, r=oli-obk
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 18, 2019
2 parents 673cf7d + 2be847b commit 04a3dd8
Show file tree
Hide file tree
Showing 154 changed files with 399 additions and 387 deletions.
2 changes: 1 addition & 1 deletion src/librustc/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::ty::{self, TyCtxt};
use crate::hir::{self, PatKind};
use crate::hir::def_id::DefId;

struct CFGBuilder<'a, 'tcx: 'a> {
struct CFGBuilder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
owner_def_id: DefId,
tables: &'a ty::TypeckTables<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/cfg/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::ty::TyCtxt;
pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
pub type Edge<'a> = &'a cfg::CFGEdge;

pub struct LabelledCFG<'a, 'tcx: 'a> {
pub struct LabelledCFG<'a, 'tcx> {
pub tcx: TyCtxt<'tcx>,
pub cfg: &'a cfg::CFG,
pub name: String,
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ macro_rules! define_dep_nodes {
impl DepNode {
#[allow(unreachable_code, non_snake_case)]
#[inline(always)]
pub fn new<'a, 'tcx>(tcx: TyCtxt<'tcx>,
pub fn new<'tcx>(tcx: TyCtxt<'tcx>,
dep: DepConstructor<'tcx>)
-> DepNode
where 'tcx: 'a,
'tcx: 'a
{
match dep {
$(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'a> FnKind<'a> {
///
/// See the comments on `ItemLikeVisitor` for more details on the overall
/// visit strategy.
pub enum NestedVisitorMap<'this, 'tcx: 'this> {
pub enum NestedVisitorMap<'this, 'tcx> {
/// Do not visit any nested things. When you add a new
/// "non-nested" thing, you will want to audit such uses to see if
/// they remain valid.
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<'a> LoweringContext<'a> {
/// needed from arbitrary locations in the crate,
/// e.g., the number of lifetime generic parameters
/// declared for every type and trait definition.
struct MiscCollector<'tcx, 'interner: 'tcx> {
struct MiscCollector<'tcx, 'interner> {
lctx: &'tcx mut LoweringContext<'interner>,
hir_id_owner: Option<NodeId>,
}
Expand Down Expand Up @@ -561,7 +561,7 @@ impl<'a> LoweringContext<'a> {
}
}

struct ItemLowerer<'tcx, 'interner: 'tcx> {
struct ItemLowerer<'tcx, 'interner> {
lctx: &'tcx mut LoweringContext<'interner>,
}

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

impl<'r, 'a: 'r, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> {
impl<'r, 'a, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> {
fn nested_visit_map<'this>(
&'this mut self,
) -> hir::intravisit::NestedVisitorMap<'this, 'v> {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/hir/map/hir_id_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) {
}
}

struct HirIdValidator<'a, 'hir: 'a> {
struct HirIdValidator<'a, 'hir> {
hir_map: &'a hir::map::Map<'hir>,
owner_def_index: Option<DefIndex>,
hir_ids_seen: FxHashSet<ItemLocalId>,
errors: &'a Lock<Vec<String>>,
}

struct OuterVisitor<'a, 'hir: 'a> {
struct OuterVisitor<'a, 'hir> {
hir_map: &'a hir::map::Map<'hir>,
errors: &'a Lock<Vec<String>>,
}

impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> {
impl<'a, 'hir> OuterVisitor<'a, 'hir> {
fn new_inner_visitor(&self,
hir_map: &'a hir::map::Map<'hir>)
-> HirIdValidator<'a, 'hir> {
Expand All @@ -51,7 +51,7 @@ impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> {
}
}

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

impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
impl<'a, 'hir> HirIdValidator<'a, 'hir> {
#[cold]
#[inline(never)]
fn error(&self, f: impl FnOnce() -> String) {
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
}
}

impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {

fn nested_visit_map<'this>(&'this mut self)
-> intravisit::NestedVisitorMap<'this, 'hir> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ use super::*;
use crate::ty::Const;
use crate::ty::relate::{Relate, TypeRelation};

pub struct At<'a, 'tcx: 'a> {
pub struct At<'a, 'tcx> {
pub infcx: &'a InferCtxt<'a, 'tcx>,
pub cause: &'a ObligationCause<'tcx>,
pub param_env: ty::ParamEnv<'tcx>,
}

pub struct Trace<'a, 'tcx: 'a> {
pub struct Trace<'a, 'tcx> {
at: At<'a, 'tcx>,
a_is_expected: bool,
trace: TypeTrace<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
}
}

struct Canonicalizer<'cx, 'tcx: 'cx> {
struct Canonicalizer<'cx, 'tcx> {
infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
tcx: TyCtxt<'tcx>,
variables: SmallVec<[CanonicalVarInfo; 8]>,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use syntax::ast;
use syntax_pos::{Span, DUMMY_SP};

#[derive(Clone)]
pub struct CombineFields<'infcx, 'tcx: 'infcx> {
pub struct CombineFields<'infcx, 'tcx> {
pub infcx: &'infcx InferCtxt<'infcx, 'tcx>,
pub trace: TypeTrace<'tcx>,
pub cause: Option<ty::relate::Cause>,
Expand Down Expand Up @@ -355,7 +355,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
}
}

struct Generalizer<'cx, 'tcx: 'cx> {
struct Generalizer<'cx, 'tcx> {
infcx: &'cx InferCtxt<'cx, 'tcx>,

/// The span, used when creating new type variables and things.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::mir::interpret::ConstValue;
use crate::infer::unify_key::replace_if_possible;

/// Ensures `a` is made equal to `b`. Returns `a` on success.
pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
pub struct Equate<'combine, 'infcx, 'tcx> {
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
}
}

pub struct NiceRegionError<'cx, 'tcx: 'cx> {
pub struct NiceRegionError<'cx, 'tcx> {
infcx: &'cx InferCtxt<'cx, 'tcx>,
error: Option<RegionResolutionError<'tcx>>,
regions: Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::collections::hash_map::Entry;
use super::InferCtxt;
use super::unify_key::ToType;

pub struct TypeFreshener<'a, 'tcx: 'a> {
pub struct TypeFreshener<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
ty_freshen_count: u32,
const_freshen_count: u32,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/fudge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}

pub struct InferenceFudger<'a, 'tcx: 'a> {
pub struct InferenceFudger<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
int_vars: Range<IntVid>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::ty::{self, Ty, TyCtxt};
use crate::ty::relate::{Relate, RelateResult, TypeRelation};

/// "Greatest lower bound" (common subtype)
pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
pub struct Glb<'combine, 'infcx, 'tcx> {
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/infer/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::ty::TyVar;
use crate::ty::{self, Ty};
use crate::ty::relate::{RelateResult, TypeRelation};

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

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

pub fn super_lattice_tys<'a, 'tcx, L>(
pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
this: &mut L,
a: Ty<'tcx>,
b: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
L: LatticeDir<'a, 'tcx>,
'tcx: 'a,
{
debug!("{}.lattice_tys({:?}, {:?})",
this.tag(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/lexical_region_resolve/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(
}
}

struct ConstraintGraph<'a, 'tcx: 'a> {
struct ConstraintGraph<'a, 'tcx> {
graph_name: String,
region_rels: &'a RegionRelations<'a, 'tcx>,
map: &'a BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct RegionAndOrigin<'tcx> {

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

struct LexicalResolver<'cx, 'tcx: 'cx> {
struct LexicalResolver<'cx, 'tcx> {
region_rels: &'cx RegionRelations<'cx, 'tcx>,
var_infos: VarInfos,
data: RegionConstraintData<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::ty::{self, Ty, TyCtxt};
use crate::ty::relate::{Relate, RelateResult, TypeRelation};

/// "Least upper bound" (common supertype)
pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
pub struct Lub<'combine, 'infcx, 'tcx> {
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ impl<'tcx> InferOk<'tcx, ()> {
}

#[must_use = "once you start a snapshot, you should always consume it"]
pub struct CombinedSnapshot<'a, 'tcx: 'a> {
pub struct CombinedSnapshot<'a, 'tcx> {
projection_cache_snapshot: traits::ProjectionCacheSnapshot,
type_snapshot: type_variable::Snapshot<'tcx>,
const_snapshot: ut::Snapshot<ut::InPlace<ty::ConstVid<'tcx>>>,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum NormalizationStrategy {
Eager,
}

pub struct TypeRelating<'me, 'tcx: 'me, D>
pub struct TypeRelating<'me, 'tcx, D>
where
D: TypeRelatingDelegate<'tcx>,
{
Expand Down Expand Up @@ -741,7 +741,7 @@ where
/// binder depth, and finds late-bound regions targeting the
/// `for<..`>. For each of those, it creates an entry in
/// `bound_region_scope`.
struct ScopeInstantiator<'me, 'tcx: 'me> {
struct ScopeInstantiator<'me, 'tcx> {
next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
// The debruijn index of the scope we are instantiating.
target_index: ty::DebruijnIndex,
Expand Down Expand Up @@ -798,7 +798,7 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
/// scopes.
///
/// [blog post]: https://is.gd/0hKvIr
struct TypeGeneralizer<'me, 'tcx: 'me, D>
struct TypeGeneralizer<'me, 'tcx, D>
where
D: TypeRelatingDelegate<'tcx> + 'me,
{
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
}
}

struct Instantiator<'a, 'tcx: 'a> {
struct Instantiator<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
parent_def_id: DefId,
body_id: hir::HirId,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/outlives/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct OutlivesEnvironment<'tcx> {
/// because of implied bounds.
pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>;

impl<'a, 'tcx: 'a> OutlivesEnvironment<'tcx> {
impl<'a, 'tcx> OutlivesEnvironment<'tcx> {
pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self {
let mut env = OutlivesEnvironment {
param_env,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
/// accrues them into the `region_obligations` code, but for NLL we
/// use something else.
pub struct TypeOutlives<'cx, 'tcx: 'cx, D>
pub struct TypeOutlives<'cx, 'tcx, D>
where
D: TypeOutlivesDelegate<'tcx>,
{
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::util::captures::Captures;
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
/// accrues them into the `region_obligations` code, but for NLL we
/// use something else.
pub struct VerifyBoundCx<'cx, 'tcx: 'cx> {
pub struct VerifyBoundCx<'cx, 'tcx> {
tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::ty::fold::{TypeFolder, TypeVisitor};
/// been unified with (similar to `shallow_resolve`, but deep). This is
/// useful for printing messages etc but also required at various
/// points for correctness.
pub struct OpportunisticVarResolver<'a, 'tcx: 'a> {
pub struct OpportunisticVarResolver<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
}

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

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

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

// N.B. This type is not public because the protocol around checking the
// `err` field is not enforcable otherwise.
struct FullTypeResolver<'a, 'tcx: 'a> {
struct FullTypeResolver<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
err: Option<FixupError<'tcx>>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::mir::interpret::ConstValue;
use std::mem;

/// Ensures `a` is made a subtype of `b`. Returns `a` on success.
pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
pub struct Sub<'combine, 'infcx, 'tcx> {
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
}
Expand Down
Loading

0 comments on commit 04a3dd8

Please sign in to comment.