Skip to content

Commit 31362ac

Browse files
committed
Rust: Remove references to deleted IDs in downgrade script
1 parent 34b3ec4 commit 31362ac

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎rust/downgrades/9487e73d9da6508522f07a34bc4aafa8d55c0f5f/downgrade.ql‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,24 @@ class Location extends @location_default {
77
}
88

99
// `CfgPredExpr` and `CfgPredPat` are new node kinds with no representation in the old schema, so we
10-
// scrub their locations.
10+
// scrub their locations and references to them.
11+
private predicate deletedNode(Element id) { cfg_pred_exprs(id) or cfg_pred_pats(id) }
12+
13+
// Comments attached to deleted nodes are also removed, along with their locations.
14+
private predicate deletedElement(Element id) {
15+
deletedNode(id)
16+
or
17+
exists(Element parent | comments(id, parent, _) and deletedNode(parent))
18+
}
19+
1120
query predicate new_locatable_locations(Element id, Location location) {
12-
locatable_locations(id, location) and not cfg_pred_exprs(id) and not cfg_pred_pats(id)
21+
locatable_locations(id, location) and not deletedElement(id)
22+
}
23+
24+
query predicate new_macro_call_macro_call_expansions(Element macroCall, Element expansion) {
25+
macro_call_macro_call_expansions(macroCall, expansion) and not deletedNode(expansion)
26+
}
27+
28+
query predicate new_comments(Element id, Element parent, string text) {
29+
comments(id, parent, text) and not deletedNode(parent)
1330
}

‎rust/downgrades/9487e73d9da6508522f07a34bc4aafa8d55c0f5f/upgrade.properties‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ cfg_pred_expr_cfg_predicates.rel: delete
66
cfg_pred_pats.rel: delete
77
cfg_pred_pat_cfg_predicates.rel: delete
88
locatable_locations.rel: run downgrade.ql new_locatable_locations
9+
macro_call_macro_call_expansions.rel: run downgrade.ql new_macro_call_macro_call_expansions
10+
comments.rel: run downgrade.ql new_comments

0 commit comments

Comments
 (0)