From 939692409da499ff3d498eae782620435f16a981 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 5 Apr 2018 17:56:46 +0200 Subject: [PATCH] Reexport from core::unicode::char in core::char rather than vice versa --- src/liballoc/string.rs | 2 +- src/liballoc/tests/string.rs | 2 +- src/libcore/char/mod.rs | 12 ++++++++++++ src/libcore/unicode/char.rs | 21 +-------------------- src/libcore/unicode/mod.rs | 6 +++--- src/libstd/lib.rs | 2 +- 6 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index a902f0bb06b..29d759b1f00 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -56,6 +56,7 @@ #![stable(feature = "rust1", since = "1.0.0")] +use core::char::{decode_utf16, REPLACEMENT_CHARACTER}; use core::fmt; use core::hash; use core::iter::{FromIterator, FusedIterator}; @@ -64,7 +65,6 @@ use core::ops::{self, Add, AddAssign, Index, IndexMut, RangeBounds}; use core::ptr; use core::str::pattern::Pattern; use core::str::lossy; -use core::unicode::char::{decode_utf16, REPLACEMENT_CHARACTER}; use borrow::{Cow, ToOwned}; use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}; diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 33f20be100d..17d53e4cf3e 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -132,7 +132,7 @@ fn test_from_utf16() { let s_as_utf16 = s.encode_utf16().collect::>(); let u_as_string = String::from_utf16(&u).unwrap(); - assert!(::core::unicode::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok())); + assert!(::core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok())); assert_eq!(s_as_utf16, u); assert_eq!(u_as_string, s); diff --git a/src/libcore/char/mod.rs b/src/libcore/char/mod.rs index c6b620e5238..3efa8396331 100644 --- a/src/libcore/char/mod.rs +++ b/src/libcore/char/mod.rs @@ -15,6 +15,18 @@ #![allow(non_snake_case)] #![stable(feature = "core_char", since = "1.2.0")] +// stable re-exports +#[stable(feature = "rust1", since = "1.0.0")] +pub use unicode::char::{ToLowercase, ToUppercase}; +#[stable(feature = "decode_utf16", since = "1.9.0")] +pub use unicode::char::{decode_utf16, DecodeUtf16, DecodeUtf16Error}; + +// unstable re-exports +#[unstable(feature = "unicode", issue = "27783")] +pub use unicode::tables::{UNICODE_VERSION}; +#[unstable(feature = "unicode", issue = "27783")] +pub use unicode::version::UnicodeVersion; + mod printable; use self::printable::is_printable; diff --git a/src/libcore/unicode/char.rs b/src/libcore/unicode/char.rs index 0e8b09f621a..e75338aedf1 100644 --- a/src/libcore/unicode/char.rs +++ b/src/libcore/unicode/char.rs @@ -28,31 +28,12 @@ #![stable(feature = "rust1", since = "1.0.0")] +use char::*; use char::CharExt as C; use iter::FusedIterator; use fmt::{self, Write}; use unicode::tables::{conversions, derived_property, general_category, property}; -// stable re-exports -#[stable(feature = "rust1", since = "1.0.0")] -pub use char::{MAX, from_digit, from_u32, from_u32_unchecked}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use char::{EscapeDebug, EscapeDefault, EscapeUnicode}; -#[stable(feature = "decode_utf16", since = "1.9.0")] -pub use char::REPLACEMENT_CHARACTER; -#[stable(feature = "char_from_str", since = "1.20.0")] -pub use char::ParseCharError; - -// unstable re-exports -#[stable(feature = "try_from", since = "1.26.0")] -pub use char::CharTryFromError; -#[unstable(feature = "decode_utf8", issue = "33906")] -pub use char::{DecodeUtf8, decode_utf8}; -#[unstable(feature = "unicode", issue = "27783")] -pub use unicode::tables::{UNICODE_VERSION}; -#[unstable(feature = "unicode", issue = "27783")] -pub use unicode::version::UnicodeVersion; - /// Returns an iterator that yields the lowercase equivalent of a `char`. /// /// This `struct` is created by the [`to_lowercase`] method on [`char`]. See diff --git a/src/libcore/unicode/mod.rs b/src/libcore/unicode/mod.rs index aaf8081799f..0ea1aa12146 100644 --- a/src/libcore/unicode/mod.rs +++ b/src/libcore/unicode/mod.rs @@ -12,11 +12,11 @@ #![allow(missing_docs)] mod bool_trie; -mod tables; -mod version; +pub(crate) mod tables; +pub(crate) mod version; pub mod str; -pub mod char; +pub(crate) mod char; // For use in liballoc, not re-exported in libstd. pub mod derived_property { diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 16bca9ddcd3..94e48732c26 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -454,7 +454,7 @@ pub use alloc::string; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc::vec; #[stable(feature = "rust1", since = "1.0.0")] -pub use core::unicode::char; +pub use core::char; #[stable(feature = "i128", since = "1.26.0")] pub use core::u128;