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:
commit
03e8b6bbfa
49 changed files with 224 additions and 231 deletions
|
@ -267,16 +267,16 @@ pub(crate) struct MacroExprFragment2024 {
|
|||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
pub(crate) struct BuiltinTypeAliasBounds<'a, 'hir> {
|
||||
pub(crate) struct BuiltinTypeAliasBounds<'hir> {
|
||||
pub in_where_clause: bool,
|
||||
pub label: Span,
|
||||
pub enable_feat_help: bool,
|
||||
pub suggestions: Vec<(Span, String)>,
|
||||
pub preds: &'hir [hir::WherePredicate<'hir>],
|
||||
pub ty: Option<&'a hir::Ty<'hir>>,
|
||||
pub ty: Option<&'hir hir::Ty<'hir>>,
|
||||
}
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinTypeAliasBounds<'_, '_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(if self.in_where_clause {
|
||||
fluent::lint_builtin_type_alias_bounds_where_clause
|
||||
|
|
|
@ -143,18 +143,18 @@ impl<'tcx> LateLintPass<'tcx> for TailExprDropOrder {
|
|||
}
|
||||
}
|
||||
|
||||
struct LintVisitor<'tcx, 'a> {
|
||||
struct LintVisitor<'a, 'tcx> {
|
||||
cx: &'a LateContext<'tcx>,
|
||||
// We only record locals that have significant drops
|
||||
locals: Vec<Span>,
|
||||
}
|
||||
|
||||
struct LocalCollector<'tcx, 'a> {
|
||||
struct LocalCollector<'a, 'tcx> {
|
||||
cx: &'a LateContext<'tcx>,
|
||||
locals: &'a mut Vec<Span>,
|
||||
}
|
||||
|
||||
impl<'tcx, 'a> Visitor<'tcx> for LocalCollector<'tcx, 'a> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for LocalCollector<'a, 'tcx> {
|
||||
type Result = ();
|
||||
fn visit_pat(&mut self, pat: &'tcx Pat<'tcx>) {
|
||||
if let PatKind::Binding(_binding_mode, id, ident, pat) = pat.kind {
|
||||
|
@ -171,7 +171,7 @@ impl<'tcx, 'a> Visitor<'tcx> for LocalCollector<'tcx, 'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 'a> Visitor<'tcx> for LintVisitor<'tcx, 'a> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for LintVisitor<'a, 'tcx> {
|
||||
fn visit_block(&mut self, block: &'tcx Block<'tcx>) {
|
||||
let mut locals = <_>::default();
|
||||
swap(&mut locals, &mut self.locals);
|
||||
|
@ -183,7 +183,7 @@ impl<'tcx, 'a> Visitor<'tcx> for LintVisitor<'tcx, 'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 'a> LintVisitor<'tcx, 'a> {
|
||||
impl<'a, 'tcx> LintVisitor<'a, 'tcx> {
|
||||
fn check_block_inner(&mut self, block: &Block<'tcx>) {
|
||||
if !block.span.at_least_rust_2024() {
|
||||
// We only lint for Edition 2024 onwards
|
||||
|
@ -205,13 +205,13 @@ impl<'tcx, 'a> LintVisitor<'tcx, 'a> {
|
|||
}
|
||||
}
|
||||
|
||||
struct LintTailExpr<'tcx, 'a> {
|
||||
struct LintTailExpr<'a, 'tcx> {
|
||||
cx: &'a LateContext<'tcx>,
|
||||
is_root_tail_expr: bool,
|
||||
locals: &'a [Span],
|
||||
}
|
||||
|
||||
impl<'tcx, 'a> LintTailExpr<'tcx, 'a> {
|
||||
impl<'a, 'tcx> LintTailExpr<'a, 'tcx> {
|
||||
fn expr_eventually_point_into_local(mut expr: &Expr<'tcx>) -> bool {
|
||||
loop {
|
||||
match expr.kind {
|
||||
|
@ -239,7 +239,7 @@ impl<'tcx, 'a> LintTailExpr<'tcx, 'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 'a> Visitor<'tcx> for LintTailExpr<'tcx, 'a> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for LintTailExpr<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
|
||||
if self.is_root_tail_expr {
|
||||
self.is_root_tail_expr = false;
|
||||
|
|
|
@ -1713,13 +1713,13 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
hir_ty: &hir::Ty<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Vec<(Ty<'tcx>, Span)> {
|
||||
struct FnPtrFinder<'parent, 'a, 'tcx> {
|
||||
visitor: &'parent ImproperCTypesVisitor<'a, 'tcx>,
|
||||
struct FnPtrFinder<'a, 'b, 'tcx> {
|
||||
visitor: &'a ImproperCTypesVisitor<'b, 'tcx>,
|
||||
spans: Vec<Span>,
|
||||
tys: Vec<Ty<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'parent, 'a, 'tcx> hir::intravisit::Visitor<'_> for FnPtrFinder<'parent, 'a, 'tcx> {
|
||||
impl<'a, 'b, 'tcx> hir::intravisit::Visitor<'_> for FnPtrFinder<'a, 'b, 'tcx> {
|
||||
fn visit_ty(&mut self, ty: &'_ hir::Ty<'_>) {
|
||||
debug!(?ty);
|
||||
if let hir::TyKind::BareFn(hir::BareFnTy { abi, .. }) = ty.kind
|
||||
|
@ -1732,7 +1732,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'vis, 'a, 'tcx> ty::visit::TypeVisitor<TyCtxt<'tcx>> for FnPtrFinder<'vis, 'a, 'tcx> {
|
||||
impl<'a, 'b, 'tcx> ty::visit::TypeVisitor<TyCtxt<'tcx>> for FnPtrFinder<'a, 'b, 'tcx> {
|
||||
type Result = ControlFlow<Ty<'tcx>>;
|
||||
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
|
||||
|
@ -1746,7 +1746,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
let mut visitor = FnPtrFinder { visitor: &*self, spans: Vec::new(), tys: Vec::new() };
|
||||
let mut visitor = FnPtrFinder { visitor: self, spans: Vec::new(), tys: Vec::new() };
|
||||
ty.visit_with(&mut visitor);
|
||||
hir::intravisit::Visitor::visit_ty(&mut visitor, hir_ty);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue