]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #8612 - SabrinaJewson:suggest-from-utf8-unchecked-in-const, r=flip1995
authorbors <bors@rust-lang.org>
Wed, 6 Apr 2022 09:32:51 +0000 (09:32 +0000)
committerbors <bors@rust-lang.org>
Wed, 6 Apr 2022 09:32:51 +0000 (09:32 +0000)
Suggest from_utf8_unchecked in const contexts

Unfortunately I couldn't figure out how to check whether a given expression is in an `unsafe` context or not, so I just unconditionally emit the wrapping `unsafe {}` block in the suggestion. If there is an easy way to get it to work better then I would love to hear it.

changelog: Suggest `from_utf8_unchecked` instead of `from_utf8` in const contexts for ``[`transmute_bytes_to_str`]``

refs: #8379


Trivial merge