lang: Change context error span and add constraint docs (#342)
This commit is contained in:
parent
6b5ed789fc
commit
2f5a9fcc7d
|
@ -43,7 +43,8 @@ use syn::parse_macro_input;
|
||||||
/// | `#[account(belongs_to = <target>)]` | On `ProgramAccount` or `CpiAccount` structs | Checks the `target` field on the account matches the `target` field in the struct deriving `Accounts`. |
|
/// | `#[account(belongs_to = <target>)]` | On `ProgramAccount` or `CpiAccount` structs | Checks the `target` field on the account matches the `target` field in the struct deriving `Accounts`. |
|
||||||
/// | `#[account(has_one = <target>)]` | On `ProgramAccount` or `CpiAccount` structs | Semantically different, but otherwise the same as `belongs_to`. |
|
/// | `#[account(has_one = <target>)]` | On `ProgramAccount` or `CpiAccount` structs | Semantically different, but otherwise the same as `belongs_to`. |
|
||||||
/// | `#[account(seeds = [<seeds>])]` | On `AccountInfo` structs | Seeds for the program derived address an `AccountInfo` struct represents. |
|
/// | `#[account(seeds = [<seeds>])]` | On `AccountInfo` structs | Seeds for the program derived address an `AccountInfo` struct represents. |
|
||||||
/// | `#[account("<literal>")]` | On any type deriving `Accounts` | Executes the given code literal as a constraint. The literal should evaluate to a boolean. |
|
/// | `#[account(constraint = <expression>)]` | On any type deriving `Accounts` | Executes the given code as a constraint. The expression should evaluate to a boolean. |
|
||||||
|
/// | `#[account("<literal>")]` | Deprecated | Executes the given code literal as a constraint. The literal should evaluate to a boolean. |
|
||||||
/// | `#[account(rent_exempt = <skip>)]` | On `AccountInfo` or `ProgramAccount` structs | Optional attribute to skip the rent exemption check. By default, all accounts marked with `#[account(init)]` will be rent exempt, and so this should rarely (if ever) be used. Similarly, omitting `= skip` will mark the account rent exempt. |
|
/// | `#[account(rent_exempt = <skip>)]` | On `AccountInfo` or `ProgramAccount` structs | Optional attribute to skip the rent exemption check. By default, all accounts marked with `#[account(init)]` will be rent exempt, and so this should rarely (if ever) be used. Similarly, omitting `= skip` will mark the account rent exempt. |
|
||||||
/// | `#[account(executable)]` | On `AccountInfo` structs | Checks the given account is an executable program. |
|
/// | `#[account(executable)]` | On `AccountInfo` structs | Checks the given account is an executable program. |
|
||||||
/// | `#[account(state = <target>)]` | On `CpiState` structs | Checks the given state is the canonical state account for the target program. |
|
/// | `#[account(state = <target>)]` | On `CpiState` structs | Checks the given state is the canonical state account for the target program. |
|
||||||
|
|
|
@ -29,12 +29,7 @@ fn ctx_accounts_ident(path_ty: &syn::PatType) -> ParseResult<proc_macro2::Ident>
|
||||||
|
|
||||||
let generic_args = match &segment.arguments {
|
let generic_args = match &segment.arguments {
|
||||||
syn::PathArguments::AngleBracketed(args) => args,
|
syn::PathArguments::AngleBracketed(args) => args,
|
||||||
_ => {
|
_ => return Err(ParseError::new(path_ty.span(), "missing accounts context")),
|
||||||
return Err(ParseError::new(
|
|
||||||
segment.arguments.span(),
|
|
||||||
"expected generic arguments here",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let generic_ty = generic_args
|
let generic_ty = generic_args
|
||||||
.args
|
.args
|
||||||
|
|
Loading…
Reference in New Issue