Skip to content

False never used function warning #101699

Closed
Closed
@leonardo-m

Description

@leonardo-m

I'm not sure if this is expected. In this code I've used a const test function, and I call it inside a const assert:

macro_rules! const_assert {
    ($x:expr $(,)?) => {
        const _: () = assert!($x);
    };
}

fn main() {
    const fn test(n: u32) -> bool {
        n > 0
    }
    const N: u32 = 100;
    const_assert!(test(N));
    dbg!(N);
}

This code works correctly, but rusts gives a "warning: function test is never used".

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions