Skip to content

Commit f75c8a9

Browse files
committed
Add make tidy fixes
1 parent 23a8c7d commit f75c8a9

File tree

9 files changed

+54
-23
lines changed

9 files changed

+54
-23
lines changed

src/librustc/hir/map/blocks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ impl<'a> FnLikeNode<'a> {
184184
}
185185

186186
pub fn decl(self) -> &'a FnDecl {
187-
if let map::NodeInlinedItem(&InlinedItem { kind: InlinedItemKind::Fn(ref decl), .. }) = self.node {
187+
if let map::NodeInlinedItem(&InlinedItem {
188+
kind: InlinedItemKind::Fn(ref decl),
189+
..
190+
}) = self.node {
188191
return &decl;
189192
}
190193
self.handle(|i: ItemFnParts<'a>| &*i.decl,

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ impl<'ast> Map<'ast> {
601601
pub fn get_parent_did(&self, id: NodeId) -> DefId {
602602
let parent = self.get_parent(id);
603603
match self.find_entry(parent) {
604-
Some(RootInlinedParent(ii)) => ii.def_id, // TODO: is this wrong for items?
604+
Some(RootInlinedParent(ii)) => ii.def_id,
605605
_ => self.local_def_id(parent)
606606
}
607607
}

src/librustc/middle/cstore.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ pub enum InlinedItemKindRef<'a> {
165165
}
166166

167167
impl<'a> InlinedItemRef<'a> {
168-
pub fn from_item<'ast: 'a>(def_id: DefId, item: &'a hir::Item, map: &hir_map::Map<'ast>) -> InlinedItemRef<'a> {
168+
pub fn from_item<'ast: 'a>(def_id: DefId,
169+
item: &'a hir::Item,
170+
map: &hir_map::Map<'ast>)
171+
-> InlinedItemRef<'a> {
169172
let (body, kind) = match item.node {
170-
hir::ItemFn(ref decl, _, _, _, _, body_id) => (map.expr(body_id), InlinedItemKindRef::Fn(&decl)),
173+
hir::ItemFn(ref decl, _, _, _, _, body_id) =>
174+
(map.expr(body_id), InlinedItemKindRef::Fn(&decl)),
171175
hir::ItemConst(ref ty, ref body) => (&**body, InlinedItemKindRef::Const(ty)),
172176
_ => bug!("InlinedItemRef::from_item wrong kind")
173177
};
@@ -178,10 +182,15 @@ impl<'a> InlinedItemRef<'a> {
178182
}
179183
}
180184

181-
pub fn from_trait_item(def_id: DefId, item: &'a hir::TraitItem, _map: &hir_map::Map) -> InlinedItemRef<'a> {
185+
pub fn from_trait_item(def_id: DefId,
186+
item: &'a hir::TraitItem,
187+
_map: &hir_map::Map)
188+
-> InlinedItemRef<'a> {
182189
let (body, kind) = match item.node {
183190
hir::ConstTraitItem(ref ty, Some(ref body)) => (&**body, InlinedItemKindRef::Const(ty)),
184-
hir::ConstTraitItem(_, None) => bug!("InlinedItemRef::from_trait_item called for const without body"),
191+
hir::ConstTraitItem(_, None) => {
192+
bug!("InlinedItemRef::from_trait_item called for const without body")
193+
},
185194
_ => bug!("InlinedItemRef::from_trait_item wrong kind")
186195
};
187196
InlinedItemRef {
@@ -191,9 +200,13 @@ impl<'a> InlinedItemRef<'a> {
191200
}
192201
}
193202

194-
pub fn from_impl_item<'ast: 'a>(def_id: DefId, item: &'a hir::ImplItem, map: &hir_map::Map<'ast>) -> InlinedItemRef<'a> {
203+
pub fn from_impl_item<'ast: 'a>(def_id: DefId,
204+
item: &'a hir::ImplItem,
205+
map: &hir_map::Map<'ast>)
206+
-> InlinedItemRef<'a> {
195207
let (body, kind) = match item.node {
196-
hir::ImplItemKind::Method(ref sig, body_id) => (map.expr(body_id), InlinedItemKindRef::Fn(&sig.decl)),
208+
hir::ImplItemKind::Method(ref sig, body_id) =>
209+
(map.expr(body_id), InlinedItemKindRef::Fn(&sig.decl)),
197210
hir::ImplItemKind::Const(ref ty, ref body) => (&**body, InlinedItemKindRef::Const(ty)),
198211
_ => bug!("InlinedItemRef::from_impl_item wrong kind")
199212
};

src/librustc/middle/region.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,8 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx, 'a>, expr:
850850
visitor.cx = prev_cx;
851851
}
852852

853-
fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx, 'a>, local: &'tcx hir::Local) {
853+
fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx, 'a>,
854+
local: &'tcx hir::Local) {
854855
debug!("resolve_local(local.id={:?},local.init={:?})",
855856
local.id,local.init.is_some());
856857

src/librustc_const_eval/eval.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
109109
// or the default.
110110
let trait_id = tcx.map.get_parent(node_id);
111111
let trait_id = tcx.map.local_def_id(trait_id);
112-
let default_value = expr_option.as_ref().map(|expr| (&**expr, tcx.ast_ty_to_prim_ty(ty)));
112+
let default_value = expr_option.as_ref()
113+
.map(|expr| (&**expr, tcx.ast_ty_to_prim_ty(ty)));
113114
resolve_trait_associated_const(tcx, def_id, default_value, trait_id, substs)
114115
} else {
115116
// Technically, without knowing anything about the
@@ -141,7 +142,8 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
141142
}
142143
let mut used_substs = false;
143144
let expr_ty = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) {
144-
Some((&InlinedItem { body: ref const_expr, kind: InlinedItemKind::Const(ref ty), .. }, _)) => {
145+
Some((&InlinedItem { body: ref const_expr,
146+
kind: InlinedItemKind::Const(ref ty), .. }, _)) => {
145147
Some((&**const_expr, tcx.ast_ty_to_prim_ty(ty)))
146148
}
147149
_ => None
@@ -1057,12 +1059,13 @@ fn infer<'a, 'tcx>(i: ConstInt,
10571059
}
10581060
}
10591061

1060-
fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1061-
trait_item_id: DefId,
1062-
default_value: Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>,
1063-
trait_id: DefId,
1064-
rcvr_substs: &'tcx Substs<'tcx>)
1065-
-> Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>
1062+
fn resolve_trait_associated_const<'a, 'tcx: 'a>(
1063+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
1064+
trait_item_id: DefId,
1065+
default_value: Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>,
1066+
trait_id: DefId,
1067+
rcvr_substs: &'tcx Substs<'tcx>
1068+
) -> Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>
10661069
{
10671070
let trait_ref = ty::Binder(ty::TraitRef::new(trait_id, rcvr_substs));
10681071
debug!("resolve_trait_associated_const: trait_ref={:?}",

src/librustc_incremental/calculate_svh/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
153153
self.calculate_def_hash(DepNode::HirBody(def_id), true, &mut walk_op);
154154
}
155155

156-
fn calculate_def_hash<W>(&mut self, dep_node: DepNode<DefId>, hash_bodies: bool, walk_op: &mut W)
156+
fn calculate_def_hash<W>(&mut self,
157+
dep_node: DepNode<DefId>,
158+
hash_bodies: bool,
159+
walk_op: &mut W)
157160
where W: for<'v> FnMut(&mut StrictVersionHashVisitor<'v, 'a, 'tcx>)
158161
{
159162
let mut state = IchHasher::new();

src/librustc_metadata/encoder.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
520520
// We only save the HIR for associated consts with bodies
521521
// (InlinedItemRef::from_trait_item panics otherwise)
522522
let trait_def_id = trait_item.container.id();
523-
Some(self.encode_inlined_item(InlinedItemRef::from_trait_item(trait_def_id, ast_item, &tcx.map)))
523+
Some(self.encode_inlined_item(
524+
InlinedItemRef::from_trait_item(trait_def_id, ast_item, &tcx.map)
525+
))
524526
} else {
525527
None
526528
},
@@ -591,7 +593,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
591593
predicates: Some(self.encode_predicates(def_id)),
592594

593595
ast: if ast {
594-
Some(self.encode_inlined_item(InlinedItemRef::from_impl_item(impl_def_id, ast_item, &tcx.map)))
596+
Some(self.encode_inlined_item(
597+
InlinedItemRef::from_impl_item(impl_def_id, ast_item, &tcx.map)
598+
))
595599
} else {
596600
None
597601
},
@@ -821,7 +825,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
821825
ast: match item.node {
822826
hir::ItemConst(..) |
823827
hir::ItemFn(_, _, hir::Constness::Const, ..) => {
824-
Some(self.encode_inlined_item(InlinedItemRef::from_item(def_id, item, &tcx.map)))
828+
Some(self.encode_inlined_item(
829+
InlinedItemRef::from_item(def_id, item, &tcx.map)
830+
))
825831
}
826832
_ => None,
827833
},

src/librustc_passes/consts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
181181
/// Returns true if the call is to a const fn or method.
182182
fn handle_const_fn_call(&mut self, _expr: &hir::Expr, def_id: DefId, ret_ty: Ty<'gcx>) -> bool {
183183
if let Some(fn_like) = lookup_const_fn_by_id(self.tcx, def_id) {
184-
let qualif = match self.tcx.const_qualif_map.borrow_mut().entry(fn_like.body().node_id()) {
184+
let node_id = fn_like.body().node_id();
185+
let qualif = match self.tcx.const_qualif_map.borrow_mut().entry(node_id) {
185186
Entry::Occupied(entry) => Some(*entry.get()),
186187
_ => None
187188
};

src/librustc_typeck/check/regionck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
143143
decl: &hir::FnDecl,
144144
body_id: hir::ExprId) {
145145
debug!("regionck_fn(id={})", fn_id);
146-
let mut rcx = RegionCtxt::new(self, RepeatingScope(body_id.node_id()), body_id.node_id(), Subject(fn_id));
146+
let node_id = body_id.node_id();
147+
let mut rcx = RegionCtxt::new(self, RepeatingScope(node_id), node_id, Subject(fn_id));
147148

148149
if self.err_count_since_creation() == 0 {
149150
// regionck assumes typeck succeeded

0 commit comments

Comments
 (0)