diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2018-05-28 13:47:20 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2018-05-29 10:19:47 -0300 |
| commit | a8b36c9e9a41cd3c9b8d723b486c176c73e4c010 (patch) | |
| tree | 811090f7355b7b46af4bfb7a7ce6c7a362d0af96 | |
| parent | 9de4e342dfc84c66d4ab435adcafc930c35f5586 (diff) | |
| download | rust-a8b36c9e9a41cd3c9b8d723b486c176c73e4c010.tar.gz rust-a8b36c9e9a41cd3c9b8d723b486c176c73e4c010.zip | |
Run rustfmt
| -rw-r--r-- | src/librustc_mir/borrow_check/flows.rs | 21 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/mod.rs | 137 |
2 files changed, 87 insertions, 71 deletions
diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs index 5d13eab8cf6..5631356dc1e 100644 --- a/src/librustc_mir/borrow_check/flows.rs +++ b/src/librustc_mir/borrow_check/flows.rs @@ -21,12 +21,12 @@ use borrow_check::location::LocationIndex; use polonius_engine::Output; -use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; +use dataflow::move_paths::indexes::BorrowIndex; +use dataflow::move_paths::HasMoveData; +use dataflow::Borrows; use dataflow::{EverInitializedPlaces, MovingOutStatements}; -use dataflow::{Borrows}; use dataflow::{FlowAtLocation, FlowsAtLocation}; -use dataflow::move_paths::HasMoveData; -use dataflow::move_paths::indexes::BorrowIndex; +use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; use either::Either; use std::fmt; use std::rc::Rc; @@ -62,7 +62,10 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> { } } - crate fn borrows_in_scope(&self, location: LocationIndex) -> impl Iterator<Item = BorrowIndex> + '_ { + crate fn borrows_in_scope( + &self, + location: LocationIndex, + ) -> impl Iterator<Item = BorrowIndex> + '_ { if let Some(ref polonius) = self.polonius_output { Either::Left(polonius.errors_at(location).iter().cloned()) } else { @@ -82,7 +85,7 @@ macro_rules! each_flow { FlowAtLocation::$meth(&mut $this.uninits, $arg); FlowAtLocation::$meth(&mut $this.move_outs, $arg); FlowAtLocation::$meth(&mut $this.ever_inits, $arg); - } + }; } 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> { s.push_str(", "); }; saw_one = true; - let move_path = - &self.uninits.operator().move_data().move_paths[mpi_uninit]; + let move_path = &self.uninits.operator().move_data().move_paths[mpi_uninit]; s.push_str(&format!("{}", move_path)); }); s.push_str("] "); @@ -175,8 +177,7 @@ impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> { s.push_str(", "); }; saw_one = true; - let ever_init = - &self.ever_inits.operator().move_data().inits[mpi_ever_init]; + let ever_init = &self.ever_inits.operator().move_data().inits[mpi_ever_init]; s.push_str(&format!("{:?}", ever_init)); }); s.push_str("]"); diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index ebc2800d204..ec1f3dbaeeb 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -11,10 +11,10 @@ use borrow_check::borrow_set::BorrowSet; use borrow_check::location::{LocationIndex, LocationTable}; use borrow_check::nll::facts::AllFactsExt; +use dataflow::indexes::BorrowIndex; use dataflow::move_paths::MoveData; use dataflow::FlowAtLocation; use dataflow::MaybeInitializedPlaces; -use dataflow::indexes::BorrowIndex; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir}; @@ -23,25 +23,25 @@ use rustc::util::nodemap::FxHashMap; use std::collections::BTreeSet; use std::fmt::Debug; use std::io; -use std::rc::Rc; use std::path::PathBuf; +use std::rc::Rc; use transform::MirSource; use util::liveness::{LivenessResults, LocalSet}; use self::mir_util::PassWhere; +use polonius_engine::{Algorithm, Output}; use util as mir_util; use util::pretty::{self, ALIGN}; -use polonius_engine::{Algorithm, Output}; mod constraint_generation; pub mod explain_borrow; mod facts; +mod invalidation; crate mod region_infer; mod renumber; mod subtype_constraint_generation; crate mod type_check; mod universal_regions; -mod invalidation; use self::facts::AllFacts; use self::region_infer::RegionInferenceContext; @@ -119,8 +119,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( // Create the region inference context, taking ownership of the region inference // data that was contained in `infcx`. let var_origins = infcx.take_region_var_origins(); - let mut regioncx = - RegionInferenceContext::new(var_origins, universal_regions, mir); + let mut regioncx = RegionInferenceContext::new(var_origins, universal_regions, mir); // Generate various constraints. subtype_constraint_generation::generate( @@ -144,22 +143,27 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( location_table, &mir, def_id, - borrow_set + borrow_set, ); // Dump facts if requested. let polonius_output = all_facts.and_then(|all_facts| { - if infcx.tcx.sess.opts.debugging_opts.nll_facts { - let def_path = infcx.tcx.hir.def_path(def_id); - let dir_path = PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate()); - all_facts.write_to_dir(dir_path, location_table).unwrap(); - } - - if infcx.tcx.sess.opts.debugging_opts.polonius { - Some(Rc::new(Output::compute(&all_facts, Algorithm::DatafrogOpt, false))) - } else { - None - } + if infcx.tcx.sess.opts.debugging_opts.nll_facts { + let def_path = infcx.tcx.hir.def_path(def_id); + let dir_path = + PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate()); + all_facts.write_to_dir(dir_path, location_table).unwrap(); + } + + if infcx.tcx.sess.opts.debugging_opts.polonius { + Some(Rc::new(Output::compute( + &all_facts, + Algorithm::DatafrogOpt, + false, + ))) + } else { + None + } }); // Solve the region constraints. @@ -195,7 +199,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( return; } - let regular_liveness_per_location: FxHashMap<_, _> = mir.basic_blocks() + let regular_liveness_per_location: FxHashMap<_, _> = mir + .basic_blocks() .indices() .flat_map(|bb| { let mut results = vec![]; @@ -208,7 +213,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( }) .collect(); - let drop_liveness_per_location: FxHashMap<_, _> = mir.basic_blocks() + let drop_liveness_per_location: FxHashMap<_, _> = mir + .basic_blocks() .indices() .flat_map(|bb| { let mut results = vec![]; @@ -221,47 +227,55 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( }) .collect(); - mir_util::dump_mir(infcx.tcx, None, "nll", &0, source, mir, |pass_where, out| { - match pass_where { - // Before the CFG, dump out the values for each region variable. - PassWhere::BeforeCFG => { - regioncx.dump_mir(out)?; - - if let Some(closure_region_requirements) = closure_region_requirements { - writeln!(out, "|")?; - writeln!(out, "| Free Region Constraints")?; - for_each_region_constraint(closure_region_requirements, &mut |msg| { - writeln!(out, "| {}", msg) - })?; + mir_util::dump_mir( + infcx.tcx, + None, + "nll", + &0, + source, + mir, + |pass_where, out| { + match pass_where { + // Before the CFG, dump out the values for each region variable. + PassWhere::BeforeCFG => { + regioncx.dump_mir(out)?; + + if let Some(closure_region_requirements) = closure_region_requirements { + writeln!(out, "|")?; + writeln!(out, "| Free Region Constraints")?; + for_each_region_constraint(closure_region_requirements, &mut |msg| { + writeln!(out, "| {}", msg) + })?; + } } - } - // Before each basic block, dump out the values - // that are live on entry to the basic block. - PassWhere::BeforeBlock(bb) => { - let s = live_variable_set(&liveness.regular.ins[bb], &liveness.drop.ins[bb]); - writeln!(out, " | Live variables on entry to {:?}: {}", bb, s)?; - } + // Before each basic block, dump out the values + // that are live on entry to the basic block. + PassWhere::BeforeBlock(bb) => { + let s = live_variable_set(&liveness.regular.ins[bb], &liveness.drop.ins[bb]); + writeln!(out, " | Live variables on entry to {:?}: {}", bb, s)?; + } - PassWhere::BeforeLocation(location) => { - let s = live_variable_set( - ®ular_liveness_per_location[&location], - &drop_liveness_per_location[&location], - ); - writeln!( - out, - "{:ALIGN$} | Live variables on entry to {:?}: {}", - "", - location, - s, - ALIGN = ALIGN - )?; - } + PassWhere::BeforeLocation(location) => { + let s = live_variable_set( + ®ular_liveness_per_location[&location], + &drop_liveness_per_location[&location], + ); + writeln!( + out, + "{:ALIGN$} | Live variables on entry to {:?}: {}", + "", + location, + s, + ALIGN = ALIGN + )?; + } - PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {} - } - Ok(()) - }); + PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {} + } + Ok(()) + }, + ); // Also dump the inference graph constraints as a graphviz file. let _: io::Result<()> = do catch { @@ -292,7 +306,8 @@ fn dump_annotation<'a, 'gcx, 'tcx>( // better. if let Some(closure_region_requirements) = closure_region_requirements { - let mut err = tcx.sess + let mut err = tcx + .sess .diagnostic() .span_note_diag(mir.span, "External requirements"); @@ -312,7 +327,8 @@ fn dump_annotation<'a, 'gcx, 'tcx>( err.emit(); } else { - let mut err = tcx.sess + let mut err = tcx + .sess .diagnostic() .span_note_diag(mir.span, "No external requirements"); regioncx.annotate(&mut err); @@ -331,8 +347,7 @@ fn for_each_region_constraint( }; with_msg(&format!( "where {:?}: {:?}", - subject, - req.outlived_free_region, + subject, req.outlived_free_region, ))?; } Ok(()) |
