idl: Remove anchor-syn
dependency
#3030
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The new IDL crate depends on
anchor-syn
(behindbuild
feature flag), only to check the safety comments. Ideally, the IDL crate shouldn't depend on any of the other Anchor crates and be a stand-alone crate (as it's versioning is also different).Summary of changes
Handle the safety comment checks inside the
#[program]
macro'sidl-build
implementation. This should work fine since we pass the program path as an env variable (#2946), and we can use that to run the logic with theidl-build
feature. However, there is one downside: we lose the span information:Before:
After:
The line and column info is set to
0
when we parse the crate inside a proc macro. Not exactly sure why this happens, but I don't think it's that big of a deal since the file name and the account name is still correct. Not planning to change the span info in this PR as it's harmless, and maybe we can make it work in the future?