butte-rs/butte

clippy warnings

Opened this issue · 1 comments

reyk commented

DISCLAIMER: I'm using a non-default clippy configuration.

With that, I have to use the following block for the generated Rust code:

#![allow(
    clippy::unreadable_literal,
    clippy::empty_enum,
    clippy::unseparated_literal_suffix
)]
#![allow(single_use_lifetimes)]

This request is a "nice-to-have", not a real issue. But as the flatbuffers crate generates quite outdated and "dirty" rust code, it would be a nice benefit if butte could try to be as rust-2018-clean as possible. Either by adding the allow directives in the generated code or by generating it in the desired style.

  • clippy::unreadable_literal: this happens with very large default values, e.g.:

    table Hello {
        value: i64 = 1000000;
    }
    

    Clippy would expect 1_000_000. The FlatBuffers schema doesn't support this and converting the format would probably be an excessive step, but it could be a case for an [allow(clippy::unreadable_literal)] in the generated code.

  • clippy::empty_enum: this happens with the offset enums, e.g.:

    pub enum HelloOffset {}
  • clippy::unseparated_literal_suffix: this is part of the vtable, e.g.:

    pub const VT_ID: butte::VOffsetT = 4u16;
                                       ^^^^ help: add an underscore: 4_u16
  • single_use_lifetimes: This warning is a bit annoying since it generates too many false positives in perfectly valid code. So I should better fix my configuration ;-). Nevertheless, it appears in a number of places:

    impl<'a> HelloOptions<&'a [u8]> {
         ^^ this...        ^^ ...is used only here     
    ``
reyk commented

I found another one: missing_copy_implementations

That happens with small tables that only contain scalars or empty tables.