Rollup merge of #40463 - tshepang:nit, r=nikomatsakis

some style fixes
This commit is contained in:
Corey Farwell
2017-03-17 08:48:54 -04:00
committed by GitHub
13 changed files with 91 additions and 83 deletions
+15 -17
View File
@@ -52,14 +52,16 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tables: tables,
graph: graph,
fn_exit: fn_exit,
loop_scopes: Vec::new()
loop_scopes: Vec::new(),
};
body_exit = cfg_builder.expr(&body.value, entry);
cfg_builder.add_contained_edge(body_exit, fn_exit);
let CFGBuilder {graph, ..} = cfg_builder;
CFG {graph: graph,
entry: entry,
exit: fn_exit}
let CFGBuilder { graph, .. } = cfg_builder;
CFG {
graph: graph,
entry: entry,
exit: fn_exit,
}
}
impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
@@ -81,7 +83,8 @@ fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
self.add_ast_node(id, &[exit])
}
hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) => {
hir::StmtExpr(ref expr, id) |
hir::StmtSemi(ref expr, id) => {
let exit = self.expr(&expr, pred);
self.add_ast_node(id, &[exit])
}
@@ -95,9 +98,7 @@ fn decl(&mut self, decl: &hir::Decl, pred: CFGIndex) -> CFGIndex {
self.pat(&local.pat, init_exit)
}
hir::DeclItem(_) => {
pred
}
hir::DeclItem(_) => pred,
}
}
@@ -107,9 +108,7 @@ fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
PatKind::Path(_) |
PatKind::Lit(..) |
PatKind::Range(..) |
PatKind::Wild => {
self.add_ast_node(pat.id, &[pred])
}
PatKind::Wild => self.add_ast_node(pat.id, &[pred]),
PatKind::Box(ref subpat) |
PatKind::Ref(ref subpat, _) |
@@ -125,8 +124,7 @@ fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
}
PatKind::Struct(_, ref subpats, _) => {
let pats_exit =
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
let pats_exit = self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
self.add_ast_node(pat.id, &[pats_exit])
}
@@ -385,7 +383,7 @@ fn call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
let method_call = ty::MethodCall::expr(call_expr.id);
let fn_ty = match self.tables.method_map.get(&method_call) {
Some(method) => method.ty,
None => self.tables.expr_ty_adjusted(func_or_rcvr)
None => self.tables.expr_ty_adjusted(func_or_rcvr),
};
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
@@ -556,7 +554,7 @@ fn add_exiting_edge(&mut self,
from_index: CFGIndex,
to_loop: LoopScope,
to_index: CFGIndex) {
let mut data = CFGEdgeData {exiting_scopes: vec![] };
let mut data = CFGEdgeData { exiting_scopes: vec![] };
let mut scope = self.tcx.region_maps.node_extent(from_expr.id);
let target_scope = self.tcx.region_maps.node_extent(to_loop.loop_id);
while scope != target_scope {
@@ -591,7 +589,7 @@ fn find_scope(&self,
}
span_bug!(expr.span, "no loop scope for id {}", loop_id);
}
Err(err) => span_bug!(expr.span, "loop scope error: {}", err)
Err(err) => span_bug!(expr.span, "loop scope error: {}", err),
}
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ pub fn new(graph: DepGraph) -> DepTrackingMap<M> {
DepTrackingMap {
phantom: PhantomData,
graph: graph,
map: FxHashMap()
map: FxHashMap(),
}
}
+6 -3
View File
@@ -29,7 +29,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> {
tcx: TyCtxt<'visit, 'tcx, 'tcx>,
dep_node_fn: &'visit mut F,
visitor: &'visit mut V
visitor: &'visit mut V,
}
impl<'visit, 'tcx, F, V> ItemLikeVisitor<'tcx> for TrackingVisitor<'visit, 'tcx, F, V>
@@ -70,13 +70,16 @@ fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) {
let mut tracking_visitor = TrackingVisitor {
tcx: tcx,
dep_node_fn: &mut dep_node_fn,
visitor: visitor
visitor: visitor,
};
krate.visit_all_item_likes(&mut tracking_visitor)
}
pub fn visit_all_bodies_in_krate<'a, 'tcx, C>(tcx: TyCtxt<'a, 'tcx, 'tcx>, callback: C)
where C: Fn(/* body_owner */ DefId, /* body id */ hir::BodyId),
where C: Fn(/* body_owner */
DefId,
/* body id */
hir::BodyId)
{
let krate = tcx.hir.krate();
for &body_id in &krate.body_ids {
+10 -4
View File
@@ -113,13 +113,19 @@ fn into_early_lint(self, id: LintId) -> EarlyLint {
let (span, msg) = self;
let mut diagnostic = Diagnostic::new(errors::Level::Warning, msg);
diagnostic.set_span(span);
EarlyLint { id: id, diagnostic: diagnostic }
EarlyLint {
id: id,
diagnostic: diagnostic,
}
}
}
impl IntoEarlyLint for Diagnostic {
fn into_early_lint(self, id: LintId) -> EarlyLint {
EarlyLint { id: id, diagnostic: self }
EarlyLint {
id: id,
diagnostic: self,
}
}
}
@@ -146,7 +152,7 @@ enum TargetLint {
enum FindLintError {
NotFound,
Removed
Removed,
}
impl LintStore {
@@ -1127,7 +1133,7 @@ enum CheckLintNameResult {
NoLint,
// The lint is either renamed or removed. This is the warning
// message.
Warning(String)
Warning(String),
}
/// Checks the name of a lint for its existence, and whether it was
+4 -1
View File
@@ -25,7 +25,10 @@ pub struct VariantInfo {
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum SizeKind { Exact, Min }
pub enum SizeKind {
Exact,
Min,
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct FieldInfo {
+2 -2
View File
@@ -37,7 +37,7 @@
pub struct OverlapError {
pub with_impl: DefId,
pub trait_desc: String,
pub self_desc: Option<String>
pub self_desc: Option<String>,
}
/// Given a subst for the requested impl, translate it to a subst
@@ -274,7 +274,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
}
pub struct SpecializesCache {
map: FxHashMap<(DefId, DefId), bool>
map: FxHashMap<(DefId, DefId), bool>,
}
impl SpecializesCache {
+1 -1
View File
@@ -23,7 +23,7 @@
#[derive(Clone, Copy, Debug)]
pub struct ExpectedFound<T> {
pub expected: T,
pub found: T
pub found: T,
}
// Data structures used in type unification
+1 -2
View File
@@ -374,14 +374,13 @@ impl LocalPathBuffer {
fn new(root_mode: RootMode) -> LocalPathBuffer {
LocalPathBuffer {
root_mode: root_mode,
str: String::new()
str: String::new(),
}
}
fn into_string(self) -> String {
self.str
}
}
impl ItemPathBuffer for LocalPathBuffer {
+1 -1
View File
@@ -85,7 +85,7 @@ fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
pub struct CycleError<'a> {
span: Span,
cycle: RefMut<'a, [(Span, Query)]>
cycle: RefMut<'a, [(Span, Query)]>,
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
+31 -31
View File
@@ -45,7 +45,7 @@ pub struct TypeAndMut<'tcx> {
/// at least as big as the scope `fr.scope`".
pub struct FreeRegion {
pub scope: region::CodeExtent,
pub bound_region: BoundRegion
pub bound_region: BoundRegion,
}
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
@@ -65,7 +65,7 @@ pub enum BoundRegion {
// Anonymous region for the implicit env pointer parameter
// to a closure
BrEnv
BrEnv,
}
/// When a region changed from late-bound to early-bound when #32330
@@ -320,7 +320,7 @@ impl<'tcx> Slice<ExistentialPredicate<'tcx>> {
pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>> {
match self.get(0) {
Some(&ExistentialPredicate::Trait(tr)) => Some(tr),
_ => None
_ => None,
}
}
@@ -520,13 +520,13 @@ pub fn as_ref(&self) -> Binder<&T> {
ty::Binder(&self.0)
}
pub fn map_bound_ref<F,U>(&self, f: F) -> Binder<U>
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U>
where F: FnOnce(&T) -> U
{
self.as_ref().map_bound(f)
}
pub fn map_bound<F,U>(self, f: F) -> Binder<U>
pub fn map_bound<F, U>(self, f: F) -> Binder<U>
where F: FnOnce(T) -> U
{
ty::Binder(f(self.0))
@@ -790,22 +790,22 @@ pub struct TyVid {
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub struct IntVid {
pub index: u32
pub index: u32,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub struct FloatVid {
pub index: u32
pub index: u32,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub struct RegionVid {
pub index: u32
pub index: u32,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub struct SkolemizedRegionVid {
pub index: u32
pub index: u32,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
@@ -819,7 +819,7 @@ pub enum InferTy {
/// `infer::freshen` for more details.
FreshTy(u32),
FreshIntTy(u32),
FreshFloatTy(u32)
FreshFloatTy(u32),
}
/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
@@ -827,7 +827,7 @@ pub enum InferTy {
pub struct ExistentialProjection<'tcx> {
pub trait_ref: ExistentialTraitRef<'tcx>,
pub item_name: Name,
pub ty: Ty<'tcx>
pub ty: Ty<'tcx>,
}
pub type PolyExistentialProjection<'tcx> = Binder<ExistentialProjection<'tcx>>;
@@ -860,9 +860,9 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy {
trait_ref: self.trait_ref.with_self_ty(tcx, self_ty),
item_name: self.item_name
item_name: self.item_name,
},
ty: self.ty
ty: self.ty,
}
}
}
@@ -899,7 +899,7 @@ pub fn is_bound(&self) -> bool {
match *self {
ty::ReEarlyBound(..) => true,
ty::ReLateBound(..) => true,
_ => false
_ => false,
}
}
@@ -969,7 +969,7 @@ pub fn as_opt_param_ty(&self) -> Option<ty::ParamTy> {
pub fn is_nil(&self) -> bool {
match self.sty {
TyTuple(ref tys, _) => tys.is_empty(),
_ => false
_ => false,
}
}
@@ -1047,7 +1047,7 @@ pub fn is_primitive(&self) -> bool {
pub fn is_ty_var(&self) -> bool {
match self.sty {
TyInfer(TyVar(_)) => true,
_ => false
_ => false,
}
}
@@ -1071,7 +1071,7 @@ pub fn is_param(&self, index: u32) -> bool {
pub fn is_self(&self) -> bool {
match self.sty {
TyParam(ref p) => p.is_self(),
_ => false
_ => false,
}
}
@@ -1088,7 +1088,7 @@ pub fn is_slice(&self) -> bool {
pub fn is_structural(&self) -> bool {
match self.sty {
TyAdt(..) | TyTuple(..) | TyArray(..) | TyClosure(..) => true,
_ => self.is_slice() | self.is_trait()
_ => self.is_slice() | self.is_trait(),
}
}
@@ -1096,7 +1096,7 @@ pub fn is_structural(&self) -> bool {
pub fn is_simd(&self) -> bool {
match self.sty {
TyAdt(def, _) => def.repr.simd,
_ => false
_ => false,
}
}
@@ -1127,7 +1127,7 @@ pub fn simd_size(&self, _cx: TyCtxt) -> usize {
pub fn is_region_ptr(&self) -> bool {
match self.sty {
TyRef(..) => true,
_ => false
_ => false,
}
}
@@ -1145,7 +1145,7 @@ pub fn is_mutable_pointer(&self) -> bool {
pub fn is_unsafe_ptr(&self) -> bool {
match self.sty {
TyRawPtr(_) => return true,
_ => return false
_ => return false,
}
}
@@ -1189,7 +1189,7 @@ pub fn is_floating_point(&self) -> bool {
pub fn is_trait(&self) -> bool {
match self.sty {
TyDynamic(..) => true,
_ => false
_ => false,
}
}
@@ -1205,7 +1205,7 @@ pub fn is_fresh(&self) -> bool {
TyInfer(FreshTy(_)) => true,
TyInfer(FreshIntTy(_)) => true,
TyInfer(FreshFloatTy(_)) => true,
_ => false
_ => false,
}
}
@@ -1219,7 +1219,7 @@ pub fn is_uint(&self) -> bool {
pub fn is_char(&self) -> bool {
match self.sty {
TyChar => true,
_ => false
_ => false,
}
}
@@ -1237,7 +1237,7 @@ pub fn is_numeric(&self) -> bool {
pub fn is_signed(&self) -> bool {
match self.sty {
TyInt(_) => true,
_ => false
_ => false,
}
}
@@ -1245,7 +1245,7 @@ pub fn is_machine(&self) -> bool {
match self.sty {
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false,
TyInt(..) | TyUint(..) | TyFloat(..) => true,
_ => false
_ => false,
}
}
@@ -1276,7 +1276,7 @@ pub fn builtin_deref(&self, explicit: bool, pref: ty::LvaluePreference)
},
TyRef(_, mt) => Some(mt),
TyRawPtr(mt) if explicit => Some(mt),
_ => None
_ => None,
}
}
@@ -1284,7 +1284,7 @@ pub fn builtin_deref(&self, explicit: bool, pref: ty::LvaluePreference)
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
match self.sty {
TyArray(ty, _) | TySlice(ty) => Some(ty),
_ => None
_ => None,
}
}
@@ -1307,7 +1307,7 @@ pub fn fn_ret(&self) -> Binder<Ty<'tcx>> {
pub fn is_fn(&self) -> bool {
match self.sty {
TyFnDef(..) | TyFnPtr(_) => true,
_ => false
_ => false,
}
}
@@ -1316,14 +1316,14 @@ pub fn ty_to_def_id(&self) -> Option<DefId> {
TyDynamic(ref tt, ..) => tt.principal().map(|p| p.def_id()),
TyAdt(def, _) => Some(def.did),
TyClosure(id, _) => Some(id),
_ => None
_ => None,
}
}
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
match self.sty {
TyAdt(adt, _) => Some(adt),
_ => None
_ => None,
}
}
+14 -16
View File
@@ -16,7 +16,7 @@
use hir::map as hir_map;
use traits::{self, Reveal};
use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
use ty::{ParameterEnvironment};
use ty::ParameterEnvironment;
use ty::fold::TypeVisitor;
use ty::layout::{Layout, LayoutError};
use ty::TypeVariants::*;
@@ -39,13 +39,13 @@
type Disr = ConstInt;
pub trait IntTypeExt {
pub trait IntTypeExt {
fn to_ty<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>;
fn disr_incr<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, val: Option<Disr>)
-> Option<Disr>;
fn assert_ty_matches(&self, val: Disr);
fn initial_discriminant<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Disr;
}
}
macro_rules! typed_literal {
@@ -133,7 +133,7 @@ fn disr_incr<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, val: Option<Disr>)
pub enum CopyImplementationError<'tcx> {
InfrigingField(&'tcx ty::FieldDef),
NotAnAdt,
HasDestructor
HasDestructor,
}
/// Describes whether a type is representable. For types that are not
@@ -159,14 +159,14 @@ pub fn can_type_implement_copy<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.infer_ctxt(self.clone(), Reveal::UserFacing).enter(|infcx| {
let (adt, substs) = match self_type.sty {
ty::TyAdt(adt, substs) => (adt, substs),
_ => return Err(CopyImplementationError::NotAnAdt)
_ => return Err(CopyImplementationError::NotAnAdt),
};
let field_implements_copy = |field: &ty::FieldDef| {
let cause = traits::ObligationCause::dummy();
match traits::fully_normalize(&infcx, cause, &field.ty(tcx, substs)) {
Ok(ty) => !infcx.type_moves_by_default(ty, span),
Err(..) => false
Err(..) => false,
}
};
@@ -198,7 +198,7 @@ pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
}
}
}
_ => ()
_ => (),
}
false
}
@@ -218,7 +218,7 @@ pub fn positional_element_ty(self,
adt.variants[0].fields.get(i).map(|f| f.ty(self, substs))
}
(&TyTuple(ref v, _), None) => v.get(i).cloned(),
_ => None
_ => None,
}
}
@@ -245,11 +245,11 @@ pub fn named_element_ty(self,
pub fn struct_tail(self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
while let TyAdt(def, substs) = ty.sty {
if !def.is_struct() {
break
break;
}
match def.struct_variant().fields.last() {
Some(f) => ty = f.ty(self, substs),
None => break
None => break,
}
}
ty
@@ -267,14 +267,14 @@ pub fn struct_lockstep_tails(self,
let (mut a, mut b) = (source, target);
while let (&TyAdt(a_def, a_substs), &TyAdt(b_def, b_substs)) = (&a.sty, &b.sty) {
if a_def != b_def || !a_def.is_struct() {
break
break;
}
match a_def.struct_variant().fields.last() {
Some(f) => {
a = f.ty(self, a_substs);
b = f.ty(self, b_substs);
}
_ => break
_ => break,
}
}
(a, b)
@@ -373,7 +373,7 @@ pub fn calculate_dtor(
let dtor_did = match dtor_did {
Some(dtor) => dtor,
None => return None
None => return None,
};
// RFC 1238: if the destructor method is tagged with the
@@ -725,9 +725,7 @@ fn same_type<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
substs_a.types().zip(substs_b.types()).all(|(a, b)| same_type(a, b))
}
_ => {
a == b
}
_ => a == b,
}
}
+4 -3
View File
@@ -94,7 +94,7 @@ pub fn to_readable_str(mut val: usize) -> String {
if val == 0 {
groups.push(format!("{}", group));
break
break;
} else {
groups.push(format!("{:03}", group));
}
@@ -142,7 +142,8 @@ fn get_resident() -> Option<usize> {
type HANDLE = *mut u8;
use libc::size_t;
use std::mem;
#[repr(C)] #[allow(non_snake_case)]
#[repr(C)]
#[allow(non_snake_case)]
struct PROCESS_MEMORY_COUNTERS {
cb: DWORD,
PageFaultCount: DWORD,
@@ -184,7 +185,7 @@ pub fn indent<R, F>(op: F) -> R where
}
pub struct Indenter {
_cannot_construct_outside_of_this_module: ()
_cannot_construct_outside_of_this_module: (),
}
impl Drop for Indenter {
+1 -1
View File
@@ -116,7 +116,7 @@ pub fn create_dir_racy(path: &Path) -> io::Result<()> {
match fs::create_dir(path) {
Ok(()) => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
Err(ref e) if e.kind() == io::ErrorKind::NotFound => (),
Err(e) => return Err(e),
}
match path.parent() {