about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-02 09:07:31 +0000
committerbors <bors@rust-lang.org>2022-08-02 09:07:31 +0000
commit792bc5a0102d0973d42183a2b267850bb905236f (patch)
tree9943fa334b90e05c7664f3e2ee84148af5dd8bb2 /compiler/rustc_codegen_gcc
parentca37a45232b41789b31caec9a71714855f66c477 (diff)
parent0e54d71e157693226c3c5f67d9755daf885714e2 (diff)
downloadrust-792bc5a0102d0973d42183a2b267850bb905236f.tar.gz
rust-792bc5a0102d0973d42183a2b267850bb905236f.zip
Auto merge of #99977 - BlackHoleFox:cfte-cstr, r=thomcc
Add validation to const fn CStr creation

Improves upon the existing validation that only worked when building the stdlib from source. `CStr::from_bytes_with_nul_unchecked` now utilizes `const_eval_select` to validate the safety requirements of the function when used as `const FOO: &CStr = CStr::from_bytes_with_nul_unchecked(b"Foobar\0");`.

This can help catch erroneous code written by accident and, assuming a new enough `rustc` in use, remove the need for boilerplate safety comments for this function in `const` contexts.

~~I think this might need a UI test, but I don't know where to put it. If this is a worth change, a perf run would be nice to make sure the `O(n)` validation isn't too bad. I didn't notice a difference building the stdlib tests locally.~~
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions