Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems like sails_rs::program/service ignore attributes on methods #526

Open
gshep opened this issue Sep 13, 2024 · 0 comments
Open

Seems like sails_rs::program/service ignore attributes on methods #526

gshep opened this issue Sep 13, 2024 · 0 comments

Comments

@gshep
Copy link
Member

gshep commented Sep 13, 2024

Problem

While working on gas estimation for reply hook I faced the issue with attributes on service/program methods. Looks like the attributes are completely ignored.

Steps

  1. cargo-sails new-program test-attriute
#[derive(Clone, Debug, Decode, TypeInfo)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
struct Input {
    n: u32,
}

#[sails_rs::service]
impl TestAttributeService {
    pub fn new() -> Self {
        Self(())
    }

    // Service's method (command)
    #[allow(unused_mut)]
    pub fn do_something(&mut self, mut input: Input) -> String {
        input.n += 1;
        "Hello from TestAttribute!".to_string()
    }
}
  1. cargo b
  2. build log is attached. There is the warning that mut is not necessary however it is and the redundant attribute has been applied.

Possible Solution

No response

Notes

No response

Relevant Log Output

Click to expand/collapse

warning: variable does not need to be mutable
  --> app/src/lib.rs:29:36
   |
29 |     pub fn do_something(&mut self, mut input: Input) -> String {
   |                                    ----^^^^^
   |                                    |
   |                                    help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant