Skip to content

Commit c7d6981

Browse files
committed
Add make tidy fixes
1 parent 04b7b97 commit c7d6981

File tree

10 files changed

+58
-24
lines changed

10 files changed

+58
-24
lines changed

src/librustc/hir/lowering.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ impl<'a> LoweringContext<'a> {
124124
}
125125
}
126126

127-
fn lower_items(&mut self, c: &Crate) -> (BTreeMap<NodeId, hir::Item>, BTreeMap<hir::ImplItemId, hir::ImplItem>) {
127+
fn lower_items(&mut self,
128+
c: &Crate)
129+
-> (BTreeMap<NodeId, hir::Item>,
130+
BTreeMap<hir::ImplItemId, hir::ImplItem>) {
128131
struct ItemLowerer<'lcx, 'interner: 'lcx> {
129132
items: BTreeMap<NodeId, hir::Item>,
130133
impl_items: BTreeMap<hir::ImplItemId, hir::ImplItem>,

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
@@ -589,7 +589,7 @@ impl<'ast> Map<'ast> {
589589
pub fn get_parent_did(&self, id: NodeId) -> DefId {
590590
let parent = self.get_parent(id);
591591
match self.find_entry(parent) {
592-
Some(RootInlinedParent(ii)) => ii.def_id, // TODO: is this wrong for items?
592+
Some(RootInlinedParent(ii)) => ii.def_id,
593593
_ => self.local_def_id(parent)
594594
}
595595
}

src/librustc/middle/cstore.rs

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

130130
impl<'a> InlinedItemRef<'a> {
131-
pub fn from_item<'ast: 'a>(def_id: DefId, item: &'a hir::Item, map: &hir_map::Map<'ast>) -> InlinedItemRef<'a> {
131+
pub fn from_item<'ast: 'a>(def_id: DefId,
132+
item: &'a hir::Item,
133+
map: &hir_map::Map<'ast>)
134+
-> InlinedItemRef<'a> {
132135
let (body, kind) = match item.node {
133-
hir::ItemFn(ref decl, _, _, _, _, body_id) => (map.expr(body_id), InlinedItemKindRef::Fn(&decl)),
136+
hir::ItemFn(ref decl, _, _, _, _, body_id) =>
137+
(map.expr(body_id), InlinedItemKindRef::Fn(&decl)),
134138
hir::ItemConst(ref ty, ref body) => (&**body, InlinedItemKindRef::Const(ty)),
135139
_ => bug!("InlinedItemRef::from_item wrong kind")
136140
};
@@ -141,10 +145,15 @@ impl<'a> InlinedItemRef<'a> {
141145
}
142146
}
143147

144-
pub fn from_trait_item(def_id: DefId, item: &'a hir::TraitItem, _map: &hir_map::Map) -> InlinedItemRef<'a> {
148+
pub fn from_trait_item(def_id: DefId,
149+
item: &'a hir::TraitItem,
150+
_map: &hir_map::Map)
151+
-> InlinedItemRef<'a> {
145152
let (body, kind) = match item.node {
146153
hir::ConstTraitItem(ref ty, Some(ref body)) => (&**body, InlinedItemKindRef::Const(ty)),
147-
hir::ConstTraitItem(_, None) => bug!("InlinedItemRef::from_trait_item called for const without body"),
154+
hir::ConstTraitItem(_, None) => {
155+
bug!("InlinedItemRef::from_trait_item called for const without body")
156+
},
148157
_ => bug!("InlinedItemRef::from_trait_item wrong kind")
149158
};
150159
InlinedItemRef {
@@ -154,9 +163,13 @@ impl<'a> InlinedItemRef<'a> {
154163
}
155164
}
156165

157-
pub fn from_impl_item<'ast: 'a>(def_id: DefId, item: &'a hir::ImplItem, map: &hir_map::Map<'ast>) -> InlinedItemRef<'a> {
166+
pub fn from_impl_item<'ast: 'a>(def_id: DefId,
167+
item: &'a hir::ImplItem,
168+
map: &hir_map::Map<'ast>)
169+
-> InlinedItemRef<'a> {
158170
let (body, kind) = match item.node {
159-
hir::ImplItemKind::Method(ref sig, body_id) => (map.expr(body_id), InlinedItemKindRef::Fn(&sig.decl)),
171+
hir::ImplItemKind::Method(ref sig, body_id) =>
172+
(map.expr(body_id), InlinedItemKindRef::Fn(&sig.decl)),
160173
hir::ImplItemKind::Const(ref ty, ref body) => (&**body, InlinedItemKindRef::Const(ty)),
161174
_ => bug!("InlinedItemRef::from_impl_item wrong kind")
162175
};

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
@@ -111,7 +111,8 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
111111
// or the default.
112112
let trait_id = tcx.map.get_parent(node_id);
113113
let trait_id = tcx.map.local_def_id(trait_id);
114-
let default_value = expr_option.as_ref().map(|expr| (&**expr, tcx.ast_ty_to_prim_ty(ty)));
114+
let default_value = expr_option.as_ref()
115+
.map(|expr| (&**expr, tcx.ast_ty_to_prim_ty(ty)));
115116
resolve_trait_associated_const(tcx, def_id, default_value, trait_id, substs)
116117
} else {
117118
// Technically, without knowing anything about the
@@ -143,7 +144,8 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
143144
}
144145
let mut used_substs = false;
145146
let expr_ty = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) {
146-
Some((&InlinedItem { body: ref const_expr, kind: InlinedItemKind::Const(ref ty), .. }, _)) => {
147+
Some((&InlinedItem { body: ref const_expr,
148+
kind: InlinedItemKind::Const(ref ty), .. }, _)) => {
147149
Some((&**const_expr, tcx.ast_ty_to_prim_ty(ty)))
148150
}
149151
_ => None
@@ -1044,12 +1046,13 @@ fn infer<'a, 'tcx>(i: ConstInt,
10441046
}
10451047
}
10461048

1047-
fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1048-
trait_item_id: DefId,
1049-
default_value: Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>,
1050-
trait_id: DefId,
1051-
rcvr_substs: &'tcx Substs<'tcx>)
1052-
-> Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>
1049+
fn resolve_trait_associated_const<'a, 'tcx: 'a>(
1050+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
1051+
trait_item_id: DefId,
1052+
default_value: Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>,
1053+
trait_id: DefId,
1054+
rcvr_substs: &'tcx Substs<'tcx>
1055+
) -> Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)>
10531056
{
10541057
let trait_ref = ty::Binder(ty::TraitRef::new(trait_id, rcvr_substs));
10551058
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
@@ -144,7 +144,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
144144
decl: &hir::FnDecl,
145145
body_id: hir::ExprId) {
146146
debug!("regionck_fn(id={})", fn_id);
147-
let mut rcx = RegionCtxt::new(self, RepeatingScope(body_id.node_id()), body_id.node_id(), Subject(fn_id));
147+
let node_id = body_id.node_id();
148+
let mut rcx = RegionCtxt::new(self, RepeatingScope(node_id), node_id, Subject(fn_id));
148149

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

0 commit comments

Comments
 (0)