Near-One / near-plugins

Implementation of common patterns used for NEAR smart contracts.
Creative Commons Zero v1.0 Universal
27 stars 12 forks source link

Comments on AccessControlRole enum variants not working #28

Closed mfornet closed 1 year ago

mfornet commented 1 year ago

Currently, adding a comment to a variant on an enum decorated with AccessControlRole fails. Docs line should be ignored and left in place in case documentation is built from the code.

Example:

#[derive(AccessControlRole, Deserialize, Serialize, Copy, Clone)]
#[serde(crate = "near_sdk::serde")]
pub enum AclRole {
    /// Allows user to update the token binary that will be deployed for new tokens.
    TokenBinaryUpdater,
    /// Allows user to update the account id that will be used for new deployed tokens.
    TokenControllerUpdater,
}

Error:

error: expected identifier, found `#`
  --> near-token-factory/src/lib.rs:34:5
   |
34 |     /// Allows user to update the token binary that will be deployed for new tokens.
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier

error: expected identifier, found `#`
  --> near-token-factory/src/lib.rs:36:5
   |
36 |     /// Allows user to update the account id that will be used for new deployed tokens.
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier

error: proc-macro derive produced unparseable tokens
  --> near-token-factory/src/lib.rs:31:10
   |
31 | #[derive(AccessControlRole, Deserialize, Serialize, Copy, Clone)]
   |          ^^^^^^^^^^^^^^^^^

error: could not compile `near-token-factory` due to 3 previous errors
mooori commented 1 year ago

Docs line should be ignored and left in place in case documentation is built from the code.

Comments will be ignored when the fix is merged. I assume they are left in place and included in documentation since derive macros may only append but not modify the input tokens.