Skip to content

Commit 5f74fa0

Browse files
committed
call mir_promoted inside of do_mir_borrowck
1 parent 0b4a81a commit 5f74fa0

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

Diff for: compiler/rustc_borrowck/src/consumers.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This file provides API for compiler consumers.
22
33
use rustc_hir::def_id::LocalDefId;
4-
use rustc_index::{IndexSlice, IndexVec};
4+
use rustc_index::IndexVec;
55
use rustc_middle::mir::{Body, Promoted};
66
use rustc_middle::ty::TyCtxt;
77

@@ -100,8 +100,5 @@ pub fn get_body_with_borrowck_facts(
100100
def: LocalDefId,
101101
options: ConsumerOptions,
102102
) -> BodyWithBorrowckFacts<'_> {
103-
let (input_body, promoted) = tcx.mir_promoted(def);
104-
let input_body: &Body<'_> = &input_body.borrow();
105-
let promoted: &IndexSlice<_, _> = &promoted.borrow();
106-
*super::do_mir_borrowck(tcx, input_body, promoted, Some(options)).1.unwrap()
103+
*super::do_mir_borrowck(tcx, def, Some(options)).1.unwrap()
107104
}

Diff for: compiler/rustc_borrowck/src/lib.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ pub fn provide(providers: &mut Providers) {
103103
}
104104

105105
fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
106-
let (input_body, promoted) = tcx.mir_promoted(def);
107-
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
108-
106+
let (input_body, _) = tcx.mir_promoted(def);
109107
let input_body: &Body<'_> = &input_body.borrow();
110-
111108
if input_body.should_skip() || input_body.tainted_by_errors.is_some() {
112109
debug!("Skipping borrowck because of injected body or tainted body");
113110
// Let's make up a borrowck result! Fun times!
@@ -120,7 +117,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
120117
return tcx.arena.alloc(result);
121118
}
122119

123-
let borrowck_result = do_mir_borrowck(tcx, input_body, &*promoted.borrow(), None).0;
120+
let borrowck_result = do_mir_borrowck(tcx, def, None).0;
124121
debug!("mir_borrowck done");
125122

126123
tcx.arena.alloc(borrowck_result)
@@ -131,15 +128,16 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
131128
/// Use `consumer_options: None` for the default behavior of returning
132129
/// [`BorrowCheckResult`] only. Otherwise, return [`BodyWithBorrowckFacts`] according
133130
/// to the given [`ConsumerOptions`].
134-
#[instrument(skip(tcx, input_body, input_promoted), fields(id=?input_body.source.def_id()), level = "debug")]
131+
#[instrument(skip(tcx), level = "debug")]
135132
fn do_mir_borrowck<'tcx>(
136133
tcx: TyCtxt<'tcx>,
137-
input_body: &Body<'tcx>,
138-
input_promoted: &IndexSlice<Promoted, Body<'tcx>>,
134+
def: LocalDefId,
139135
consumer_options: Option<ConsumerOptions>,
140136
) -> (BorrowCheckResult<'tcx>, Option<Box<BodyWithBorrowckFacts<'tcx>>>) {
141-
let def = input_body.source.def_id().expect_local();
142137
let infcx = BorrowckInferCtxt::new(tcx, def);
138+
let (input_body, promoted) = tcx.mir_promoted(def);
139+
let input_body: &Body<'_> = &input_body.borrow();
140+
let input_promoted: &IndexSlice<_, _> = &promoted.borrow();
143141
if let Some(e) = input_body.tainted_by_errors {
144142
infcx.set_tainted_by_errors(e);
145143
}

0 commit comments

Comments
 (0)