about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorAngelicosPhosphoros <xuzin.timur@gmail.com>2023-05-02 17:53:11 +0400
committerAngelicosPhosphoros <xuzin.timur@gmail.com>2023-05-11 18:06:31 +0400
commit7c263adb2afc310b96422bd33317407bc5385bf9 (patch)
treee5c2a5db3896f6832dfe64f857461c292c463f3e /compiler/rustc_span/src
parentf8d8ffa2eba53928662dc57bc3a6c5608beb26f1 (diff)
downloadrust-7c263adb2afc310b96422bd33317407bc5385bf9.tar.gz
rust-7c263adb2afc310b96422bd33317407bc5385bf9.zip
Add support for `cfg(overflow_checks)`
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.
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/symbol.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 60efcb768cb..9951d8f4fc1 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -463,6 +463,7 @@ symbols! {
         cfg_doctest,
         cfg_eval,
         cfg_hide,
+        cfg_overflow_checks,
         cfg_panic,
         cfg_sanitize,
         cfg_target_abi,
@@ -1065,6 +1066,7 @@ symbols! {
         or_patterns,
         other,
         out,
+        overflow_checks,
         overlapping_marker_traits,
         owned_box,
         packed,