Skip to content

Commit 31f0ed1

Browse files
committed
Peel refs in contains_data_field_reference
1 parent 6005934 commit 31f0ed1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lints/type_cosplay/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ impl<'tcx> LateLintPass<'tcx> for TypeCosplay {
7373
if let ExprKind::Call(fnc_expr, args_exprs) = expr.kind;
7474
// TODO: recommended-2 case will exit early since it contains a reference to AccountInfo.data,
7575
// not a direct argument. In general, any references will fail
76+
// smoelius: I updated the `recommended-2` test so that the call contains a reference to
77+
// `AccountInfo.data`. But @victor-wei126's comment is still relevant in that we need a
78+
// more general solution for finding references to `AccountInfo.data`.
7679
if args_exprs.iter().any(|arg| {
7780
visit_expr_no_bodies(arg, |expr| contains_data_field_reference(cx, expr))
7881
});
@@ -158,7 +161,7 @@ fn contains_data_field_reference(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool
158161
if_chain! {
159162
if let ExprKind::Field(obj_expr, ident) = expr.kind;
160163
if ident.as_str() == "data";
161-
let ty = cx.typeck_results().expr_ty(obj_expr);
164+
let ty = cx.typeck_results().expr_ty(obj_expr).peel_refs();
162165
if match_type(cx, ty, &paths::SOLANA_PROGRAM_ACCOUNT_INFO);
163166
then {
164167
true

0 commit comments

Comments
 (0)