Skip to content

Function used in anonymous constant is not considered used #104084

Description

@joshlf

I have the following code:

fn foo() {}
const fn bar() {}

fn main() {
    let _ = foo();
    const _: () = bar();
}

Even though both foo and bar are used, I get an unused warning for bar:

warning: function `bar` is never used
 --> src/main.rs:2:10
  |
2 | const fn bar() {}
  |          ^^^
  |
  = note: `#[warn(dead_code)]` on by default

Version

Rust 1.65.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions