antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.42k stars 79 forks source link

Compiler warnings #247

Closed antoyo closed 3 years ago

antoyo commented 3 years ago
warning: unused doc comment
   --> src/app/status_bar.rs:363:5
    |
361 | #[derive(Msg)]
    |          --- rustdoc does not generate documentation for match arms
362 | pub enum ItemMsg {
363 |     /// Set the color of the status bar item.
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
antoyo commented 3 years ago

@zzeroo: If we compile with:

cargo rustc --profile=check -- -Zunstable-options --pretty=expanded

we can see the generated code and why this causes an issue:

impl ::relm::DisplayVariant for Msg {
    #[allow(unused_qualifications)]
    fn display_variant(&self) -> &'static str {
        match *self
            {
             #[doc = " Comment."]
             Msg::Decrement { .. } => "Decrement",
            Msg::Increment { .. } => "Increment",
            Msg::Quit { .. } => "Quit",
        }
    }
}

We see a useless doc-comment on a pattern. This is most likely caused by this line. ~If I did that, it's probably for a reason, though I don't remember it.~ Edit: I remember now: it's to allow the usage of #[cfg(test)] to have a message only used in tests.

~Maybe you could try removing this attribute to see if it generates an error in the tests.~ Edit: This should generate errors in tests. We probably just need to filter the attributes to remove the ones with the name doc.