-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
let hir = tcx.hir();
if let Some(body_id) = tcx.hir_node_by_def_id(def_id).body_id() {
tcx.arena.alloc_from_iter(hir.body_param_names(body_id))
} else if let Node::TraitItem(&TraitItem {
kind: TraitItemKind::Fn(_, TraitFn::Required(idents)),
..
})
| Node::ForeignItem(&ForeignItem {
kind: ForeignItemKind::Fn(_, idents, _),
..
}) = tcx.hir_node(tcx.local_def_id_to_hir_id(def_id))
{
idents
} else {
span_bug!(
hir.span(tcx.local_def_id_to_hir_id(def_id)),
"fn_arg_names: unexpected item {:?}",
def_id
);
}The indentation on this else if let is very confusing as it looks like the if else ends because we are at "normal" indentation for statements in the body, which makes it look like someone has written an assignment with a pattern with a leading | which is then somehow followed up by a block with an else on the end of it (?)
Something like the following would be significantly clearer as the indentation signifies that this is inside of the else condition:
let hir = tcx.hir();
if let Some(body_id) = tcx.hir_node_by_def_id(def_id).body_id() {
tcx.arena.alloc_from_iter(hir.body_param_names(body_id))
} else if let Node::TraitItem(&TraitItem {
kind: TraitItemKind::Fn(_, TraitFn::Required(idents)),
..
})
| Node::ForeignItem(&ForeignItem {
kind: ForeignItemKind::Fn(_, idents, _),
..
}) = tcx.hir_node(tcx.local_def_id_to_hir_id(def_id))
{
idents
} else {
span_bug!(
hir.span(tcx.local_def_id_to_hir_id(def_id)),
"fn_arg_names: unexpected item {:?}",
def_id
);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.