Skip to content

Outer attributes of generic type / lifetime parameter not respected in async trait async function definition. #288

Closed
@jymchng

Description

@jymchng

Hi sir(s)

Thank you for the awesome crate and also for many other crates you (and your team) had contributed to the Rust ecosystem!

Consider this snippet:

use {async_trait::async_trait}; // 0.1.86

#[async_trait]
trait AsyncTrait {
    
    async fn async_fn<#[cfg(test)] T>(#[cfg(test)] t: T) {
        #[cfg(test)]
        let _ = t;
    }
}

trait SyncTrait {
    
    fn async_fn<#[cfg(test)] T>(#[cfg(test)] t: T) {
        #[cfg(test)]
        let _ = t;
    }
}

Playground

For the async function definition async fn async_fn<#[cfg(test)] T>(#[cfg(test)] t: T) {, it seems that #[async_trait] attribute macro does not respect the outer attribute #[cfg(test)] in the generic type parameter 'slot', i.e. <#[cfg(test)] T>.

I am not sure if this is a bug or intended.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions