Move contents of libstd_unicode into libcore

This commit is contained in:
Simon Sapin 2018-04-05 17:09:28 +02:00
parent f87d4a15a8
commit 5807be7ccb
10 changed files with 56 additions and 59 deletions

View File

@ -180,6 +180,8 @@ pub mod hash;
pub mod fmt;
pub mod time;
pub mod unicode;
/* Heap memory allocator trait */
#[allow(missing_docs)]
pub mod heap;

View File

@ -28,30 +28,30 @@
#![stable(feature = "rust1", since = "1.0.0")]
use core::char::CharExt as C;
use core::iter::FusedIterator;
use core::fmt::{self, Write};
use tables::{conversions, derived_property, general_category, property};
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 core::char::{MAX, from_digit, from_u32, from_u32_unchecked};
pub use char::{MAX, from_digit, from_u32, from_u32_unchecked};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode};
pub use char::{EscapeDebug, EscapeDefault, EscapeUnicode};
#[stable(feature = "decode_utf16", since = "1.9.0")]
pub use core::char::REPLACEMENT_CHARACTER;
pub use char::REPLACEMENT_CHARACTER;
#[stable(feature = "char_from_str", since = "1.20.0")]
pub use core::char::ParseCharError;
pub use char::ParseCharError;
// unstable re-exports
#[stable(feature = "try_from", since = "1.26.0")]
pub use core::char::CharTryFromError;
pub use char::CharTryFromError;
#[unstable(feature = "decode_utf8", issue = "33906")]
pub use core::char::{DecodeUtf8, decode_utf8};
pub use char::{DecodeUtf8, decode_utf8};
#[unstable(feature = "unicode", issue = "27783")]
pub use tables::{UNICODE_VERSION};
pub use unicode::tables::{UNICODE_VERSION};
#[unstable(feature = "unicode", issue = "27783")]
pub use version::UnicodeVersion;
pub use unicode::version::UnicodeVersion;
/// Returns an iterator that yields the lowercase equivalent of a `char`.
///

View File

@ -0,0 +1,29 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![unstable(feature = "unicode", issue = "27783")]
#![allow(missing_docs)]
mod bool_trie;
mod tables;
mod version;
pub mod str;
pub mod char;
// For use in liballoc, not re-exported in libstd.
pub mod derived_property {
pub use unicode::tables::derived_property::{Case_Ignorable, Cased};
}
// For use in libsyntax
pub mod property {
pub use unicode::tables::property::Pattern_White_Space;
}

View File

@ -13,9 +13,9 @@
//! This module provides functionality to `str` that requires the Unicode
//! methods provided by the unicode parts of the CharExt trait.
use core::char;
use core::iter::{Filter, FusedIterator};
use core::str::Split;
use char;
use iter::{Filter, FusedIterator};
use str::Split;
/// An iterator over the non-whitespace substrings of a string,
/// separated by any amount of whitespace.

View File

@ -12,8 +12,8 @@
#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
use version::UnicodeVersion;
use bool_trie::{BoolTrie, SmallBoolTrie};
use unicode::version::UnicodeVersion;
use unicode::bool_trie::{BoolTrie, SmallBoolTrie};
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
/// `CharExt` and `UnicodeStrPrelude` traits are based on.
@ -1138,9 +1138,6 @@ pub mod property {
}
pub mod conversions {
use core::option::Option;
use core::option::Option::{Some, None};
pub fn to_lower(c: char) -> [char; 3] {
match bsearch_case_table(c, to_lowercase_table) {
None => [c, '\0', '\0'],

View File

@ -39,8 +39,8 @@ preamble = '''// Copyright 2012-2016 The Rust Project Developers. See the COPYRI
#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
use version::UnicodeVersion;
use bool_trie::{BoolTrie, SmallBoolTrie};
use unicode::version::UnicodeVersion;
use unicode::bool_trie::{BoolTrie, SmallBoolTrie};
'''
# Mapping taken from Table 12 from:
@ -408,9 +408,6 @@ def emit_property_module(f, mod, tbl, emit):
def emit_conversions_module(f, to_upper, to_lower, to_title):
f.write("pub mod conversions {")
f.write("""
use core::option::Option;
use core::option::Option::{Some, None};
pub fn to_lower(c: char) -> [char; 3] {
match bsearch_case_table(c, to_lowercase_table) {
None => [c, '\\0', '\\0'],

View File

@ -27,37 +27,9 @@
html_playground_url = "https://play.rust-lang.org/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![deny(missing_debug_implementations)]
#![no_std]
#![feature(ascii_ctype)]
#![feature(core_char_ext)]
#![feature(str_internals)]
#![feature(decode_utf8)]
#![feature(fn_traits)]
#![feature(lang_items)]
#![feature(non_exhaustive)]
#![feature(unicode)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
mod bool_trie;
mod tables;
mod u_str;
mod version;
pub mod char;
#[allow(deprecated)]
pub mod str {
pub use u_str::{SplitWhitespace, UnicodeStr};
pub use u_str::Utf16Encoder;
}
// For use in liballoc, not re-exported in libstd.
pub mod derived_property {
pub use tables::derived_property::{Case_Ignorable, Cased};
}
// For use in libsyntax
pub mod property {
pub use tables::property::Pattern_White_Space;
}
pub use core::unicode::*;

View File

@ -15,9 +15,9 @@
#![no_std]
// OK
#[lang = "char"]
impl char {}
#[lang = "str"]
impl str {}
impl char {
//~^ error: only a single inherent implementation marked with `#[lang = "char"]` is allowed for the `char` primitive
impl str {
//~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive
}