Skip to content

Commit d14a96c

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-segmentation crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(), char.compose(), char.decompose_canonical(), char.decompose_compatible(): use unicode-normalization crate
1 parent dabf0c6 commit d14a96c

File tree

8 files changed

+51
-0
lines changed

8 files changed

+51
-0
lines changed

src/libcollections/str.rs

+26
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ enum DecompositionType {
161161
/// External iterator for a string decomposition's characters.
162162
///
163163
/// For use with the `std::iter` module.
164+
#[allow(deprecated)]
165+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
166+
since = "1.0.0")]
164167
#[derive(Clone)]
165168
#[unstable(feature = "unicode",
166169
reason = "this functionality may be replaced with a more generic \
@@ -172,6 +175,7 @@ pub struct Decompositions<'a> {
172175
sorted: bool
173176
}
174177

178+
#[allow(deprecated)]
175179
#[stable(feature = "rust1", since = "1.0.0")]
176180
impl<'a> Iterator for Decompositions<'a> {
177181
type Item = char;
@@ -254,6 +258,9 @@ enum RecompositionState {
254258
/// External iterator for a string recomposition's characters.
255259
///
256260
/// For use with the `std::iter` module.
261+
#[allow(deprecated)]
262+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
263+
since = "1.0.0")]
257264
#[derive(Clone)]
258265
#[unstable(feature = "unicode",
259266
reason = "this functionality may be replaced with a more generic \
@@ -266,6 +273,7 @@ pub struct Recompositions<'a> {
266273
last_ccc: Option<u8>
267274
}
268275

276+
#[allow(deprecated)]
269277
#[stable(feature = "rust1", since = "1.0.0")]
270278
impl<'a> Iterator for Recompositions<'a> {
271279
type Item = char;
@@ -465,6 +473,9 @@ impl str {
465473

466474
/// Returns an iterator over the string in Unicode Normalization Form D
467475
/// (canonical decomposition).
476+
#[allow(deprecated)]
477+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
478+
since = "1.0.0")]
468479
#[inline]
469480
#[unstable(feature = "unicode",
470481
reason = "this functionality may be replaced with a more generic \
@@ -480,6 +491,9 @@ impl str {
480491

481492
/// Returns an iterator over the string in Unicode Normalization Form KD
482493
/// (compatibility decomposition).
494+
#[allow(deprecated)]
495+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
496+
since = "1.0.0")]
483497
#[inline]
484498
#[unstable(feature = "unicode",
485499
reason = "this functionality may be replaced with a more generic \
@@ -495,6 +509,9 @@ impl str {
495509

496510
/// An Iterator over the string in Unicode Normalization Form C
497511
/// (canonical decomposition followed by canonical composition).
512+
#[allow(deprecated)]
513+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
514+
since = "1.0.0")]
498515
#[inline]
499516
#[unstable(feature = "unicode",
500517
reason = "this functionality may be replaced with a more generic \
@@ -511,6 +528,9 @@ impl str {
511528

512529
/// An Iterator over the string in Unicode Normalization Form KC
513530
/// (compatibility decomposition followed by canonical composition).
531+
#[allow(deprecated)]
532+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
533+
since = "1.0.0")]
514534
#[inline]
515535
#[unstable(feature = "unicode",
516536
reason = "this functionality may be replaced with a more generic \
@@ -1690,6 +1710,8 @@ impl str {
16901710
///
16911711
/// assert_eq!(&gr2[..], b);
16921712
/// ```
1713+
#[deprecated(reason = "use the crates.io `unicode-segmentation` library instead",
1714+
since = "1.0.0")]
16931715
#[unstable(feature = "unicode",
16941716
reason = "this functionality may only be provided by libunicode")]
16951717
pub fn graphemes(&self, is_extended: bool) -> Graphemes {
@@ -1709,6 +1731,8 @@ impl str {
17091731
///
17101732
/// assert_eq!(&gr_inds[..], b);
17111733
/// ```
1734+
#[deprecated(reason = "use the crates.io `unicode-segmentation` library instead",
1735+
since = "1.0.0")]
17121736
#[unstable(feature = "unicode",
17131737
reason = "this functionality may only be provided by libunicode")]
17141738
pub fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
@@ -1749,6 +1773,8 @@ impl str {
17491773
/// recommends that these
17501774
/// characters be treated as 1 column (i.e., `is_cjk = false`) if the
17511775
/// locale is unknown.
1776+
#[deprecated(reason = "use the crates.io `unicode-width` library instead",
1777+
since = "1.0.0")]
17521778
#[unstable(feature = "unicode",
17531779
reason = "this functionality may only be provided by libunicode")]
17541780
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")]
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/normalize.rs

+12
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@ fn bsearch_table<T>(c: char, r: &'static [(char, &'static [T])]) -> Option<&'sta
3333
}
3434

3535
/// Compute canonical Unicode decomposition for character
36+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
37+
since = "1.0.0")]
38+
#[unstable(feature = "unicode",
39+
reason = "this functionality will be moved to crates.io")]
3640
pub fn decompose_canonical<F>(c: char, mut i: F) where F: FnMut(char) { d(c, &mut i, false); }
3741

3842
/// Compute canonical or compatible Unicode decomposition for character
43+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
44+
since = "1.0.0")]
45+
#[unstable(feature = "unicode",
46+
reason = "this functionality will be moved to crates.io")]
3947
pub fn decompose_compatible<F>(c: char, mut i: F) where F: FnMut(char) { d(c, &mut i, true); }
4048

4149
// FIXME(#19596) This is a workaround, we should use `F` instead of `&mut F`
@@ -78,6 +86,10 @@ fn d<F>(c: char, i: &mut F, k: bool) where F: FnMut(char) {
7886
(*i)(c);
7987
}
8088

89+
#[deprecated(reason = "use the crates.io `unicode-normalization` library instead",
90+
since = "1.0.0")]
91+
#[unstable(feature = "unicode",
92+
reason = "this functionality will be moved to crates.io")]
8193
pub fn compose(a: char, b: char) -> Option<char> {
8294
compose_hangul(a, b).or_else(|| {
8395
match bsearch_table(a, composition_table) {

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)