Skip to content

Commit a8b36c9

Browse files
committed
Run rustfmt
1 parent 9de4e34 commit a8b36c9

File tree

2 files changed

+87
-71
lines changed

2 files changed

+87
-71
lines changed

src/librustc_mir/borrow_check/flows.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ use borrow_check::location::LocationIndex;
2121

2222
use polonius_engine::Output;
2323

24-
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
24+
use dataflow::move_paths::indexes::BorrowIndex;
25+
use dataflow::move_paths::HasMoveData;
26+
use dataflow::Borrows;
2527
use dataflow::{EverInitializedPlaces, MovingOutStatements};
26-
use dataflow::{Borrows};
2728
use dataflow::{FlowAtLocation, FlowsAtLocation};
28-
use dataflow::move_paths::HasMoveData;
29-
use dataflow::move_paths::indexes::BorrowIndex;
29+
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
3030
use either::Either;
3131
use std::fmt;
3232
use std::rc::Rc;
@@ -62,7 +62,10 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
6262
}
6363
}
6464

65-
crate fn borrows_in_scope(&self, location: LocationIndex) -> impl Iterator<Item = BorrowIndex> + '_ {
65+
crate fn borrows_in_scope(
66+
&self,
67+
location: LocationIndex,
68+
) -> impl Iterator<Item = BorrowIndex> + '_ {
6669
if let Some(ref polonius) = self.polonius_output {
6770
Either::Left(polonius.errors_at(location).iter().cloned())
6871
} else {
@@ -82,7 +85,7 @@ macro_rules! each_flow {
8285
FlowAtLocation::$meth(&mut $this.uninits, $arg);
8386
FlowAtLocation::$meth(&mut $this.move_outs, $arg);
8487
FlowAtLocation::$meth(&mut $this.ever_inits, $arg);
85-
}
88+
};
8689
}
8790

8891
impl<'b, 'gcx, 'tcx> FlowsAtLocation for Flows<'b, 'gcx, 'tcx> {
@@ -150,8 +153,7 @@ impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
150153
s.push_str(", ");
151154
};
152155
saw_one = true;
153-
let move_path =
154-
&self.uninits.operator().move_data().move_paths[mpi_uninit];
156+
let move_path = &self.uninits.operator().move_data().move_paths[mpi_uninit];
155157
s.push_str(&format!("{}", move_path));
156158
});
157159
s.push_str("] ");
@@ -175,8 +177,7 @@ impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
175177
s.push_str(", ");
176178
};
177179
saw_one = true;
178-
let ever_init =
179-
&self.ever_inits.operator().move_data().inits[mpi_ever_init];
180+
let ever_init = &self.ever_inits.operator().move_data().inits[mpi_ever_init];
180181
s.push_str(&format!("{:?}", ever_init));
181182
});
182183
s.push_str("]");

src/librustc_mir/borrow_check/nll/mod.rs

+76-61
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
use borrow_check::borrow_set::BorrowSet;
1212
use borrow_check::location::{LocationIndex, LocationTable};
1313
use borrow_check::nll::facts::AllFactsExt;
14+
use dataflow::indexes::BorrowIndex;
1415
use dataflow::move_paths::MoveData;
1516
use dataflow::FlowAtLocation;
1617
use dataflow::MaybeInitializedPlaces;
17-
use dataflow::indexes::BorrowIndex;
1818
use rustc::hir::def_id::DefId;
1919
use rustc::infer::InferCtxt;
2020
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir};
@@ -23,25 +23,25 @@ use rustc::util::nodemap::FxHashMap;
2323
use std::collections::BTreeSet;
2424
use std::fmt::Debug;
2525
use std::io;
26-
use std::rc::Rc;
2726
use std::path::PathBuf;
27+
use std::rc::Rc;
2828
use transform::MirSource;
2929
use util::liveness::{LivenessResults, LocalSet};
3030

3131
use self::mir_util::PassWhere;
32+
use polonius_engine::{Algorithm, Output};
3233
use util as mir_util;
3334
use util::pretty::{self, ALIGN};
34-
use polonius_engine::{Algorithm, Output};
3535

3636
mod constraint_generation;
3737
pub mod explain_borrow;
3838
mod facts;
39+
mod invalidation;
3940
crate mod region_infer;
4041
mod renumber;
4142
mod subtype_constraint_generation;
4243
crate mod type_check;
4344
mod universal_regions;
44-
mod invalidation;
4545

4646
use self::facts::AllFacts;
4747
use self::region_infer::RegionInferenceContext;
@@ -119,8 +119,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
119119
// Create the region inference context, taking ownership of the region inference
120120
// data that was contained in `infcx`.
121121
let var_origins = infcx.take_region_var_origins();
122-
let mut regioncx =
123-
RegionInferenceContext::new(var_origins, universal_regions, mir);
122+
let mut regioncx = RegionInferenceContext::new(var_origins, universal_regions, mir);
124123

125124
// Generate various constraints.
126125
subtype_constraint_generation::generate(
@@ -144,22 +143,27 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
144143
location_table,
145144
&mir,
146145
def_id,
147-
borrow_set
146+
borrow_set,
148147
);
149148

150149
// Dump facts if requested.
151150
let polonius_output = all_facts.and_then(|all_facts| {
152-
if infcx.tcx.sess.opts.debugging_opts.nll_facts {
153-
let def_path = infcx.tcx.hir.def_path(def_id);
154-
let dir_path = PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate());
155-
all_facts.write_to_dir(dir_path, location_table).unwrap();
156-
}
157-
158-
if infcx.tcx.sess.opts.debugging_opts.polonius {
159-
Some(Rc::new(Output::compute(&all_facts, Algorithm::DatafrogOpt, false)))
160-
} else {
161-
None
162-
}
151+
if infcx.tcx.sess.opts.debugging_opts.nll_facts {
152+
let def_path = infcx.tcx.hir.def_path(def_id);
153+
let dir_path =
154+
PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate());
155+
all_facts.write_to_dir(dir_path, location_table).unwrap();
156+
}
157+
158+
if infcx.tcx.sess.opts.debugging_opts.polonius {
159+
Some(Rc::new(Output::compute(
160+
&all_facts,
161+
Algorithm::DatafrogOpt,
162+
false,
163+
)))
164+
} else {
165+
None
166+
}
163167
});
164168

165169
// Solve the region constraints.
@@ -195,7 +199,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
195199
return;
196200
}
197201

198-
let regular_liveness_per_location: FxHashMap<_, _> = mir.basic_blocks()
202+
let regular_liveness_per_location: FxHashMap<_, _> = mir
203+
.basic_blocks()
199204
.indices()
200205
.flat_map(|bb| {
201206
let mut results = vec![];
@@ -208,7 +213,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
208213
})
209214
.collect();
210215

211-
let drop_liveness_per_location: FxHashMap<_, _> = mir.basic_blocks()
216+
let drop_liveness_per_location: FxHashMap<_, _> = mir
217+
.basic_blocks()
212218
.indices()
213219
.flat_map(|bb| {
214220
let mut results = vec![];
@@ -221,47 +227,55 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
221227
})
222228
.collect();
223229

224-
mir_util::dump_mir(infcx.tcx, None, "nll", &0, source, mir, |pass_where, out| {
225-
match pass_where {
226-
// Before the CFG, dump out the values for each region variable.
227-
PassWhere::BeforeCFG => {
228-
regioncx.dump_mir(out)?;
229-
230-
if let Some(closure_region_requirements) = closure_region_requirements {
231-
writeln!(out, "|")?;
232-
writeln!(out, "| Free Region Constraints")?;
233-
for_each_region_constraint(closure_region_requirements, &mut |msg| {
234-
writeln!(out, "| {}", msg)
235-
})?;
230+
mir_util::dump_mir(
231+
infcx.tcx,
232+
None,
233+
"nll",
234+
&0,
235+
source,
236+
mir,
237+
|pass_where, out| {
238+
match pass_where {
239+
// Before the CFG, dump out the values for each region variable.
240+
PassWhere::BeforeCFG => {
241+
regioncx.dump_mir(out)?;
242+
243+
if let Some(closure_region_requirements) = closure_region_requirements {
244+
writeln!(out, "|")?;
245+
writeln!(out, "| Free Region Constraints")?;
246+
for_each_region_constraint(closure_region_requirements, &mut |msg| {
247+
writeln!(out, "| {}", msg)
248+
})?;
249+
}
236250
}
237-
}
238251

239-
// Before each basic block, dump out the values
240-
// that are live on entry to the basic block.
241-
PassWhere::BeforeBlock(bb) => {
242-
let s = live_variable_set(&liveness.regular.ins[bb], &liveness.drop.ins[bb]);
243-
writeln!(out, " | Live variables on entry to {:?}: {}", bb, s)?;
244-
}
252+
// Before each basic block, dump out the values
253+
// that are live on entry to the basic block.
254+
PassWhere::BeforeBlock(bb) => {
255+
let s = live_variable_set(&liveness.regular.ins[bb], &liveness.drop.ins[bb]);
256+
writeln!(out, " | Live variables on entry to {:?}: {}", bb, s)?;
257+
}
245258

246-
PassWhere::BeforeLocation(location) => {
247-
let s = live_variable_set(
248-
&regular_liveness_per_location[&location],
249-
&drop_liveness_per_location[&location],
250-
);
251-
writeln!(
252-
out,
253-
"{:ALIGN$} | Live variables on entry to {:?}: {}",
254-
"",
255-
location,
256-
s,
257-
ALIGN = ALIGN
258-
)?;
259-
}
259+
PassWhere::BeforeLocation(location) => {
260+
let s = live_variable_set(
261+
&regular_liveness_per_location[&location],
262+
&drop_liveness_per_location[&location],
263+
);
264+
writeln!(
265+
out,
266+
"{:ALIGN$} | Live variables on entry to {:?}: {}",
267+
"",
268+
location,
269+
s,
270+
ALIGN = ALIGN
271+
)?;
272+
}
260273

261-
PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
262-
}
263-
Ok(())
264-
});
274+
PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
275+
}
276+
Ok(())
277+
},
278+
);
265279

266280
// Also dump the inference graph constraints as a graphviz file.
267281
let _: io::Result<()> = do catch {
@@ -292,7 +306,8 @@ fn dump_annotation<'a, 'gcx, 'tcx>(
292306
// better.
293307

294308
if let Some(closure_region_requirements) = closure_region_requirements {
295-
let mut err = tcx.sess
309+
let mut err = tcx
310+
.sess
296311
.diagnostic()
297312
.span_note_diag(mir.span, "External requirements");
298313

@@ -312,7 +327,8 @@ fn dump_annotation<'a, 'gcx, 'tcx>(
312327

313328
err.emit();
314329
} else {
315-
let mut err = tcx.sess
330+
let mut err = tcx
331+
.sess
316332
.diagnostic()
317333
.span_note_diag(mir.span, "No external requirements");
318334
regioncx.annotate(&mut err);
@@ -331,8 +347,7 @@ fn for_each_region_constraint(
331347
};
332348
with_msg(&format!(
333349
"where {:?}: {:?}",
334-
subject,
335-
req.outlived_free_region,
350+
subject, req.outlived_free_region,
336351
))?;
337352
}
338353
Ok(())

0 commit comments

Comments
 (0)