-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Implement enclosing callable #17921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
af5561c
to
75e055c
Compare
75e055c
to
dadc605
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
/** Gets the underlying source code call, if any. */ | ||
abstract CallCfgNode asCall(); | ||
|
||
abstract string toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add QL doc: Gets a textual representation of this call.
RustDataFlow::ReturnKind getKind() { none() } | ||
/** A data flow node that represents a value returned by a callable. */ | ||
final class ReturnNode extends ExprNode { | ||
ReturnNode() { this.getCfgNode().getASuccessor() instanceof ExitCfgNode } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should just be ReturnExpr
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so we don't want to include implicit returns like fn foo() { 12 }
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we need to include that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reinstated the old implementation again :). If we want to include implicit returns then I think just looking at edges into the exit node handles all cases.
return
goes directly to the exit node- In the absence of explicit returns, the
BlockExpr
is last both in a function and in a closure and it lets the final expression flow through if there is no;
at the end. - For a lambda without braces
|a| a + 1
the single expression has an edge to the exit node.
Fills out some more of the data flow implementation, including an implementation of
nodeGetEnclosingCallable
. This fixes a good deal of theuniqueEnclosingCallable
inconsistencies. There is only 7 left post this PR.