-
Notifications
You must be signed in to change notification settings - Fork 1.6k
extend clippy_utils::path_to_local()
to handle Cast expressions
#14378
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
Comments
I am not sure I understand what you are requesting. Would you want to pass the Can you explain why you would need to do this? I wonder if we are in presence of a XY problem here. |
Apologies for the miscommunication or confusion, but yes that is what i seek to achieve, perhaps in my is_referencing_same_variable function here, i have some boilerplate code handling casted types, and looking the implementation of example implementation below: fn some_new_utility_function_name(expr: &Expr<'_>){
if let ExprKind::Cast(path, _) = &expr1.kind {
return path_to_local(path)
}
None
} i am assuming a new function here because i understand your point about passing an expression that is not a path to does this make any sense? |
I wonder if you're not looking for But I am not sure you need to detect casts to implement the |
Yes, |
Description
clippy_utils::path_to_local()
currently accepts a Path expression and returns the canonical HirId of the local, example below:The Path expression for the variable
x
inside the Let statement will resolve correctly, however the variableb
in the example below returnsNone
when passed to the function, because thePath
expression is wrapped inside aCast
expression.Version
The text was updated successfully, but these errors were encountered: