Skip to content

Commit e49e43a

Browse files
committed
remove Option from the tables field
1 parent cde3c15 commit e49e43a

File tree

1 file changed

+9
-7
lines changed
  • src/librustc_borrowck/borrowck

1 file changed

+9
-7
lines changed

src/librustc_borrowck/borrowck/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn borrowck_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, body_id: hir::BodyId) {
8787

8888
let mut bccx = &mut BorrowckCtxt {
8989
tcx: tcx,
90-
tables: Some(tables),
90+
tables: tables,
9191
};
9292

9393
let body = bccx.tcx.hir.body(body_id);
@@ -159,17 +159,20 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
159159
/// the `BorrowckCtxt` itself , e.g. the flowgraph visualizer.
160160
pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
161161
tcx: TyCtxt<'a, 'tcx, 'tcx>,
162-
body: hir::BodyId,
162+
body_id: hir::BodyId,
163163
cfg: &cfg::CFG)
164164
-> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'a, 'tcx>)
165165
{
166+
let owner_id = tcx.hir.body_owner(body_id);
167+
let owner_def_id = tcx.hir.local_def_id(owner_id);
168+
let tables = tcx.item_tables(owner_def_id);
166169

167170
let mut bccx = BorrowckCtxt {
168171
tcx: tcx,
169-
tables: None,
172+
tables: tables,
170173
};
171174

172-
let dataflow_data = build_borrowck_dataflow_data(&mut bccx, cfg, body);
175+
let dataflow_data = build_borrowck_dataflow_data(&mut bccx, cfg, body_id);
173176
(bccx, dataflow_data)
174177
}
175178

@@ -181,7 +184,7 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> {
181184

182185
// tables for the current thing we are checking; set to
183186
// Some in `borrowck_fn` and cleared later
184-
tables: Option<&'a ty::TypeckTables<'tcx>>,
187+
tables: &'a ty::TypeckTables<'tcx>,
185188
}
186189

187190
///////////////////////////////////////////////////////////////////////////
@@ -472,8 +475,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
472475
r_sup: &'tcx ty::Region)
473476
-> bool
474477
{
475-
self.tables.unwrap().free_region_map
476-
.is_subregion_of(self.tcx, r_sub, r_sup)
478+
self.tables.free_region_map.is_subregion_of(self.tcx, r_sub, r_sup)
477479
}
478480

479481
pub fn report(&self, err: BckError<'tcx>) {

0 commit comments

Comments
 (0)