From 1977c62339acceabe711d8ca6bf9404475c7f75d Mon Sep 17 00:00:00 2001 From: Joe ST Date: Wed, 23 May 2018 15:01:11 +0100 Subject: [PATCH] move type def out of unsafe block from https://github.com/rust-lang/rust/pull/50863#discussion_r190213000 move the union definition outside of the unsafe block --- src/libcore/str/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 70aaf10f421..13d808ede5f 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -2246,13 +2246,11 @@ pub fn is_char_boundary(&self, index: usize) -> bool { #[inline(always)] #[rustc_const_unstable(feature="const_str_as_bytes")] pub const fn as_bytes(&self) -> &[u8] { - unsafe { - union Slices<'a> { - str: &'a str, - slice: &'a [u8], - } - Slices { str: self }.slice + union Slices<'a> { + str: &'a str, + slice: &'a [u8], } + unsafe { Slices { str: self }.slice } } /// Converts a mutable string slice to a mutable byte slice. To convert the -- GitLab