Skip to content

Calling a static trait method on a type doesn't mark it as used. #27037

Closed
@michaelsproul

Description

@michaelsproul
enum Empty {}
struct Unit;

trait Run {
    fn run() -> u8;
}

impl Run for Empty {
    fn run() -> u8 { 0 }
}

impl Run for Unit {
    fn run() -> u8 { 1 }
}

fn main() {
    println!("{} {}", Empty::run(), Unit::run());
}
$ rustc -V
rustc 1.3.0-nightly (6d71ce536 2015-07-06)

$ rustc test.rs 
test.rs:1:1: 1:14 warning: enum is never used: `Empty`, #[warn(dead_code)] on by default
test.rs:1 enum Empty {}
          ^~~~~~~~~~~~~
test.rs:2:1: 2:13 warning: struct is never used: `Unit`, #[warn(dead_code)] on by default
test.rs:2 struct Unit;

The same doesn't happen for static methods implemented directly on the types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions