lang: Allow seeds to have a trailing comma (#777)

This commit is contained in:
Alan O'Donnell 2021-09-22 07:42:39 -07:00 committed by GitHub
parent 22ef0aec42
commit 42ed126163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -281,7 +281,12 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
let seeds_with_nonce = match &c.seeds { let seeds_with_nonce = match &c.seeds {
None => quote! {}, None => quote! {},
Some(c) => { Some(c) => {
let s = &c.seeds; let s = &mut c.seeds.clone();
// If the seeds came with a trailing comma, we need to chop it off
// before we interpolate them below.
if let Some(pair) = s.pop() {
s.push_value(pair.into_value());
}
let inner = match c.bump.as_ref() { let inner = match c.bump.as_ref() {
// Bump target not given. Use the canonical bump. // Bump target not given. Use the canonical bump.
None => { None => {

View File

@ -18,7 +18,7 @@ pub struct TestTokenSeedsInit<'info> {
pub mint: Account<'info, Mint>, pub mint: Account<'info, Mint>,
#[account( #[account(
init, init,
seeds = [b"my-token-seed".as_ref()], seeds = [b"my-token-seed".as_ref(),],
bump = token_bump, bump = token_bump,
payer = authority, payer = authority,
token::mint = mint, token::mint = mint,