Skip to content

Commit

Permalink
Revert "Move feature flag to anchor-lang crate"
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante committed Jul 1, 2021
1 parent 587ac55 commit 2e703d3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
4 changes: 3 additions & 1 deletion examples/lockup/programs/lockup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ name = "lockup"
[features]
no-entrypoint = []
cpi = ["no-entrypoint"]
anchor-deprecated-state = []
default = ["anchor-deprecated-state"]

[dependencies]
anchor-lang = { path = "../../../../lang", features = ["anchor-deprecated-state"] }
anchor-lang = { path = "../../../../lang" }
anchor-spl = { path = "../../../../spl" }
4 changes: 3 additions & 1 deletion examples/lockup/programs/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ name = "registry"
[features]
no-entrypoint = []
cpi = ["no-entrypoint"]
anchor-deprecated-state = []
default = ["anchor-deprecated-state"]

[dependencies]
anchor-lang = { path = "../../../../lang", features = ["anchor-deprecated-state"] }
anchor-lang = { path = "../../../../lang" }
anchor-spl = { path = "../../../../spl" }
lockup = { path = "../lockup", features = ["cpi"] }
11 changes: 0 additions & 11 deletions lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ anchor-debug = [
"anchor-attribute-state/anchor-debug",
"anchor-derive-accounts/anchor-debug"
]
#
# WARNING: This is dangerous to use. Do not use if you don't know
# what you're doing. This will introduce a semver incompatible
# change meant for programs deployed with Anchor v0.6.0 and below,
# but who want to use the latest version of Anchor.
#
# If you have multiple programs that all depend on each other, make
# sure they are all using this feature together. Otherwise, it probably
# won't do what you're expecting.
#
anchor-deprecated-state = ["anchor-attribute-state/anchor-deprecated-state"]

[dependencies]
anchor-attribute-access-control = { path = "./attribute/access-control", version = "0.10.0" }
Expand Down
1 change: 0 additions & 1 deletion lang/attribute/state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ proc-macro = true

[features]
anchor-debug = ["anchor-syn/anchor-debug"]
anchor-deprecated-state = []

[dependencies]
proc-macro2 = "1.0"
Expand Down
21 changes: 9 additions & 12 deletions lang/attribute/state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,15 @@ pub fn state(
}
};

let attribute = {
if cfg!(feature = "anchor-deprecated-state") {
match is_zero_copy {
false => quote! { #[account] },
true => quote! { #[account(zero_copy)] },
}
} else {
match is_zero_copy {
false => quote! { #[account("state")] },
true => quote! { #[account("state", zero_copy)] },
}
}
let attribute = match is_zero_copy {
false => quote! {
#[cfg_attr(feature = "anchor-deprecated-state", account)]
#[cfg_attr(not(feature = "anchor-deprecated-state"), account("state"))]
},
true => quote! {
#[cfg_attr(feature = "anchor-deprecated-state", account(zero_copy))]
#[cfg_attr(not(feature = "anchor-deprecated-state"), account("state", zero_copy))]
},
};

proc_macro::TokenStream::from(quote! {
Expand Down

0 comments on commit 2e703d3

Please sign in to comment.