Warn(dead_code) for a struct with a allow(dead_code) method

Hello !

I am writing a little lib providing a macro who generate structure with implemented functions. The functions are not necessarily used, so I add them allow(dead_code).

#[warn(dead_code)]
struct U(u64);

impl U {
    #[allow(dead_code)]
    pub fn foo() {}
}

The problem is there is no warning even when the structure is absolutely unused. The fact of removing the warning for one of the method implemented remove also the warning for the structure.

Someone would have a solution?
Sorry if my English is bad, is not my native language.

No one has a solution ?
Or it's really not possible…

I wonder if this should be considered a bug?

It does seem to be a "bug"...

Where should we talk about to see if it's a bug ?

Maybe here: https://github.com/rust-lang/rust/issues.

1 Like