- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-langRelevant to the language teamRelevant to the language team
Description
I tried this code: [playground]
#![feature(inline_const)] pub fn cause_late_error<T>() { const { panic!() }; } fn main() { let a = 1; let b = 2; if a + b == 5 { cause_late_error::<()>(); } }
I expected to see this happen:
error[E0080]: evaluation of `cause_late_error::<()>::{constant#0}` failed --> src/main.rs:7:9 | 7 | panic!() | ^^^^^^^^ the evaluated program panicked at 'explicit panic', src/main.rs:7:9 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: the above error was encountered while instantiating `fn cause_late_error::<()>` --> src/main.rs:13:9 | 13 | cause_late_error::<()>(); | ^^^^^^^^^^^^^^^^^^^^^^^^
Instead, this happened: it compiled without any warnings.
Meta
Playground nightly, 1.69.0-nightly (2023-01-30 001a77f)
Related
- dead-code optimize
if const { expr }
even in opt-level=0 #85836 - Stabilise inline_const #104087
- unused function is not monomorphized, so post-mono lints do not show up (in particular affects associated and inline consts) #106617
Potential fix:
SludgePhD
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-langRelevant to the language teamRelevant to the language team