Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnr

Lifetime cleanups

The last commit is very opinionated, let's see how we go.

r? `@oli-obk`
This commit is contained in:
León Orell Valerian Liehr 2024-09-14 18:12:13 +02:00 committed by GitHub
commit 03e8b6bbfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 224 additions and 231 deletions

View file

@ -62,14 +62,14 @@ impl<'tcx> crate::MirPass<'tcx> for CheckAlignment {
}
}
struct PointerFinder<'tcx, 'a> {
struct PointerFinder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
local_decls: &'a mut LocalDecls<'tcx>,
param_env: ParamEnv<'tcx>,
pointers: Vec<(Place<'tcx>, Ty<'tcx>)>,
}
impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> {
impl<'a, 'tcx> Visitor<'tcx> for PointerFinder<'a, 'tcx> {
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
// We want to only check reads and writes to Places, so we specifically exclude
// Borrow and RawBorrow.

View file

@ -554,13 +554,13 @@ impl<'tcx> Patch<'tcx> {
}
}
struct Collector<'tcx, 'locals> {
struct Collector<'a, 'tcx> {
patch: Patch<'tcx>,
local_decls: &'locals LocalDecls<'tcx>,
local_decls: &'a LocalDecls<'tcx>,
}
impl<'tcx, 'locals> Collector<'tcx, 'locals> {
pub(crate) fn new(tcx: TyCtxt<'tcx>, local_decls: &'locals LocalDecls<'tcx>) -> Self {
impl<'a, 'tcx> Collector<'a, 'tcx> {
pub(crate) fn new(tcx: TyCtxt<'tcx>, local_decls: &'a LocalDecls<'tcx>) -> Self {
Self { patch: Patch::new(tcx), local_decls }
}
@ -722,7 +722,7 @@ fn try_write_constant<'tcx>(
impl<'mir, 'tcx>
ResultsVisitor<'mir, 'tcx, Results<'tcx, ValueAnalysisWrapper<ConstAnalysis<'_, 'tcx>>>>
for Collector<'tcx, '_>
for Collector<'_, 'tcx>
{
type Domain = State<FlatSet<Scalar>>;
@ -839,9 +839,9 @@ impl<'tcx> MutVisitor<'tcx> for Patch<'tcx> {
}
}
struct OperandCollector<'a, 'locals, 'tcx> {
struct OperandCollector<'a, 'b, 'tcx> {
state: &'a State<FlatSet<Scalar>>,
visitor: &'a mut Collector<'tcx, 'locals>,
visitor: &'a mut Collector<'b, 'tcx>,
ecx: &'a mut InterpCx<'tcx, DummyMachine>,
map: &'a Map<'tcx>,
}

View file

@ -98,7 +98,7 @@ fn find_duplicates(body: &Body<'_>) -> FxHashMap<BasicBlock, BasicBlock> {
duplicates
}
struct BasicBlockHashable<'tcx, 'a> {
struct BasicBlockHashable<'a, 'tcx> {
basic_block_data: &'a BasicBlockData<'tcx>,
}

View file

@ -38,7 +38,7 @@ pub(super) fn build_projection<'tcx>(
]
}
struct ElaborateBoxDerefVisitor<'tcx, 'a> {
struct ElaborateBoxDerefVisitor<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
unique_did: DefId,
nonnull_did: DefId,
@ -46,7 +46,7 @@ struct ElaborateBoxDerefVisitor<'tcx, 'a> {
patch: MirPatch<'tcx>,
}
impl<'tcx, 'a> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'tcx, 'a> {
impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}

View file

@ -89,7 +89,7 @@ pub(crate) struct FnItemRef {
pub ident: String,
}
pub(crate) struct MustNotSupend<'tcx, 'a> {
pub(crate) struct MustNotSupend<'a, 'tcx> {
pub tcx: TyCtxt<'tcx>,
pub yield_sp: Span,
pub reason: Option<MustNotSuspendReason>,

View file

@ -63,13 +63,13 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify {
}
}
struct InstSimplifyContext<'tcx, 'a> {
struct InstSimplifyContext<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
local_decls: &'a LocalDecls<'tcx>,
param_env: ParamEnv<'tcx>,
}
impl<'tcx> InstSimplifyContext<'tcx, '_> {
impl<'tcx> InstSimplifyContext<'_, 'tcx> {
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
self.should_simplify_custom(source_info, "Rvalue", rvalue)
}

View file

@ -117,7 +117,7 @@ struct ThreadingOpportunity {
target: BasicBlock,
}
struct TOFinder<'tcx, 'a> {
struct TOFinder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
ecx: InterpCx<'tcx, DummyMachine>,
@ -183,7 +183,7 @@ impl<'a> ConditionSet<'a> {
}
}
impl<'tcx, 'a> TOFinder<'tcx, 'a> {
impl<'a, 'tcx> TOFinder<'a, 'tcx> {
fn is_empty(&self, state: &State<ConditionSet<'a>>) -> bool {
state.all_bottom()
}

View file

@ -295,7 +295,7 @@ struct SimplifyToExp {
}
#[derive(Clone, Copy)]
enum ExpectedTransformKind<'tcx, 'a> {
enum ExpectedTransformKind<'a, 'tcx> {
/// Identical statements.
Same(&'a StatementKind<'tcx>),
/// Assignment statements have the same value.

View file

@ -235,7 +235,7 @@ impl SsaLocals {
}
}
struct SsaVisitor<'tcx, 'a> {
struct SsaVisitor<'a, 'tcx> {
body: &'a Body<'tcx>,
dominators: &'a Dominators<BasicBlock>,
assignments: IndexVec<Local, Set1<DefLocation>>,
@ -261,7 +261,7 @@ impl SsaVisitor<'_, '_> {
}
}
impl<'tcx> Visitor<'tcx> for SsaVisitor<'tcx, '_> {
impl<'tcx> Visitor<'tcx> for SsaVisitor<'_, 'tcx> {
fn visit_local(&mut self, local: Local, ctxt: PlaceContext, loc: Location) {
match ctxt {
PlaceContext::MutatingUse(MutatingUseContext::Projection)