Skip to content

Commit a6aa5dd

Browse files
committed
Run rustfmt
1 parent 373fc93 commit a6aa5dd

File tree

2 files changed

+84
-67
lines changed

2 files changed

+84
-67
lines changed

Diff for: src/librustc/mir/mod.rs

+46-33
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ use hir::def::CtorKind;
1717
use hir::def_id::DefId;
1818
use hir::{self, HirId, InlineAsm};
1919
use middle::region;
20-
use mir::interpret::{EvalErrorKind, Scalar, ScalarMaybeUndef, ConstValue};
20+
use mir::interpret::{ConstValue, EvalErrorKind, Scalar, ScalarMaybeUndef};
2121
use mir::visit::MirVisitable;
2222
use rustc_apfloat::ieee::{Double, Single};
2323
use rustc_apfloat::Float;
2424
use rustc_data_structures::graph::dominators::{dominators, Dominators};
2525
use rustc_data_structures::graph::{self, GraphPredecessors, GraphSuccessors};
2626
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
27-
use smallvec::SmallVec;
2827
use rustc_data_structures::sync::Lrc;
2928
use rustc_data_structures::sync::ReadGuard;
3029
use rustc_serialize as serialize;
30+
use smallvec::SmallVec;
3131
use std::borrow::Cow;
3232
use std::fmt::{self, Debug, Formatter, Write};
3333
use std::ops::{Index, IndexMut};
@@ -208,9 +208,10 @@ impl<'tcx> Mir<'tcx> {
208208
let if_zero_locations = if loc.statement_index == 0 {
209209
let predecessor_blocks = self.predecessors_for(loc.block);
210210
let num_predecessor_blocks = predecessor_blocks.len();
211-
Some((0 .. num_predecessor_blocks)
212-
.map(move |i| predecessor_blocks[i])
213-
.map(move |bb| self.terminator_loc(bb))
211+
Some(
212+
(0..num_predecessor_blocks)
213+
.map(move |i| predecessor_blocks[i])
214+
.map(move |bb| self.terminator_loc(bb)),
214215
)
215216
} else {
216217
None
@@ -219,10 +220,16 @@ impl<'tcx> Mir<'tcx> {
219220
let if_not_zero_locations = if loc.statement_index == 0 {
220221
None
221222
} else {
222-
Some(Location { block: loc.block, statement_index: loc.statement_index - 1 })
223+
Some(Location {
224+
block: loc.block,
225+
statement_index: loc.statement_index - 1,
226+
})
223227
};
224228

225-
if_zero_locations.into_iter().flatten().chain(if_not_zero_locations)
229+
if_zero_locations
230+
.into_iter()
231+
.flatten()
232+
.chain(if_not_zero_locations)
226233
}
227234

228235
#[inline]
@@ -577,13 +584,15 @@ impl_stable_hash_for!(struct self::VarBindingForm<'tcx> {
577584
});
578585

579586
mod binding_form_impl {
580-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
581587
use ich::StableHashingContext;
588+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
582589

583590
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for super::BindingForm<'tcx> {
584-
fn hash_stable<W: StableHasherResult>(&self,
585-
hcx: &mut StableHashingContext<'a>,
586-
hasher: &mut StableHasher<W>) {
591+
fn hash_stable<W: StableHasherResult>(
592+
&self,
593+
hcx: &mut StableHashingContext<'a>,
594+
hasher: &mut StableHasher<W>,
595+
) {
587596
use super::BindingForm::*;
588597
::std::mem::discriminant(self).hash_stable(hcx, hasher);
589598

@@ -1500,16 +1509,17 @@ impl<'tcx> TerminatorKind<'tcx> {
15001509
.map(|&u| {
15011510
let mut s = String::new();
15021511
let c = ty::Const {
1503-
val: ConstValue::Scalar(Scalar::Bits {
1512+
val: ConstValue::Scalar(
1513+
Scalar::Bits {
15041514
bits: u,
15051515
size: size.bytes() as u8,
1506-
}.into()),
1516+
}.into(),
1517+
),
15071518
ty: switch_ty,
15081519
};
15091520
fmt_const_val(&mut s, &c).unwrap();
15101521
s.into()
1511-
})
1512-
.chain(iter::once(String::from("otherwise").into()))
1522+
}).chain(iter::once(String::from("otherwise").into()))
15131523
.collect()
15141524
}
15151525
Call {
@@ -2039,7 +2049,13 @@ pub enum AggregateKind<'tcx> {
20392049
/// active field number and is present only for union expressions
20402050
/// -- e.g. for a union expression `SomeUnion { c: .. }`, the
20412051
/// active field index would identity the field `c`
2042-
Adt(&'tcx AdtDef, usize, &'tcx Substs<'tcx>, Option<CanonicalTy<'tcx>>, Option<usize>),
2052+
Adt(
2053+
&'tcx AdtDef,
2054+
usize,
2055+
&'tcx Substs<'tcx>,
2056+
Option<CanonicalTy<'tcx>>,
2057+
Option<usize>,
2058+
),
20432059

20442060
Closure(DefId, ClosureSubsts<'tcx>),
20452061
Generator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability),
@@ -2289,7 +2305,7 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
22892305
return write!(f, "{:?}{}", ((bits as i128) << shift) >> shift, i);
22902306
}
22912307
Char => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()),
2292-
_ => {},
2308+
_ => {}
22932309
}
22942310
}
22952311
// print function definitons
@@ -2305,14 +2321,12 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
23052321
let alloc = tcx.alloc_map.lock().get(ptr.alloc_id);
23062322
if let Some(interpret::AllocType::Memory(alloc)) = alloc {
23072323
assert_eq!(len as usize as u128, len);
2308-
let slice = &alloc
2309-
.bytes
2310-
[(ptr.offset.bytes() as usize)..]
2311-
[..(len as usize)];
2324+
let slice =
2325+
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
23122326
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
23132327
write!(f, "{:?}", s)
23142328
} else {
2315-
write!(f, "pointer to erroneous constant {:?}, {:?}", ptr, len)
2329+
write!(f, "pointer to erroneous constant {:?}, {:?}", ptr, len)
23162330
}
23172331
});
23182332
}
@@ -2843,15 +2857,13 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
28432857
let kind = box match **kind {
28442858
AggregateKind::Array(ty) => AggregateKind::Array(ty.fold_with(folder)),
28452859
AggregateKind::Tuple => AggregateKind::Tuple,
2846-
AggregateKind::Adt(def, v, substs, user_ty, n) => {
2847-
AggregateKind::Adt(
2848-
def,
2849-
v,
2850-
substs.fold_with(folder),
2851-
user_ty.fold_with(folder),
2852-
n,
2853-
)
2854-
}
2860+
AggregateKind::Adt(def, v, substs, user_ty, n) => AggregateKind::Adt(
2861+
def,
2862+
v,
2863+
substs.fold_with(folder),
2864+
user_ty.fold_with(folder),
2865+
n,
2866+
),
28552867
AggregateKind::Closure(id, substs) => {
28562868
AggregateKind::Closure(id, substs.fold_with(folder))
28572869
}
@@ -2882,8 +2894,9 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
28822894
(match **kind {
28832895
AggregateKind::Array(ty) => ty.visit_with(visitor),
28842896
AggregateKind::Tuple => false,
2885-
AggregateKind::Adt(_, _, substs, user_ty, _) =>
2886-
substs.visit_with(visitor) || user_ty.visit_with(visitor),
2897+
AggregateKind::Adt(_, _, substs, user_ty, _) => {
2898+
substs.visit_with(visitor) || user_ty.visit_with(visitor)
2899+
}
28872900
AggregateKind::Closure(_, substs) => substs.visit_with(visitor),
28882901
AggregateKind::Generator(_, substs, _) => substs.visit_with(visitor),
28892902
}) || fields.visit_with(visitor)

Diff for: src/librustc_mir/borrow_check/error_reporting.rs

+38-34
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use super::{Context, MirBorrowckCtxt};
2626
use super::{InitializationRequiringAction, PrefixSet};
2727

2828
use dataflow::drop_flag_effects;
29-
use dataflow::move_paths::MovePathIndex;
3029
use dataflow::move_paths::indexes::MoveOutIndex;
30+
use dataflow::move_paths::MovePathIndex;
3131
use util::borrowck_errors::{BorrowckErrors, Origin};
3232

3333
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
@@ -347,10 +347,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
347347
if issued_spans == borrow_spans {
348348
borrow_spans.var_span_label(
349349
&mut err,
350-
format!(
351-
"borrows occur due to use of `{}` in closure",
352-
desc_place
353-
),
350+
format!("borrows occur due to use of `{}` in closure", desc_place),
354351
);
355352
} else {
356353
let borrow_place = &issued_borrow.borrowed_place;
@@ -365,7 +362,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
365362

366363
borrow_spans.var_span_label(
367364
&mut err,
368-
format!("second borrow occurs due to use of `{}` in closure", desc_place),
365+
format!(
366+
"second borrow occurs due to use of `{}` in closure",
367+
desc_place
368+
),
369369
);
370370
}
371371

@@ -412,10 +412,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
412412

413413
let mut err = match &self.describe_place(&borrow.borrowed_place) {
414414
Some(_) if self.is_place_thread_local(root_place) => {
415-
self.report_thread_local_value_does_not_live_long_enough(
416-
drop_span,
417-
borrow_span,
418-
)
415+
self.report_thread_local_value_does_not_live_long_enough(drop_span, borrow_span)
419416
}
420417
Some(name) => self.report_local_value_does_not_live_long_enough(
421418
context,
@@ -461,7 +458,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
461458
);
462459

463460
let mut err = self.tcx.path_does_not_live_long_enough(
464-
borrow_span, &format!("`{}`", name), Origin::Mir);
461+
borrow_span,
462+
&format!("`{}`", name),
463+
Origin::Mir,
464+
);
465465

466466
err.span_label(borrow_span, "borrowed value does not live long enough");
467467
err.span_label(
@@ -485,11 +485,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
485485
drop_span, borrow_span
486486
);
487487

488-
let mut err = self.tcx.thread_local_value_does_not_live_long_enough(
489-
borrow_span, Origin::Mir);
488+
let mut err = self
489+
.tcx
490+
.thread_local_value_does_not_live_long_enough(borrow_span, Origin::Mir);
490491

491-
err.span_label(borrow_span,
492-
"thread-local variables cannot be borrowed beyond the end of the function");
492+
err.span_label(
493+
borrow_span,
494+
"thread-local variables cannot be borrowed beyond the end of the function",
495+
);
493496
err.span_label(drop_span, "end of enclosing function is here");
494497
err
495498
}
@@ -520,11 +523,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
520523
err
521524
}
522525

523-
fn get_moved_indexes(
524-
&mut self,
525-
context: Context,
526-
mpi: MovePathIndex,
527-
) -> Vec<MoveOutIndex> {
526+
fn get_moved_indexes(&mut self, context: Context, mpi: MovePathIndex) -> Vec<MoveOutIndex> {
528527
let mir = self.mir;
529528

530529
let mut stack = Vec::new();
@@ -533,16 +532,21 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
533532
let mut visited = FxHashSet();
534533
let mut result = vec![];
535534

536-
'dfs:
537-
while let Some(l) = stack.pop() {
538-
debug!("report_use_of_moved_or_uninitialized: current_location={:?}", l);
535+
'dfs: while let Some(l) = stack.pop() {
536+
debug!(
537+
"report_use_of_moved_or_uninitialized: current_location={:?}",
538+
l
539+
);
539540

540541
if !visited.insert(l) {
541542
continue;
542543
}
543544

544545
// check for moves
545-
let stmt_kind = mir[l.block].statements.get(l.statement_index).map(|s| &s.kind);
546+
let stmt_kind = mir[l.block]
547+
.statements
548+
.get(l.statement_index)
549+
.map(|s| &s.kind);
546550
if let Some(StatementKind::StorageDead(..)) = stmt_kind {
547551
// this analysis only tries to find moves explicitly
548552
// written by the user, so we ignore the move-outs
@@ -578,13 +582,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
578582

579583
// check for inits
580584
let mut any_match = false;
581-
drop_flag_effects::for_location_inits(
582-
self.tcx,
583-
self.mir,
584-
self.move_data,
585-
l,
586-
|m| if m == mpi { any_match = true; },
587-
);
585+
drop_flag_effects::for_location_inits(self.tcx, self.mir, self.move_data, l, |m| {
586+
if m == mpi {
587+
any_match = true;
588+
}
589+
});
588590
if any_match {
589591
continue 'dfs;
590592
}
@@ -964,8 +966,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
964966
let attrs = self.tcx.get_attrs(statik.def_id);
965967
let is_thread_local = attrs.iter().any(|attr| attr.check_name("thread_local"));
966968

967-
debug!("is_place_thread_local: attrs={:?} is_thread_local={:?}",
968-
attrs, is_thread_local);
969+
debug!(
970+
"is_place_thread_local: attrs={:?} is_thread_local={:?}",
971+
attrs, is_thread_local
972+
);
969973
is_thread_local
970974
} else {
971975
debug!("is_place_thread_local: no");
@@ -983,7 +987,7 @@ pub(super) enum UseSpans {
983987
// it's present.
984988
args_span: Span,
985989
// The span of the first use of the captured variable inside the closure.
986-
var_span: Span
990+
var_span: Span,
987991
},
988992
// This access has a single span associated to it: common case.
989993
OtherUse(Span),

0 commit comments

Comments
 (0)