dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.81k stars 84 forks source link

Linting on non_snake_case is inconsistent with ordinary trait impls #85

Closed dtolnay closed 4 years ago

dtolnay commented 4 years ago

Normally Rust only triggers non_snake_case on the one place that decides the name of a thing, for example the trait definition rather than the impl.

#![deny(non_snake_case)]

pub trait Trait {
    #[allow(non_snake_case)]
    fn camelCase();
}

pub struct Struct;

impl Trait for Struct {
    fn camelCase() {}
}

But async_trait hits it on the impl as well, which is not right.

#![deny(non_snake_case)]

use async_trait::async_trait;

#[async_trait]
pub trait Trait {
    #[allow(non_snake_case)]
    async fn camelCase();
}

pub struct Struct;

#[async_trait]
impl Trait for Struct {
    async fn camelCase() {}
}
error: function `__camelCase` should have a snake case name
   --> tests/test.rs:584:18
    |
584 |         async fn camelCase() {}
    |                  ^^^^^^^^^ help: convert the identifier to snake case: `__camel_case`
    |
note: the lint level is defined here
   --> tests/test.rs:570:13
    |
570 |     #![deny(non_snake_case)]
    |             ^^^^^^^^^^^^^^