Skip to content

Commit 1e709bf

Browse files
committed
deprecate Unicode functions that will be moved to crates.io
This deprecates the following functionality: 1. char.width() and str.width(): use unicode-width crate 2. str.graphemes() and str.grapheme_indices(): use unicode-uax29 crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(): use unicode-decomp crate
1 parent dabf0c6 commit 1e709bf

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed

src/libcollections/str.rs

+18
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ enum DecompositionType {
161161
/// External iterator for a string decomposition's characters.
162162
///
163163
/// For use with the `std::iter` module.
164+
#[deprecated(reason = "use the crates.io `unicode-decomp` library instead",
165+
since = "1.0.0-nightly-20150415")]
164166
#[derive(Clone)]
165167
#[unstable(feature = "unicode",
166168
reason = "this functionality may be replaced with a more generic \
@@ -254,6 +256,8 @@ enum RecompositionState {
254256
/// External iterator for a string recomposition's characters.
255257
///
256258
/// For use with the `std::iter` module.
259+
#[deprecated(reason = "use the crates.io `unicode-decomp` library instead",
260+
since = "1.0.0-nightly-20150415")]
257261
#[derive(Clone)]
258262
#[unstable(feature = "unicode",
259263
reason = "this functionality may be replaced with a more generic \
@@ -465,6 +469,8 @@ impl str {
465469

466470
/// Returns an iterator over the string in Unicode Normalization Form D
467471
/// (canonical decomposition).
472+
#[deprecated(reason = "use the crates.io `unicode-decomp` library instead",
473+
since = "1.0.0-nightly-20150415")]
468474
#[inline]
469475
#[unstable(feature = "unicode",
470476
reason = "this functionality may be replaced with a more generic \
@@ -480,6 +486,8 @@ impl str {
480486

481487
/// Returns an iterator over the string in Unicode Normalization Form KD
482488
/// (compatibility decomposition).
489+
#[deprecated(reason = "use the crates.io `unicode-decomp` library instead",
490+
since = "1.0.0-nightly-20150415")]
483491
#[inline]
484492
#[unstable(feature = "unicode",
485493
reason = "this functionality may be replaced with a more generic \
@@ -495,6 +503,8 @@ impl str {
495503

496504
/// An Iterator over the string in Unicode Normalization Form C
497505
/// (canonical decomposition followed by canonical composition).
506+
#[deprecated(reason = "use the crates.io `unicode-decomp` library instead",
507+
since = "1.0.0-nightly-20150415")]
498508
#[inline]
499509
#[unstable(feature = "unicode",
500510
reason = "this functionality may be replaced with a more generic \
@@ -511,6 +521,8 @@ impl str {
511521

512522
/// An Iterator over the string in Unicode Normalization Form KC
513523
/// (compatibility decomposition followed by canonical composition).
524+
#[deprecated(reason = "use the crates.io `unicode-decomp` library instead",
525+
since = "1.0.0-nightly-20150415")]
514526
#[inline]
515527
#[unstable(feature = "unicode",
516528
reason = "this functionality may be replaced with a more generic \
@@ -1690,6 +1702,8 @@ impl str {
16901702
///
16911703
/// assert_eq!(&gr2[..], b);
16921704
/// ```
1705+
#[deprecated(reason = "use the crates.io `unicode-uax29` library instead",
1706+
since = "1.0.0-nightly-20150415")]
16931707
#[unstable(feature = "unicode",
16941708
reason = "this functionality may only be provided by libunicode")]
16951709
pub fn graphemes(&self, is_extended: bool) -> Graphemes {
@@ -1709,6 +1723,8 @@ impl str {
17091723
///
17101724
/// assert_eq!(&gr_inds[..], b);
17111725
/// ```
1726+
#[deprecated(reason = "use the crates.io `unicode-uax29` library instead",
1727+
since = "1.0.0-nightly-20150415")]
17121728
#[unstable(feature = "unicode",
17131729
reason = "this functionality may only be provided by libunicode")]
17141730
pub fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
@@ -1749,6 +1765,8 @@ impl str {
17491765
/// recommends that these
17501766
/// characters be treated as 1 column (i.e., `is_cjk = false`) if the
17511767
/// locale is unknown.
1768+
#[deprecated(reason = "use the crates.io `unicode-width` library instead",
1769+
since = "1.0.0-nightly-20150415")]
17521770
#[unstable(feature = "unicode",
17531771
reason = "this functionality may only be provided by libunicode")]
17541772
pub fn width(&self, is_cjk: bool) -> usize {

src/libcollectionstest/str.rs

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn test_le() {
1919
assert!("foo" != "bar");
2020
}
2121

22+
#[allow(deprecated)]
2223
#[test]
2324
fn test_len() {
2425
assert_eq!("".len(), 0);
@@ -944,6 +945,7 @@ fn test_words() {
944945
assert_eq!(words, ["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"])
945946
}
946947

948+
#[allow(deprecated)]
947949
#[test]
948950
fn test_nfd_chars() {
949951
macro_rules! t {
@@ -963,6 +965,7 @@ fn test_nfd_chars() {
963965
t!("\u{ac1c}", "\u{1100}\u{1162}");
964966
}
965967

968+
#[allow(deprecated)]
966969
#[test]
967970
fn test_nfkd_chars() {
968971
macro_rules! t {
@@ -982,6 +985,7 @@ fn test_nfkd_chars() {
982985
t!("\u{ac1c}", "\u{1100}\u{1162}");
983986
}
984987

988+
#[allow(deprecated)]
985989
#[test]
986990
fn test_nfc_chars() {
987991
macro_rules! t {
@@ -1002,6 +1006,7 @@ fn test_nfc_chars() {
10021006
t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
10031007
}
10041008

1009+
#[allow(deprecated)]
10051010
#[test]
10061011
fn test_nfkc_chars() {
10071012
macro_rules! t {
@@ -1033,6 +1038,7 @@ fn test_lines() {
10331038
assert_eq!(lines, ["", "Märy häd ä little lämb", "", "Little lämb"]);
10341039
}
10351040

1041+
#[allow(deprecated)]
10361042
#[test]
10371043
fn test_graphemes() {
10381044
use std::iter::order;

src/libcoretest/char.rs

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ fn test_len_utf16() {
210210
assert!('\u{1f4a9}'.len_utf16() == 2);
211211
}
212212

213+
#[allow(deprecated)]
213214
#[test]
214215
fn test_width() {
215216
assert_eq!('\x00'.width(false),Some(0));

src/librustc_driver/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ Additional help:
531531
extra_help);
532532
}
533533

534+
#[allow(deprecated)]
534535
fn describe_lints(lint_store: &lint::LintStore, loaded_plugins: bool) {
535536
println!("
536537
Available lint options:

src/libsyntax/diagnostic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ fn highlight_suggestion(err: &mut EmitterWriter,
542542
Ok(())
543543
}
544544

545+
#[allow(deprecated)]
545546
fn highlight_lines(err: &mut EmitterWriter,
546547
cm: &codemap::CodeMap,
547548
sp: Span,
@@ -664,6 +665,7 @@ fn highlight_lines(err: &mut EmitterWriter,
664665
/// than 6 lines), `end_highlight_lines` will print the first line, then
665666
/// dot dot dot, then last line, whereas `highlight_lines` prints the first
666667
/// six lines.
668+
#[allow(deprecated)]
667669
fn end_highlight_lines(w: &mut EmitterWriter,
668670
cm: &codemap::CodeMap,
669671
sp: Span,

src/libunicode/char.rs

+2
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ impl char {
445445
/// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
446446
/// recommends that these characters be treated as 1 column (i.e.,
447447
/// `is_cjk` = `false`) if the context cannot be reliably determined.
448+
#[deprecated(reason = "use the crates.io `unicode-width` library instead",
449+
since = "1.0.0-nightly-20150415")]
448450
#[unstable(feature = "unicode",
449451
reason = "needs expert opinion. is_cjk flag stands out as ugly")]
450452
pub fn width(self, is_cjk: bool) -> Option<usize> { charwidth::width(self, is_cjk) }

src/libunicode/u_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl UnicodeStr for str {
7575
#[inline]
7676
fn is_alphanumeric(&self) -> bool { self.chars().all(|c| c.is_alphanumeric()) }
7777

78+
#[allow(deprecated)]
7879
#[inline]
7980
fn width(&self, is_cjk: bool) -> usize {
8081
self.chars().map(|c| c.width(is_cjk).unwrap_or(0)).sum()

0 commit comments

Comments
 (0)