Skip to content
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

lang: Fix using data as an instruction parameter name in declare_program! #3574

Conversation

acheroncrypto
Copy link
Collaborator

Problem

Having an instruction parameter named data results in a compilation error when used with declare_program!

error[E0382]: borrow of moved value: `data`
 --> programs/declare-program/src/lib.rs:5:1
  |
5 | declare_program!(external);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
  | |
  | value borrowed here after move
  | move occurs because `data` has type `Vec<u8>`, which does not implement the `Copy` trait
  |
  = note: this error originates in the macro `declare_program` (in Nightly builds, run with -Z macro-backtrace for more info)

This happens because that identifier is being used internally here:

let mut data = Vec::with_capacity(256);

Summary of changes

  • Fix being unable to use data as an instruction parameter name in declare_program!
  • Add a compilation test

Fixes #3572

Copy link

vercel bot commented Feb 26, 2025

@acheroncrypto is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added lang fix Bug fix PR labels Feb 26, 2025
@acheroncrypto acheroncrypto merged commit dac533e into coral-xyz:master Feb 26, 2025
0 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix PR lang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

declare_program macro returns error: value borrowed here after move
1 participant