Skip to content

lang: Shorten invariant lifetimes during Context creation#4363

Draft
acheroncrypto wants to merge 3 commits into
otter-sec:masterfrom
acheroncrypto:lang-shorten-invariant-lifetimes-during-context-creation
Draft

lang: Shorten invariant lifetimes during Context creation#4363
acheroncrypto wants to merge 3 commits into
otter-sec:masterfrom
acheroncrypto:lang-shorten-invariant-lifetimes-during-context-creation

Conversation

@acheroncrypto
Copy link
Copy Markdown
Collaborator

Problem

As mentioned in #3340 (comment), the helper function __shrink_lifetime actually extends the mutable borrow lifetime instead of shrinking the inner lifetime:

https://github.com/solana-foundation/anchor/blob/62865c636aecc6974fc9cfebfc6cf08ca4f0bb72/lang/syn/src/codegen/program/handlers.rs#L130-L132

This is not the desired behavior, and it also conflicts with its safety comments:

https://github.com/solana-foundation/anchor/blob/62865c636aecc6974fc9cfebfc6cf08ca4f0bb72/lang/syn/src/codegen/program/handlers.rs#L138-L142

Summary of changes

Shorten invariant lifetimes rather than extending the mutable borrow lifetime during Context creation.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 29, 2026

@acheroncrypto is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added lang fix Bug fix PR labels Mar 29, 2026
@jamie-osec
Copy link
Copy Markdown
Collaborator

Just bumping on this, are you able to fix the compile errors?

@acheroncrypto
Copy link
Copy Markdown
Collaborator Author

There seems to be only one compile error coming from that cursed generics accounts struct. It should be fixable. I'll take a look later this week.

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.

2 participants