Skip to content

Incorrect 'never used' warning for struct when only use is in pattern match #52325

Description

@stearnsc

I ran across this implementing a one-time-use struct for a diesel query.
I incorrectly get a warning:

warning: struct is never used: `Foo`

when compiling

trait SomeTrait {}

struct Foo {
    s: String
}

impl SomeTrait for Foo {}

fn main() {
    let Foo { s } = get_thing();
    println!("{}", s);
}

fn get_thing<T: SomeTrait>() -> T {
    unimplemented!()
}

I got this is on 1.27.0 stable, and verified still exists on 1.29.0-nightly (2018-07-10). I didn't find another issue that looked like the same thing, so hopefully this isn't a duplicate :).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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