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

Commit d887ce2

Browse files
committed
Auto merge of rust-lang#125755 - fmease:rollup-aybyh6c, r=fmease
Rollup of 6 pull requests Successful merges: - rust-lang#124636 (Make `std::env::{set_var, remove_var}` unsafe in edition 2024) - rust-lang#125342 (Document platform-specifics for `Read` and `Write` of `File`) - rust-lang#125671 (Do not equate `Const`'s ty in `super_combine_const`) - rust-lang#125711 (Make `body_owned_by` return the `Body` instead of just the `BodyId`) - rust-lang#125745 (Bump the stage0 compiler to beta.7 (2024-05-26)) - rust-lang#125753 (compiletest: Unify `cmd2procres` with `run_command_to_procres`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents caa187f + cf66e64 commit d887ce2

File tree

110 files changed

+1258
-1020
lines changed

Some content is hidden

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

110 files changed

+1258
-1020
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
399399
}
400400
}
401401
let hir = self.infcx.tcx.hir();
402-
if let Some(body_id) = hir.maybe_body_owned_by(self.mir_def_id()) {
403-
let expr = hir.body(body_id).value;
402+
if let Some(body) = hir.maybe_body_owned_by(self.mir_def_id()) {
403+
let expr = body.value;
404404
let place = &self.move_data.move_paths[mpi].place;
405405
let span = place.as_local().map(|local| self.body.local_decls[local].source_info.span);
406406
let mut finder = ExpressionFinder {
@@ -556,11 +556,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
556556
// We use the statements were the binding was initialized, and inspect the HIR to look
557557
// for the branching codepaths that aren't covered, to point at them.
558558
let map = self.infcx.tcx.hir();
559-
let body_id = map.body_owned_by(self.mir_def_id());
560-
let body = map.body(body_id);
559+
let body = map.body_owned_by(self.mir_def_id());
561560

562561
let mut visitor = ConditionVisitor { spans: &spans, name: &name, errors: vec![] };
563-
visitor.visit_body(body);
562+
visitor.visit_body(&body);
564563

565564
let mut show_assign_sugg = false;
566565
let isnt_initialized = if let InitializationRequiringAction::PartialAssignment
@@ -665,7 +664,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
665664
}
666665

667666
let mut visitor = LetVisitor { decl_span, sugg_span: None };
668-
visitor.visit_body(body);
667+
visitor.visit_body(&body);
669668
if let Some(span) = visitor.sugg_span {
670669
self.suggest_assign_value(&mut err, moved_place, span);
671670
}

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -647,16 +647,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
647647
let hir_map = self.infcx.tcx.hir();
648648
let def_id = self.body.source.def_id();
649649
let Some(local_def_id) = def_id.as_local() else { return };
650-
let Some(body_id) = hir_map.maybe_body_owned_by(local_def_id) else { return };
651-
let body = self.infcx.tcx.hir().body(body_id);
650+
let Some(body) = hir_map.maybe_body_owned_by(local_def_id) else { return };
652651

653652
let mut v = SuggestIndexOperatorAlternativeVisitor {
654653
assign_span: span,
655654
err,
656655
ty,
657656
suggested: false,
658657
};
659-
v.visit_body(body);
658+
v.visit_body(&body);
660659
if !v.suggested {
661660
err.help(format!(
662661
"to modify a `{ty}`, use `.get_mut()`, `.insert()` or the entry API",
@@ -746,9 +745,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
746745
// `fn foo(&x: &i32)` -> `fn foo(&(mut x): &i32)`
747746
let def_id = self.body.source.def_id();
748747
if let Some(local_def_id) = def_id.as_local()
749-
&& let Some(body_id) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id)
750-
&& let body = self.infcx.tcx.hir().body(body_id)
751-
&& let Some(hir_id) = (BindingFinder { span: pat_span }).visit_body(body).break_value()
748+
&& let Some(body) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id)
749+
&& let Some(hir_id) = (BindingFinder { span: pat_span }).visit_body(&body).break_value()
752750
&& let node = self.infcx.tcx.hir_node(hir_id)
753751
&& let hir::Node::LetStmt(hir::LetStmt {
754752
pat: hir::Pat { kind: hir::PatKind::Ref(_, _), .. },
@@ -867,8 +865,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
867865
}
868866
}
869867
}
870-
if let Some(body_id) = hir_map.maybe_body_owned_by(self.mir_def_id())
871-
&& let Block(block, _) = hir_map.body(body_id).value.kind
868+
if let Some(body) = hir_map.maybe_body_owned_by(self.mir_def_id())
869+
&& let Block(block, _) = body.value.kind
872870
{
873871
// `span` corresponds to the expression being iterated, find the `for`-loop desugared
874872
// expression with that span in order to identify potential fixes when encountering a
@@ -1189,10 +1187,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
11891187
Some((false, err_label_span, message, _)) => {
11901188
let def_id = self.body.source.def_id();
11911189
let hir_id = if let Some(local_def_id) = def_id.as_local()
1192-
&& let Some(body_id) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id)
1190+
&& let Some(body) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id)
11931191
{
1194-
let body = self.infcx.tcx.hir().body(body_id);
1195-
BindingFinder { span: err_label_span }.visit_body(body).break_value()
1192+
BindingFinder { span: err_label_span }.visit_body(&body).break_value()
11961193
} else {
11971194
None
11981195
};

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
11831183
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
11841184
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
11851185
let map = self.infcx.tcx.hir();
1186-
let body_id = map.body_owned_by(self.mir_def_id());
1187-
let expr = &map.body(body_id).value.peel_blocks();
1186+
let body = map.body_owned_by(self.mir_def_id());
1187+
let expr = &body.value.peel_blocks();
11881188
let mut closure_span = None::<rustc_span::Span>;
11891189
match expr.kind {
11901190
hir::ExprKind::MethodCall(.., args, _) => {

compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<'tcx> pprust_hir::PpAnn for HirTypedAnn<'tcx> {
169169
self.tcx
170170
.hir()
171171
.maybe_body_owned_by(expr.hir_id.owner.def_id)
172-
.map(|body_id| self.tcx.typeck_body(body_id))
172+
.map(|body_id| self.tcx.typeck_body(body_id.id()))
173173
});
174174

175175
if let Some(typeck_results) = typeck_results {

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
578578
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
579579
through unstable paths"
580580
),
581+
rustc_attr!(
582+
rustc_deprecated_safe_2024, Normal, template!(Word), WarnFollowing,
583+
EncodeCrossCrate::Yes,
584+
"rustc_deprecated_safe_2024 is supposed to be used in libstd only",
585+
),
586+
581587

582588
// ==========================================================================
583589
// Internal attributes: Type system related:

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: 3 additions & 4 deletions
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

@@ -896,7 +896,7 @@ pub fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
896896
return tcx.region_scope_tree(typeck_root_def_id);
897897
}
898898

899-
let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(def_id.expect_local()) {
899+
let scope_tree = if let Some(body) = tcx.hir().maybe_body_owned_by(def_id.expect_local()) {
900900
let mut visitor = RegionResolutionVisitor {
901901
tcx,
902902
scope_tree: ScopeTree::default(),
@@ -907,9 +907,8 @@ pub fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
907907
fixup_scopes: vec![],
908908
};
909909

910-
let body = tcx.hir().body(body_id);
911910
visitor.scope_tree.root_body = Some(body.value.hir_id);
912-
visitor.visit_body(body);
911+
visitor.visit_body(&body);
913912
visitor.scope_tree
914913
} else {
915914
ScopeTree::default()

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
207207
let hir = self.tcx.hir();
208208

209209
// First, check that we're actually in the tail of a function.
210-
let Some(body_id) = hir.maybe_body_owned_by(self.body_id) else {
210+
let Some(body) = hir.maybe_body_owned_by(self.body_id) else {
211211
return;
212212
};
213-
let body = hir.body(body_id);
214213
let hir::ExprKind::Block(block, _) = body.value.kind else {
215214
return;
216215
};

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
327327
}
328328

329329
let mut expr_finder = FindExprs { hir_id: local_hir_id, uses: init.into_iter().collect() };
330-
let body =
331-
hir.body(hir.maybe_body_owned_by(self.body_id).expect("expected item to have body"));
330+
let body = hir.body_owned_by(self.body_id);
332331
expr_finder.visit_expr(body.value);
333332

334333
// Replaces all of the variables in the given type with a fresh inference variable.

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
909909
// the first place.
910910
assert_ne!(encl_item_id.def_id, encl_body_owner_id);
911911

912-
let encl_body_id = self.tcx.hir().body_owned_by(encl_body_owner_id);
913-
let encl_body = self.tcx.hir().body(encl_body_id);
912+
let encl_body = self.tcx.hir().body_owned_by(encl_body_owner_id);
914913

915914
err.encl_body_span = Some(encl_body.value.span);
916915
err.encl_fn_span = Some(*encl_fn_span);

0 commit comments

Comments
 (0)