From: Santiago Pastorino Date: Thu, 30 Aug 2018 18:06:27 +0000 (-0300) Subject: Run rustfmt X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=a6aa5ddf56a42f547224f616c4f37d490d5e9b88;p=rust.git Run rustfmt --- diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index c9374b6bfc7..3ef8cdfd104 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -17,17 +17,17 @@ use hir::def_id::DefId; use hir::{self, HirId, InlineAsm}; use middle::region; -use mir::interpret::{EvalErrorKind, Scalar, ScalarMaybeUndef, ConstValue}; +use mir::interpret::{ConstValue, EvalErrorKind, Scalar, ScalarMaybeUndef}; use mir::visit::MirVisitable; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; use rustc_data_structures::graph::dominators::{dominators, Dominators}; use rustc_data_structures::graph::{self, GraphPredecessors, GraphSuccessors}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use smallvec::SmallVec; use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::ReadGuard; use rustc_serialize as serialize; +use smallvec::SmallVec; use std::borrow::Cow; use std::fmt::{self, Debug, Formatter, Write}; use std::ops::{Index, IndexMut}; @@ -208,9 +208,10 @@ pub fn predecessor_locations(&self, loc: Location) -> impl Iterator impl Iterator { }); mod binding_form_impl { - use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; use ich::StableHashingContext; + use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; impl<'a, 'tcx> HashStable> for super::BindingForm<'tcx> { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher, + ) { use super::BindingForm::*; ::std::mem::discriminant(self).hash_stable(hcx, hasher); @@ -1500,16 +1509,17 @@ pub fn fmt_successor_labels(&self) -> Vec> { .map(|&u| { let mut s = String::new(); let c = ty::Const { - val: ConstValue::Scalar(Scalar::Bits { + val: ConstValue::Scalar( + Scalar::Bits { bits: u, size: size.bytes() as u8, - }.into()), + }.into(), + ), ty: switch_ty, }; fmt_const_val(&mut s, &c).unwrap(); s.into() - }) - .chain(iter::once(String::from("otherwise").into())) + }).chain(iter::once(String::from("otherwise").into())) .collect() } Call { @@ -2039,7 +2049,13 @@ pub enum AggregateKind<'tcx> { /// active field number and is present only for union expressions /// -- e.g. for a union expression `SomeUnion { c: .. }`, the /// active field index would identity the field `c` - Adt(&'tcx AdtDef, usize, &'tcx Substs<'tcx>, Option>, Option), + Adt( + &'tcx AdtDef, + usize, + &'tcx Substs<'tcx>, + Option>, + Option, + ), Closure(DefId, ClosureSubsts<'tcx>), 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 { return write!(f, "{:?}{}", ((bits as i128) << shift) >> shift, i); } Char => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()), - _ => {}, + _ => {} } } // print function definitons @@ -2305,14 +2321,12 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result { let alloc = tcx.alloc_map.lock().get(ptr.alloc_id); if let Some(interpret::AllocType::Memory(alloc)) = alloc { assert_eq!(len as usize as u128, len); - let slice = &alloc - .bytes - [(ptr.offset.bytes() as usize)..] - [..(len as usize)]; + let slice = + &alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)]; let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri"); write!(f, "{:?}", s) } else { - write!(f, "pointer to erroneous constant {:?}, {:?}", ptr, len) + write!(f, "pointer to erroneous constant {:?}, {:?}", ptr, len) } }); } @@ -2843,15 +2857,13 @@ fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) let kind = box match **kind { AggregateKind::Array(ty) => AggregateKind::Array(ty.fold_with(folder)), AggregateKind::Tuple => AggregateKind::Tuple, - AggregateKind::Adt(def, v, substs, user_ty, n) => { - AggregateKind::Adt( - def, - v, - substs.fold_with(folder), - user_ty.fold_with(folder), - n, - ) - } + AggregateKind::Adt(def, v, substs, user_ty, n) => AggregateKind::Adt( + def, + v, + substs.fold_with(folder), + user_ty.fold_with(folder), + n, + ), AggregateKind::Closure(id, substs) => { AggregateKind::Closure(id, substs.fold_with(folder)) } @@ -2882,8 +2894,9 @@ fn super_visit_with>(&self, visitor: &mut V) -> bool { (match **kind { AggregateKind::Array(ty) => ty.visit_with(visitor), AggregateKind::Tuple => false, - AggregateKind::Adt(_, _, substs, user_ty, _) => - substs.visit_with(visitor) || user_ty.visit_with(visitor), + AggregateKind::Adt(_, _, substs, user_ty, _) => { + substs.visit_with(visitor) || user_ty.visit_with(visitor) + } AggregateKind::Closure(_, substs) => substs.visit_with(visitor), AggregateKind::Generator(_, substs, _) => substs.visit_with(visitor), }) || fields.visit_with(visitor) diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index efd80498306..a0b0aabf73e 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -26,8 +26,8 @@ use super::{InitializationRequiringAction, PrefixSet}; use dataflow::drop_flag_effects; -use dataflow::move_paths::MovePathIndex; use dataflow::move_paths::indexes::MoveOutIndex; +use dataflow::move_paths::MovePathIndex; use util::borrowck_errors::{BorrowckErrors, Origin}; impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { @@ -347,10 +347,7 @@ pub(super) fn report_conflicting_borrow( if issued_spans == borrow_spans { borrow_spans.var_span_label( &mut err, - format!( - "borrows occur due to use of `{}` in closure", - desc_place - ), + format!("borrows occur due to use of `{}` in closure", desc_place), ); } else { let borrow_place = &issued_borrow.borrowed_place; @@ -365,7 +362,10 @@ pub(super) fn report_conflicting_borrow( borrow_spans.var_span_label( &mut err, - format!("second borrow occurs due to use of `{}` in closure", desc_place), + format!( + "second borrow occurs due to use of `{}` in closure", + desc_place + ), ); } @@ -412,10 +412,7 @@ pub(super) fn report_borrowed_value_does_not_live_long_enough( let mut err = match &self.describe_place(&borrow.borrowed_place) { Some(_) if self.is_place_thread_local(root_place) => { - self.report_thread_local_value_does_not_live_long_enough( - drop_span, - borrow_span, - ) + self.report_thread_local_value_does_not_live_long_enough(drop_span, borrow_span) } Some(name) => self.report_local_value_does_not_live_long_enough( context, @@ -461,7 +458,10 @@ fn report_local_value_does_not_live_long_enough( ); let mut err = self.tcx.path_does_not_live_long_enough( - borrow_span, &format!("`{}`", name), Origin::Mir); + borrow_span, + &format!("`{}`", name), + Origin::Mir, + ); err.span_label(borrow_span, "borrowed value does not live long enough"); err.span_label( @@ -485,11 +485,14 @@ fn report_thread_local_value_does_not_live_long_enough( drop_span, borrow_span ); - let mut err = self.tcx.thread_local_value_does_not_live_long_enough( - borrow_span, Origin::Mir); + let mut err = self + .tcx + .thread_local_value_does_not_live_long_enough(borrow_span, Origin::Mir); - err.span_label(borrow_span, - "thread-local variables cannot be borrowed beyond the end of the function"); + err.span_label( + borrow_span, + "thread-local variables cannot be borrowed beyond the end of the function", + ); err.span_label(drop_span, "end of enclosing function is here"); err } @@ -520,11 +523,7 @@ fn report_temporary_value_does_not_live_long_enough( err } - fn get_moved_indexes( - &mut self, - context: Context, - mpi: MovePathIndex, - ) -> Vec { + fn get_moved_indexes(&mut self, context: Context, mpi: MovePathIndex) -> Vec { let mir = self.mir; let mut stack = Vec::new(); @@ -533,16 +532,21 @@ fn get_moved_indexes( let mut visited = FxHashSet(); let mut result = vec![]; - 'dfs: - while let Some(l) = stack.pop() { - debug!("report_use_of_moved_or_uninitialized: current_location={:?}", l); + 'dfs: while let Some(l) = stack.pop() { + debug!( + "report_use_of_moved_or_uninitialized: current_location={:?}", + l + ); if !visited.insert(l) { continue; } // check for moves - let stmt_kind = mir[l.block].statements.get(l.statement_index).map(|s| &s.kind); + let stmt_kind = mir[l.block] + .statements + .get(l.statement_index) + .map(|s| &s.kind); if let Some(StatementKind::StorageDead(..)) = stmt_kind { // this analysis only tries to find moves explicitly // written by the user, so we ignore the move-outs @@ -578,13 +582,11 @@ fn get_moved_indexes( // check for inits let mut any_match = false; - drop_flag_effects::for_location_inits( - self.tcx, - self.mir, - self.move_data, - l, - |m| if m == mpi { any_match = true; }, - ); + drop_flag_effects::for_location_inits(self.tcx, self.mir, self.move_data, l, |m| { + if m == mpi { + any_match = true; + } + }); if any_match { continue 'dfs; } @@ -964,8 +966,10 @@ pub fn is_place_thread_local(&self, place: &Place<'tcx>) -> bool { let attrs = self.tcx.get_attrs(statik.def_id); let is_thread_local = attrs.iter().any(|attr| attr.check_name("thread_local")); - debug!("is_place_thread_local: attrs={:?} is_thread_local={:?}", - attrs, is_thread_local); + debug!( + "is_place_thread_local: attrs={:?} is_thread_local={:?}", + attrs, is_thread_local + ); is_thread_local } else { debug!("is_place_thread_local: no"); @@ -983,7 +987,7 @@ pub(super) enum UseSpans { // it's present. args_span: Span, // The span of the first use of the captured variable inside the closure. - var_span: Span + var_span: Span, }, // This access has a single span associated to it: common case. OtherUse(Span),