Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Rust] Get receiver type information#20005

Answeredbyhvitved
Fee0 asked this question inQ&A
Discussion options

I just saw the developer preview for Rust and wanted to try it out.

I'm trying to find all calls tolen() on aStringobject.

pubfnname_length(name:String) ->usize{    name.len()}

I expected it to work like this but there is no method for accessing the type information.
I saw other languages having thisgetType() function. Is Rust different here?

import rustfromMethodCallExprcallwherecall.getIdentifier().toString()="len"andcall.getReceiver().getType().toString()="String"selectcall

From looking at the AST it seems I could get theTypeRepr from the function argument by tracing it back via dataflow analysis.
But I'm thinking there must be an easier way?
I'm new to codeql.

You must be logged in to vote

Type information is currently not exposed in the public API, since we still haven't decided what that API should look like.

In the meantime, you can use the following:

fromMethodCallExprcallwherecall.getStaticTarget().getCanonicalPath()="<core::str>::len"selectcall

Replies: 1 comment

Comment options

Type information is currently not exposed in the public API, since we still haven't decided what that API should look like.

In the meantime, you can use the following:

fromMethodCallExprcallwherecall.getStaticTarget().getCanonicalPath()="<core::str>::len"selectcall
You must be logged in to vote
0 replies
Answer selected byFee0
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@Fee0@hvitved

[8]ページ先頭

©2009-2025 Movatter.jp