Skip to content

Commit 28312b5

Browse files
author
Albin Stjerna
committed
Rustfmt the files I touched
1 parent 560ef6d commit 28312b5

File tree

6 files changed

+187
-168
lines changed

6 files changed

+187
-168
lines changed

src/librustc_mir/borrow_check/nll/mod.rs

+31-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use crate::transform::MirSource;
1111
use crate::borrow_check::Upvar;
1212
use rustc::hir::def_id::DefId;
1313
use rustc::infer::InferCtxt;
14-
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Local, Location, Body, LocalKind, BasicBlock, Promoted};
14+
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements,
15+
Local, Location, Body, LocalKind, BasicBlock, Promoted};
1516
use rustc::ty::{self, RegionKind, RegionVid};
1617
use rustc_data_structures::indexed_vec::IndexVec;
1718
use rustc_errors::Diagnostic;
@@ -72,11 +73,27 @@ pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'tcx>(
7273

7374
// This function populates an AllFacts instance with base facts related to
7475
// MovePaths and needed for the move analysis.
75-
fn populate_polonius_move_facts(all_facts: &mut AllFacts, move_data: &MoveData<'_>, location_table: &LocationTable, body: &Body<'_>) {
76-
all_facts.path_belongs_to_var.extend(move_data.rev_lookup.iter_locals_enumerated().map(|(v, &m)| (m, v)));
76+
fn populate_polonius_move_facts(
77+
all_facts: &mut AllFacts,
78+
move_data: &MoveData<'_>,
79+
location_table: &LocationTable,
80+
body: &Body<'_>) {
81+
all_facts
82+
.path_belongs_to_var
83+
.extend(
84+
move_data
85+
.rev_lookup
86+
.iter_locals_enumerated()
87+
.map(|(v, &m)| (m, v)));
7788

7889
for (child, move_path) in move_data.move_paths.iter_enumerated() {
79-
all_facts.child.extend(move_path.parents(&move_data.move_paths).iter().map(|&parent| (child, parent)));
90+
all_facts
91+
.child
92+
.extend(
93+
move_path
94+
.parents(&move_data.move_paths)
95+
.iter()
96+
.map(|&parent| (child, parent)));
8097
}
8198

8299
// initialized_at
@@ -99,7 +116,9 @@ fn populate_polonius_move_facts(all_facts: &mut AllFacts, move_data: &MoveData<'
99116
// The initialization happened in (or rather, when arriving at)
100117
// the successors, but not in the unwind block.
101118
let first_statement = Location { block: successor, statement_index: 0};
102-
all_facts.initialized_at.push((init.path, location_table.start_index(first_statement)));
119+
all_facts
120+
.initialized_at
121+
.push((init.path, location_table.start_index(first_statement)));
103122
}
104123

105124
} else {
@@ -121,7 +140,13 @@ fn populate_polonius_move_facts(all_facts: &mut AllFacts, move_data: &MoveData<'
121140

122141
// moved_out_at
123142
// deinitialisation is assumed to always happen!
124-
all_facts.moved_out_at.extend(move_data.moves.iter().map(|mo| (mo.path, location_table.mid_index(mo.source))));
143+
all_facts
144+
.moved_out_at
145+
.extend(
146+
move_data
147+
.moves
148+
.iter()
149+
.map(|mo| (mo.path, location_table.mid_index(mo.source))));
125150
}
126151

127152
/// Computes the (non-lexical) regions from the input MIR.

src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements};
22
use crate::util::liveness::{categorize, DefUse};
33
use rustc::mir::visit::{PlaceContext, Visitor};
4-
use rustc::mir::{Local, Location, Body};
4+
use rustc::mir::{Body, Local, Location};
55
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
66
use rustc_data_structures::vec_linked_list as vll;
77

@@ -72,16 +72,10 @@ impl LocalUseMap {
7272

7373
let mut locals_with_use_data: IndexVec<Local, bool> =
7474
IndexVec::from_elem_n(false, body.local_decls.len());
75-
live_locals
76-
.iter()
77-
.for_each(|&local| locals_with_use_data[local] = true);
78-
79-
LocalUseMapBuild {
80-
local_use_map: &mut local_use_map,
81-
elements,
82-
locals_with_use_data,
83-
}
84-
.visit_body(body);
75+
live_locals.iter().for_each(|&local| locals_with_use_data[local] = true);
76+
77+
LocalUseMapBuild { local_use_map: &mut local_use_map, elements, locals_with_use_data }
78+
.visit_body(body);
8579

8680
local_use_map
8781
}
@@ -151,10 +145,8 @@ impl LocalUseMapBuild<'_> {
151145
location: Location,
152146
) {
153147
let point_index = elements.point_from_location(location);
154-
let appearance_index = appearances.push(Appearance {
155-
point_index,
156-
next: *first_appearance,
157-
});
148+
let appearance_index =
149+
appearances.push(Appearance { point_index, next: *first_appearance });
158150
*first_appearance = Some(appearance_index);
159151
}
160152
}

src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,7 @@ impl LivenessContext<'_, '_, '_, 'tcx> {
394394
) {
395395
debug!("add_use_live_facts_for(value={:?})", value);
396396

397-
Self::make_all_regions_live(
398-
self.elements,
399-
&mut self.typeck,
400-
value,
401-
live_at,
402-
)
397+
Self::make_all_regions_live(self.elements, &mut self.typeck, value, live_at)
403398
}
404399

405400
/// Some variable with type `live_ty` is "drop live" at `location`
@@ -450,12 +445,7 @@ impl LivenessContext<'_, '_, '_, 'tcx> {
450445
// All things in the `outlives` array may be touched by
451446
// the destructor and must be live at this point.
452447
for &kind in &drop_data.dropck_result.kinds {
453-
Self::make_all_regions_live(
454-
self.elements,
455-
&mut self.typeck,
456-
kind,
457-
live_at,
458-
);
448+
Self::make_all_regions_live(self.elements, &mut self.typeck, kind, live_at);
459449

460450
polonius::add_var_drops_regions(&mut self.typeck, dropped_local, &kind);
461451
}

src/librustc_mir/dataflow/move_paths/abs_domain.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! `a[x]` would still overlap them both. But that is not this
1212
//! representation does today.)
1313
14-
use rustc::mir::{Local, PlaceElem, Operand, ProjectionElem};
14+
use rustc::mir::{Local, Operand, PlaceElem, ProjectionElem};
1515
use rustc::ty::Ty;
1616

1717
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
@@ -26,36 +26,36 @@ pub trait Lift {
2626
}
2727
impl<'tcx> Lift for Operand<'tcx> {
2828
type Abstract = AbstractOperand;
29-
fn lift(&self) -> Self::Abstract { AbstractOperand }
29+
fn lift(&self) -> Self::Abstract {
30+
AbstractOperand
31+
}
3032
}
3133
impl Lift for Local {
3234
type Abstract = AbstractOperand;
33-
fn lift(&self) -> Self::Abstract { AbstractOperand }
35+
fn lift(&self) -> Self::Abstract {
36+
AbstractOperand
37+
}
3438
}
3539
impl<'tcx> Lift for Ty<'tcx> {
3640
type Abstract = AbstractType;
37-
fn lift(&self) -> Self::Abstract { AbstractType }
41+
fn lift(&self) -> Self::Abstract {
42+
AbstractType
43+
}
3844
}
3945
impl<'tcx> Lift for PlaceElem<'tcx> {
4046
type Abstract = AbstractElem;
4147
fn lift(&self) -> Self::Abstract {
4248
match *self {
43-
ProjectionElem::Deref =>
44-
ProjectionElem::Deref,
45-
ProjectionElem::Field(ref f, ty) =>
46-
ProjectionElem::Field(f.clone(), ty.lift()),
47-
ProjectionElem::Index(ref i) =>
48-
ProjectionElem::Index(i.lift()),
49-
ProjectionElem::Subslice {from, to} =>
50-
ProjectionElem::Subslice { from: from, to: to },
51-
ProjectionElem::ConstantIndex {offset,min_length,from_end} =>
52-
ProjectionElem::ConstantIndex {
53-
offset,
54-
min_length,
55-
from_end,
56-
},
57-
ProjectionElem::Downcast(a, u) =>
58-
ProjectionElem::Downcast(a, u.clone()),
49+
ProjectionElem::Deref => ProjectionElem::Deref,
50+
ProjectionElem::Field(ref f, ty) => ProjectionElem::Field(f.clone(), ty.lift()),
51+
ProjectionElem::Index(ref i) => ProjectionElem::Index(i.lift()),
52+
ProjectionElem::Subslice { from, to } => {
53+
ProjectionElem::Subslice { from: from, to: to }
54+
}
55+
ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
56+
ProjectionElem::ConstantIndex { offset, min_length, from_end }
57+
}
58+
ProjectionElem::Downcast(a, u) => ProjectionElem::Downcast(a, u.clone()),
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)