Skip to content

"arithmetic_overflow" and "unconditional_panic" lints do not fire on const fn that is only const-used in bin crate #81265

Open
@RalfJung

Description

@RalfJung

I tried the following code:

const fn overflow() -> u32 {
    0 - 1
}

pub const X: u32 = overflow();

fn main() {}

On stable, in release mode, the emits a lint (err-by-default) about the arithmetic overflow. On nightly, it does not.

This probably is related to #78407. However, the part I do not understand is that I can only reproduce the problem with a binary crate, not with a library crate. Cc @oli-obk

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.P-mediumMedium priorityregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions