Skip to content

[Bug] async_trait underscore variable ignore cannot find value __arg1 #17

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

Open
Lukas-Heiligenbrunner opened this issue Feb 22, 2025 · 0 comments

Comments

@Lukas-Heiligenbrunner
Copy link

Hey, thanks for this great lib!
When using async_trait and ignoring a variable with underscore in an implementation your trait fails with:

cannot find value `__arg1` in this scope
  --> src/main.rs:25:5
   |
25 |     #[logcall]
   |     ^^^^^^^^^^ not found in this scope

Code to reproduce:

#[tokio::main]
async fn main() {
    env_logger::builder()
        .parse_env(Env::default().filter_or("LOG_LEVEL", "trace"))
        .init();

    let test = Test {};
    test.test("Hello".to_string()).await;
}

#[async_trait]
pub trait TestTrait {
    async fn test(&self, mystr: String) -> String;
}

struct Test {}

#[async_trait]
impl TestTrait for Test {
    #[logcall]
    async fn test(&self, _: String) -> String {
        "test".to_string()
    }
}

Note, when giving the string of the async test function an explicit name it works fine.

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