Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ceb45d5

Browse files
committed
Don't require visit_body to take a lifetime that must outlive the function call
1 parent 5870f1c commit ceb45d5

File tree

20 files changed

+27
-31
lines changed

20 files changed

+27
-31
lines changed

compiler/rustc_hir/src/intravisit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ pub trait Visitor<'v>: Sized {
299299
walk_item(self, i)
300300
}
301301

302-
fn visit_body(&mut self, b: &'v Body<'v>) -> Self::Result {
302+
fn visit_body(&mut self, b: &Body<'v>) -> Self::Result {
303303
walk_body(self, b)
304304
}
305305

@@ -578,7 +578,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
578578
V::Result::output()
579579
}
580580

581-
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) -> V::Result {
581+
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &Body<'v>) -> V::Result {
582582
walk_list!(visitor, visit_param, body.params);
583583
visitor.visit_expr(body.value)
584584
}

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
818818
resolve_block(self, b);
819819
}
820820

821-
fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
821+
fn visit_body(&mut self, body: &hir::Body<'tcx>) {
822822
let body_id = body.id();
823823
let owner_id = self.tcx.hir().body_owner_def_id(body_id);
824824

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
11631163

11641164
/// For closures, we first visit the parameters and then the content,
11651165
/// as we prefer those.
1166-
fn visit_body(&mut self, body: &'tcx Body<'tcx>) {
1166+
fn visit_body(&mut self, body: &Body<'tcx>) {
11671167
for param in body.params {
11681168
debug!(
11691169
"param: span {:?}, ty_span {:?}, pat.span {:?}",

compiler/rustc_infer/src/infer/error_reporting/suggest.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
578578
walk_stmt(self, ex)
579579
}
580580
}
581-
582-
fn visit_body(&mut self, body: &'v hir::Body<'v>) -> Self::Result {
583-
hir::intravisit::walk_body(self, body)
584-
}
585581
}
586582

587583
self.tcx.hir().maybe_body_owned_by(cause.body_id).and_then(|body_id| {

compiler/rustc_lint/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
125125
});
126126
}
127127

128-
fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
128+
fn visit_body(&mut self, body: &hir::Body<'tcx>) {
129129
lint_callback!(self, check_body, body);
130130
hir_visit::walk_body(self, body);
131131
lint_callback!(self, check_body_post, body);

compiler/rustc_lint/src/non_local_def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ impl_lint_pass!(NonLocalDefinitions => [NON_LOCAL_DEFINITIONS]);
6868
// instead check_mod is called after every body has been handled.
6969

7070
impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
71-
fn check_body(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) {
71+
fn check_body(&mut self, _cx: &LateContext<'tcx>, _body: &Body<'tcx>) {
7272
self.body_depth += 1;
7373
}
7474

75-
fn check_body_post(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) {
75+
fn check_body_post(&mut self, _cx: &LateContext<'tcx>, _body: &Body<'tcx>) {
7676
self.body_depth -= 1;
7777
}
7878

compiler/rustc_lint/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use rustc_session::lint::LintPass;
77
macro_rules! late_lint_methods {
88
($macro:path, $args:tt) => (
99
$macro!($args, [
10-
fn check_body(a: &'tcx rustc_hir::Body<'tcx>);
11-
fn check_body_post(a: &'tcx rustc_hir::Body<'tcx>);
10+
fn check_body(a: &rustc_hir::Body<'tcx>);
11+
fn check_body_post(a: &rustc_hir::Body<'tcx>);
1212
fn check_crate();
1313
fn check_crate_post();
1414
fn check_mod(a: &'tcx rustc_hir::Mod<'tcx>, b: rustc_hir::HirId);

compiler/rustc_passes/src/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
196196
self.recurse_into(kind, None, |this| intravisit::walk_anon_const(this, anon));
197197
}
198198

199-
fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
199+
fn visit_body(&mut self, body: &hir::Body<'tcx>) {
200200
let owner = self.tcx.hir().body_owner_def_id(body.id());
201201
let kind = self.tcx.hir().body_const_context(owner);
202202
self.recurse_into(kind, Some(owner), |this| intravisit::walk_body(this, body));

compiler/rustc_passes/src/hir_stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
246246
hir_visit::walk_item(self, i)
247247
}
248248

249-
fn visit_body(&mut self, b: &'v hir::Body<'v>) {
249+
fn visit_body(&mut self, b: &hir::Body<'v>) {
250250
self.record("Body", Id::None, b);
251251
hir_visit::walk_body(self, b);
252252
}

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4748,7 +4748,7 @@ impl<'v> Visitor<'v> for ReturnsVisitor<'v> {
47484748
}
47494749
}
47504750

4751-
fn visit_body(&mut self, body: &'v hir::Body<'v>) {
4751+
fn visit_body(&mut self, body: &hir::Body<'v>) {
47524752
assert!(!self.in_block_tail);
47534753
self.in_block_tail = true;
47544754
hir::intravisit::walk_body(self, body);

0 commit comments

Comments
 (0)