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

Linting on non_snake_case is inconsistent with ordinary trait impls #85

Closed
dtolnay opened this issue Apr 2, 2020 · 0 comments · Fixed by #86
Closed

Linting on non_snake_case is inconsistent with ordinary trait impls #85

dtolnay opened this issue Apr 2, 2020 · 0 comments · Fixed by #86
Labels
bug Something isn't working

Comments

@dtolnay
Copy link
Owner

dtolnay commented Apr 2, 2020

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)]
    |             ^^^^^^^^^^^^^^
@dtolnay dtolnay added the bug Something isn't working label Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant