Exclude generated code

This commit is contained in:
Daniel Wagner-Hall
2018-06-17 22:58:08 +01:00
parent d3124731b7
commit b24d75313e
4 changed files with 113 additions and 15 deletions

View File

@@ -1128,3 +1128,17 @@ pub fn without_block_comments(lines: Vec<&str>) -> Vec<&str> {
without
}
pub fn any_parent_is_automatically_derived(tcx: TyCtxt, node: NodeId) -> bool {
let map = &tcx.hir;
let mut prev_enclosing_node = None;
let mut enclosing_node = node;
while Some(enclosing_node) != prev_enclosing_node {
if is_automatically_derived(map.attrs(enclosing_node)) {
return true;
}
prev_enclosing_node = Some(enclosing_node);
enclosing_node = map.get_parent(enclosing_node);
}
false
}