提交 9d3c59d6 编写于 作者: A Albin Stjerna

rustfmt all the things!

上级 ac0a3d10
此差异已折叠。
......@@ -15,8 +15,8 @@
use crate::dataflow::move_paths::HasMoveData;
use crate::dataflow::Borrows;
use crate::dataflow::EverInitializedPlaces;
use crate::dataflow::{FlowAtLocation, FlowsAtLocation};
use crate::dataflow::MaybeUninitializedPlaces;
use crate::dataflow::{FlowAtLocation, FlowsAtLocation};
use either::Either;
use std::fmt;
use std::rc::Rc;
......@@ -40,12 +40,7 @@ impl<'b, 'tcx> Flows<'b, 'tcx> {
ever_inits: FlowAtLocation<'tcx, EverInitializedPlaces<'b, 'tcx>>,
polonius_output: Option<Rc<PoloniusOutput>>,
) -> Self {
Flows {
borrows,
uninits,
ever_inits,
polonius_output,
}
Flows { borrows, uninits, ever_inits, polonius_output }
}
crate fn borrows_in_scope(
......
......@@ -28,8 +28,7 @@ fn write_to_dir(
impl AllFactsExt for AllFacts {
/// Return
fn enabled(tcx: TyCtxt<'_>) -> bool {
tcx.sess.opts.debugging_opts.nll_facts
|| tcx.sess.opts.debugging_opts.polonius
tcx.sess.opts.debugging_opts.nll_facts || tcx.sess.opts.debugging_opts.polonius
}
fn write_to_dir(
......@@ -91,11 +90,7 @@ struct FactWriter<'w> {
}
impl<'w> FactWriter<'w> {
fn write_facts_to_path<T>(
&self,
rows: &[T],
file_name: &str,
) -> Result<(), Box<dyn Error>>
fn write_facts_to_path<T>(&self, rows: &[T], file_name: &str) -> Result<(), Box<dyn Error>>
where
T: FactRow,
{
......@@ -109,19 +104,11 @@ fn write_facts_to_path<T>(
}
trait FactRow {
fn write(
&self,
out: &mut File,
location_table: &LocationTable,
) -> Result<(), Box<dyn Error>>;
fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>>;
}
impl FactRow for RegionVid {
fn write(
&self,
out: &mut File,
location_table: &LocationTable,
) -> Result<(), Box<dyn Error>> {
fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[self])
}
}
......@@ -131,11 +118,7 @@ impl<A, B> FactRow for (A, B)
A: FactCell,
B: FactCell,
{
fn write(
&self,
out: &mut File,
location_table: &LocationTable,
) -> Result<(), Box<dyn Error>> {
fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1])
}
}
......@@ -146,11 +129,7 @@ impl<A, B, C> FactRow for (A, B, C)
B: FactCell,
C: FactCell,
{
fn write(
&self,
out: &mut File,
location_table: &LocationTable,
) -> Result<(), Box<dyn Error>> {
fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1, &self.2])
}
}
......@@ -162,11 +141,7 @@ impl<A, B, C, D> FactRow for (A, B, C, D)
C: FactCell,
D: FactCell,
{
fn write(
&self,
out: &mut File,
location_table: &LocationTable,
) -> Result<(), Box<dyn Error>> {
fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1, &self.2, &self.3])
}
}
......@@ -177,11 +152,7 @@ fn write_row(
columns: &[&dyn FactCell],
) -> Result<(), Box<dyn Error>> {
for (index, c) in columns.iter().enumerate() {
let tail = if index == columns.len() - 1 {
"\n"
} else {
"\t"
};
let tail = if index == columns.len() - 1 { "\n" } else { "\t" };
write!(out, "{:?}{}", c.to_string(location_table), tail)?;
}
Ok(())
......
......@@ -7,7 +7,7 @@
use crate::dataflow::move_paths::MoveData;
use crate::dataflow::FlowAtLocation;
use crate::dataflow::MaybeInitializedPlaces;
use rustc::mir::{Local, Body};
use rustc::mir::{Body, Local};
use rustc::ty::{RegionVid, TyCtxt};
use rustc_data_structures::fx::FxHashSet;
use std::rc::Rc;
......
......@@ -247,9 +247,7 @@ fn compute_use_live_points_for(&mut self, local: Local) {
}
if self.use_live_at.insert(p) {
self.cx
.elements
.push_predecessors(self.cx.body, p, &mut self.stack)
self.cx.elements.push_predecessors(self.cx.body, p, &mut self.stack)
}
}
}
......@@ -287,10 +285,7 @@ fn compute_drop_live_points_for(&mut self, local: Local) {
}
}
debug!(
"compute_drop_live_points_for: drop_locations={:?}",
self.drop_locations
);
debug!("compute_drop_live_points_for: drop_locations={:?}", self.drop_locations);
// Reverse DFS. But for drops, we do it a bit differently.
// The stack only ever stores *terminators of blocks*. Within
......@@ -326,17 +321,11 @@ fn compute_drop_live_points_for_block(&mut self, mpi: MovePathIndex, term_point:
// block. One of them may be either a definition or use
// live point.
let term_location = self.cx.elements.to_location(term_point);
debug_assert_eq!(
self.cx.body.terminator_loc(term_location.block),
term_location,
);
debug_assert_eq!(self.cx.body.terminator_loc(term_location.block), term_location,);
let block = term_location.block;
let entry_point = self.cx.elements.entry_point(term_location.block);
for p in (entry_point..term_point).rev() {
debug!(
"compute_drop_live_points_for_block: p = {:?}",
self.cx.elements.to_location(p),
);
debug!("compute_drop_live_points_for_block: p = {:?}", self.cx.elements.to_location(p));
if self.defs.contains(p) {
debug!("compute_drop_live_points_for_block: def site");
......@@ -355,10 +344,7 @@ fn compute_drop_live_points_for_block(&mut self, mpi: MovePathIndex, term_point:
}
for &pred_block in self.cx.body.predecessors_for(block).iter() {
debug!(
"compute_drop_live_points_for_block: pred_block = {:?}",
pred_block,
);
debug!("compute_drop_live_points_for_block: pred_block = {:?}", pred_block,);
// Check whether the variable is (at least partially)
// initialized at the exit of this predecessor. If so, we
......@@ -389,18 +375,12 @@ fn compute_drop_live_points_for_block(&mut self, mpi: MovePathIndex, term_point:
// If the terminator of this predecessor either *assigns*
// our value or is a "normal use", then stop.
if self.defs.contains(pred_term_point) {
debug!(
"compute_drop_live_points_for_block: defined at {:?}",
pred_term_loc
);
debug!("compute_drop_live_points_for_block: defined at {:?}", pred_term_loc);
continue;
}
if self.use_live_at.contains(pred_term_point) {
debug!(
"compute_drop_live_points_for_block: use-live at {:?}",
pred_term_loc
);
debug!("compute_drop_live_points_for_block: use-live at {:?}", pred_term_loc);
continue;
}
......@@ -461,10 +441,7 @@ fn initialized_at_terminator(&mut self, block: BasicBlock, mpi: MovePathIndex) -
// "just ahead" of a terminator.
self.flow_inits.reset_to_entry_of(block);
for statement_index in 0..self.body[block].statements.len() {
let location = Location {
block,
statement_index,
};
let location = Location { block, statement_index };
self.flow_inits.reconstruct_statement_effect(location);
self.flow_inits.apply_local_effect(location);
}
......@@ -531,12 +508,11 @@ fn add_drop_live_facts_for(
if let Some(data) = &drop_data.region_constraint_data {
for &drop_location in drop_locations {
self.typeck
.push_region_constraints(
drop_location.to_locations(),
ConstraintCategory::Boring,
data,
);
self.typeck.push_region_constraints(
drop_location.to_locations(),
ConstraintCategory::Boring,
data,
);
}
}
......@@ -602,14 +578,9 @@ fn compute_drop_data(
debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,);
let param_env = typeck.param_env;
let (dropck_result, region_constraint_data) = param_env
.and(DropckOutlives::new(dropped_ty))
.fully_perform(typeck.infcx)
.unwrap();
DropData {
dropck_result,
region_constraint_data,
}
let (dropck_result, region_constraint_data) =
param_env.and(DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx).unwrap();
DropData { dropck_result, region_constraint_data }
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册