Skip to content

Commit dd1a2d6

Browse files
fix: Don't panic if a borrow-checker error in the graph is caused by a mutable reference
1 parent 54cf661 commit dd1a2d6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/move_while_borrowed.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ fn emit_ancestor_descendant_borrow_error(
349349
while let Some(node_id) = nodes_to_visit.pop_front() {
350350
let mut incoming_edges = call_graph.edges_directed(node_id, Direction::Incoming);
351351
if incoming_edges.clone().any(|edge_ref| {
352-
edge_ref.weight() == &CallGraphEdgeMetadata::SharedBorrow
353-
&& edge_ref.source().id() == contended_node_id
352+
edge_ref.weight().is_borrow() && edge_ref.source().id() == contended_node_id
354353
}) {
355354
downstream_borrow_node_id = Some(node_id);
356355
break;

compiler/pavexc/src/compiler/analyses/call_graph/core_graph.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,15 @@ pub(crate) enum CallGraphEdgeMetadata {
781781
HappensBefore,
782782
}
783783

784+
impl CallGraphEdgeMetadata {
785+
pub(crate) fn is_borrow(&self) -> bool {
786+
matches!(
787+
self,
788+
CallGraphEdgeMetadata::SharedBorrow | CallGraphEdgeMetadata::ExclusiveBorrow
789+
)
790+
}
791+
}
792+
784793
impl From<ConsumptionMode> for CallGraphEdgeMetadata {
785794
fn from(value: ConsumptionMode) -> Self {
786795
match value {

0 commit comments

Comments
 (0)