diff --git a/.idea/dictionaries/intellij_rust.xml b/.idea/dictionaries/intellij_rust.xml
index cbcbeaad45a..73f5cd6346e 100644
--- a/.idea/dictionaries/intellij_rust.xml
+++ b/.idea/dictionaries/intellij_rust.xml
@@ -82,6 +82,7 @@
simd
staticlib
stmts
+ straightline
subcommand
subcommands
submatrix
@@ -97,6 +98,7 @@
turbofish
uncached
unescape
+ unexecuted
unsafety
valobj
wasm
diff --git a/src/main/kotlin/org/rust/lang/core/dfa/ControlFlowGraph.kt b/src/main/kotlin/org/rust/lang/core/dfa/ControlFlowGraph.kt
index 1e9418e3edd..37e830efec6 100644
--- a/src/main/kotlin/org/rust/lang/core/dfa/ControlFlowGraph.kt
+++ b/src/main/kotlin/org/rust/lang/core/dfa/ControlFlowGraph.kt
@@ -40,7 +40,7 @@ sealed class CFGNodeData(val element: RsElement? = null) : PresentableNodeData {
override val text: String
get() = when (this) {
- is AST -> element?.cfgText()?.trim() ?: "AST"
+ is AST -> element!!.cfgText().trim()
Entry -> "Entry"
Exit -> "Exit"
Termination -> "Termination"
@@ -56,6 +56,7 @@ sealed class CFGNodeData(val element: RsElement? = null) : PresentableNodeData {
is RsLoopExpr -> "LOOP"
is RsForExpr -> "FOR"
is RsMatchExpr -> "MATCH"
+ is RsLambdaExpr -> "CLOSURE"
is RsExprStmt -> expr.cfgText() + ";"
else -> this.text
}
@@ -64,10 +65,11 @@ sealed class CFGNodeData(val element: RsElement? = null) : PresentableNodeData {
class CFGEdgeData(val exitingScopes: List)
typealias CFGNode = Node
+typealias CFGGraph = PresentableGraph
class ControlFlowGraph private constructor(
val owner: RsElement,
- val graph: PresentableGraph,
+ val graph: CFGGraph,
val body: RsBlock,
val regionScopeTree: ScopeTree,
val entry: CFGNode,
@@ -97,7 +99,7 @@ class ControlFlowGraph private constructor(
*
* Only collects [RsExprStmt]s, [RsLetDecl]s and tail expressions, ignoring conditionally disabled.
*/
- private fun collectUnreachableElements(graph: PresentableGraph, entry: CFGNode): Set {
+ private fun collectUnreachableElements(graph: CFGGraph, entry: CFGNode): Set {
/**
* In terms of our control-flow graph, a [RsElement]'s node is not reachable if it cannot be fully executed,
* since [CFGBuilder] processes elements in post-order.
diff --git a/src/test/kotlin/org/rust/lang/core/dfa/RsControlFlowGraphTest.kt b/src/test/kotlin/org/rust/lang/core/dfa/RsControlFlowGraphTest.kt
index 9b870f1efb8..3256fa864b4 100644
--- a/src/test/kotlin/org/rust/lang/core/dfa/RsControlFlowGraphTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/dfa/RsControlFlowGraphTest.kt
@@ -867,7 +867,7 @@ class RsControlFlowGraphTest : RsTestBase() {
x + 1
BLOCK
BLOCK
- |x: i32| { x + 1 }
+ CLOSURE
f
f
let f = |x: i32| { x + 1 };
@@ -950,7 +950,7 @@ class RsControlFlowGraphTest : RsTestBase() {
Entry
panic!()
Termination
- || { panic!() }
+ CLOSURE
f
f
let f = || { panic!() };
@@ -1072,6 +1072,6 @@ class RsControlFlowGraphTest : RsTestBase() {
val cfg = ControlFlowGraph.buildFor(function.block!!, getRegionScopeTree(function))
val expected = expectedIndented.trimIndent()
val actual = cfg.graph.depthFirstTraversalTrace(cfg.entry)
- check(actual == expected) { throw ComparisonFailure("Comparision failed", expected, actual) }
+ check(actual == expected) { throw ComparisonFailure("Comparison failed", expected, actual) }
}
}