Skip to content

dead_code lint triggers even though function is used in const pattern #78171

Closed
@camelid

Description

@camelid

This should compile without warnings (playground):

#![allow(incomplete_features)]
#![feature(inline_const)]

const fn one() -> i32 {
    1
}

fn main() {
    match 1 {
        const { one() } => {}
        _ => {}
    }
}

Yet it warns:

   Compiling playground v0.0.1 (/playground)
warning: function is never used: `one`
 --> src/main.rs:4:10
  |
4 | const fn one() -> i32 {
  |          ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.80s
     Running `target/debug/playground`

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions