Skip to content

Commit 39b126b

Browse files
committed
Auto merge of #164609 - tgross35:rollup-oDWHXH1, r=tgross35
Rollup of 5 pull requests Successful merges: - #164568 (Exclude MaybeDangling like types from SROA) - #163771 (update {Ipv4Addr,Ipv6Addr}::is_global to match IANA registries) - #164268 ([rustdoc] Add the Dyn Compatibility heading all the time in the sidebar since it is always in the doc) - #164581 (Revert "Remove indirection for `Expr` in `Body`") - #164606 (triagebot: Delete the libs ad-hoc group)
2 parents 8144389 + 5d657be commit 39b126b

122 files changed

Lines changed: 255 additions & 211 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎compiler/rustc_ast_lowering/src/item.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12161216
params: &'hir [hir::Param<'hir>],
12171217
value: hir::Expr<'hir>,
12181218
) -> hir::BodyId {
1219-
let body = hir::Body { params, value };
1219+
let body = hir::Body { params, value: self.arena.alloc(value) };
12201220
let id = body.id();
12211221
assert_eq!(id.hir_id.owner, self.curr_owner.owner_id());
12221222
self.curr_owner.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
408408
}
409409
let tcx = self.infcx.tcx;
410410
if let Some(body) = tcx.hir_maybe_body_owned_by(self.mir_def_id()) {
411-
let expr = &body.value;
411+
let expr = body.value;
412412
let place = &self.move_data.move_paths[mpi].place;
413413
let span = place.as_local().map(|local| self.body.local_decls[local].source_info.span);
414414
let mut finder = ExpressionFinder {
@@ -2134,7 +2134,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
21342134

21352135
let mut expr_finder = FindUselessClone::new(tcx, self.mir_def_id());
21362136

2137-
let body = &tcx.hir_body(body_id).value;
2137+
let body = tcx.hir_body(body_id).value;
21382138
expr_finder.visit_expr(body);
21392139

21402140
struct Holds<'tcx> {
@@ -2323,7 +2323,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
23232323
let tcx = self.infcx.tcx;
23242324
let body_id = tcx.hir_node(self.mir_hir_id()).body_id()?;
23252325
let mut expr_finder = FindExprBySpan::new(span, tcx);
2326-
expr_finder.visit_expr(&tcx.hir_body(body_id).value);
2326+
expr_finder.visit_expr(tcx.hir_body(body_id).value);
23272327
expr_finder.result
23282328
}
23292329

@@ -2554,7 +2554,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
25542554
}
25552555
}
25562556
let mut finder = ExprFinder { tcx, expr_span: span, issue_span, .. };
2557-
finder.visit_expr(&tcx.hir_body(body_id).value);
2557+
finder.visit_expr(tcx.hir_body(body_id).value);
25582558

25592559
if let Some(body_expr) = finder.body_expr
25602560
&& let Some(loop_span) = finder.loop_span
@@ -2705,7 +2705,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
27052705
// Get the body the error happens in
27062706
let Some(body_id) = tcx.hir_node(self.mir_hir_id()).body_id() else { return };
27072707

2708-
let body_expr = &tcx.hir_body(body_id).value;
2708+
let body_expr = tcx.hir_body(body_id).value;
27092709

27102710
struct ClosureFinder<'hir> {
27112711
tcx: TyCtxt<'hir>,
@@ -2809,7 +2809,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
28092809
}
28102810

28112811
let mut finder = VariableUseFinder { local_id, spans: Vec::new() };
2812-
finder.visit_expr(&tcx.hir_body(closure.body).value);
2812+
finder.visit_expr(tcx.hir_body(closure.body).value);
28132813

28142814
spans = finder.spans;
28152815
} else {
@@ -4747,7 +4747,7 @@ fn find_for_loop_span<'hir>(
47474747
}
47484748
}
47494749
let mut finder = ExprFinder { tcx, issue_span, result: None };
4750-
finder.visit_expr(&tcx.hir_body(body_id).value);
4750+
finder.visit_expr(tcx.hir_body(body_id).value);
47514751
finder.result
47524752
}
47534753

‎compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
7373
{
7474
let body = tcx.hir_body(body_id);
7575
let mut expr_finder = FindExprBySpan::new(span, tcx);
76-
expr_finder.visit_expr(&body.value);
76+
expr_finder.visit_expr(body.value);
7777
if let Some(mut expr) = expr_finder.result {
7878
while let hir::ExprKind::AddrOf(_, _, inner)
7979
| hir::ExprKind::Unary(hir::UnOp::Deref, inner)
@@ -308,7 +308,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
308308
&& let hir_body = tcx.hir_body(body_id)
309309
&& let mut expr_finder = (FindLetExpr { span: old, result: None, tcx })
310310
&& let Some((let_expr_span, let_expr_pat, let_expr_init)) = {
311-
expr_finder.visit_expr(&hir_body.value);
311+
expr_finder.visit_expr(hir_body.value);
312312
expr_finder.result
313313
}
314314
&& !let_expr_span.contains(new)

‎compiler/rustc_borrowck/src/diagnostics/move_errors.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
339339
// Find the closure that captured the binding.
340340
let mut expr_finder = FindExprBySpan::new(args_span, tcx);
341341
expr_finder.include_closures = true;
342-
expr_finder.visit_expr(&tcx.hir_body(body_id).value);
342+
expr_finder.visit_expr(tcx.hir_body(body_id).value);
343343
let Some(closure_expr) = expr_finder.result else { return };
344344
let ExprKind::Closure(closure) = closure_expr.kind else { return };
345345
// We'll only suggest cloning the binding if it's a `move` closure.
@@ -349,7 +349,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
349349
let use_span = use_spans.var_or_use();
350350
let mut expr_finder = FindExprBySpan::new(use_span, tcx);
351351
expr_finder.include_closures = true;
352-
expr_finder.visit_expr(&tcx.hir_body(body_id).value);
352+
expr_finder.visit_expr(tcx.hir_body(body_id).value);
353353
let Some(use_expr) = expr_finder.result else { return };
354354
let parent = tcx.parent_hir_node(use_expr.hir_id);
355355
if let Node::Expr(expr) = parent

‎compiler/rustc_hir/src/hir.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ pub struct BodyId {
19601960
#[derive(Debug, Clone, Copy, StableHash)]
19611961
pub struct Body<'hir> {
19621962
pub params: &'hir [Param<'hir>],
1963-
pub value: Expr<'hir>,
1963+
pub value: &'hir Expr<'hir>,
19641964
}
19651965

19661966
impl<'hir> Body<'hir> {
@@ -5279,7 +5279,7 @@ mod size_asserts {
52795279
use super::*;
52805280
// tidy-alphabetical-start
52815281
static_assert_size!(Block<'_>, 48);
5282-
static_assert_size!(Body<'_>, 80);
5282+
static_assert_size!(Body<'_>, 24);
52835283
static_assert_size!(Expr<'_>, 64);
52845284
static_assert_size!(ExprKind<'_>, 48);
52855285
static_assert_size!(FnDecl<'_>, 40);

‎compiler/rustc_hir/src/intravisit.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub trait Visitor<'v>: Sized {
296296
walk_item(self, i)
297297
}
298298

299-
fn visit_body(&mut self, b: &'v Body<'v>) -> Self::Result {
299+
fn visit_body(&mut self, b: &Body<'v>) -> Self::Result {
300300
walk_body(self, b)
301301
}
302302

@@ -662,10 +662,10 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
662662
V::Result::output()
663663
}
664664

665-
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) -> V::Result {
665+
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &Body<'v>) -> V::Result {
666666
let Body { params, value } = body;
667667
walk_list!(visitor, visit_param, *params);
668-
visitor.visit_expr(value)
668+
visitor.visit_expr(*value)
669669
}
670670

671671
pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) -> V::Result {

‎compiler/rustc_hir_analysis/src/check/region.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
762762
resolve_block(self, b, false);
763763
}
764764

765-
fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
765+
fn visit_body(&mut self, body: &hir::Body<'tcx>) {
766766
let body_id = body.id();
767767
let owner_id = self.tcx.hir_body_owner_def_id(body_id);
768768

@@ -783,7 +783,7 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
783783
}
784784

785785
// The body of the every fn is a root scope.
786-
resolve_expr(this, &body.value, true);
786+
resolve_expr(this, body.value, true);
787787
} else {
788788
// All bodies have an outer temporary drop scope, but temporaries
789789
// and `super let` bindings in constant initializers may be extended
@@ -808,7 +808,7 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
808808
local_id: body.value.hir_id.local_id,
809809
data: ScopeData::Destruction,
810810
});
811-
resolve_local(this, None, Some(&body.value), LetKind::Regular);
811+
resolve_local(this, None, Some(body.value), LetKind::Regular);
812812
}
813813
})
814814
}

‎compiler/rustc_hir_analysis/src/collect.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ fn coroutine_for_closure(tcx: TyCtxt<'_>, def_id: LocalDefId) -> DefId {
17051705
bug!()
17061706
};
17071707

1708-
let hir::Expr {
1708+
let &hir::Expr {
17091709
kind:
17101710
hir::ExprKind::Closure(&rustc_hir::Closure {
17111711
def_id,

‎compiler/rustc_hir_pretty/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl PpAnn for &dyn rustc_hir::intravisit::HirTyCtxt<'_> {
6363
Nested::TraitItem(id) => state.print_trait_item(self.hir_trait_item(id)),
6464
Nested::ImplItem(id) => state.print_impl_item(self.hir_impl_item(id)),
6565
Nested::ForeignItem(id) => state.print_foreign_item(self.hir_foreign_item(id)),
66-
Nested::Body(id) => state.print_expr(&self.hir_body(id).value),
66+
Nested::Body(id) => state.print_expr(self.hir_body(id).value),
6767
Nested::BodyParamPat(id, i) => state.print_pat(self.hir_body(id).params[i].pat),
6868
}
6969
}

‎compiler/rustc_hir_typeck/src/check.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub(super) fn check_fn<'a, 'tcx>(
127127
}
128128

129129
fcx.is_whole_body.set(true);
130-
fcx.check_return_or_body_tail(&body.value, false);
130+
fcx.check_return_or_body_tail(body.value, false);
131131

132132
// Finalize the return check by taking the LUB of the return types
133133
// we saw and assigning it to the expected return type. This isn't

0 commit comments

Comments
 (0)