mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
7c263adb2a
This PR adds support for detecting if overflow checks are enabled in similar fashion as debug_assertions are detected. Possible use-case of this, for example, if we want to use checked integer casts in builds with overflow checks, e.g. ```rust pub fn cast(val: usize)->u16 { if cfg!(overflow_checks) { val.try_into().unwrap() } else{ vas as _ } } ``` Resolves #91130. Tracking issue: #111466.
13 lines
484 B
Plaintext
13 lines
484 B
Plaintext
error[E0658]: `cfg(overflow_checks)` is experimental and subject to change
|
|
--> $DIR/feature-gate-cfg_overflow_checks.rs:3:7
|
|
|
|
|
LL | #[cfg(overflow_checks)]
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
= note: see issue #111466 <https://github.com/rust-lang/rust/issues/111466> for more information
|
|
= help: add `#![feature(cfg_overflow_checks)]` to the crate attributes to enable
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0658`.
|