Skip to content

Commit c57a412

Browse files
committed
Address a review comment and fix a bootstrapping issue
1 parent 7ac6b58 commit c57a412

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

src/libcollections/str.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1856,16 +1856,21 @@ impl str {
18561856
let mut s = String::with_capacity(self.len());
18571857
for (i, c) in self[..].char_indices() {
18581858
if c == 'Σ' {
1859+
// Σ maps to σ, except at the end of a word where it maps to ς.
1860+
// This is the only conditional (contextual) but language-independent mapping
1861+
// in `SpecialCasing.txt`,
1862+
// so hard-code it rather than have a generic "condition" mechanim.
1863+
// See https://github.com/rust-lang/rust/issues/26035
18591864
map_uppercase_sigma(self, i, &mut s)
18601865
} else {
18611866
s.extend(c.to_lowercase());
18621867
}
18631868
}
18641869
return s;
18651870

1866-
#[cold]
1867-
#[inline(never)]
18681871
fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) {
1872+
// See http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992
1873+
// for the definition of `Final_Sigma`.
18691874
debug_assert!('Σ'.len_utf8() == 2);
18701875
let is_word_final =
18711876
case_ignoreable_then_cased(from[..i].chars().rev()) &&

src/libcollectionstest/str.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,34 @@ fn trim_ws() {
16901690
#[test]
16911691
fn to_lowercase() {
16921692
assert_eq!("".to_lowercase(), "");
1693+
assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé ");
1694+
16931695
// https://github.com/rust-lang/rust/issues/26035
1694-
assert_eq!("'Σ AÉΣ'Σ'' Σ DžΣ".to_lowercase(), "'σ aéσ'ς'' σ džς");
1696+
assert_eq!("ΑΣ".to_lowercase(), "ας");
1697+
assert_eq!("Α'Σ".to_lowercase(), "α'ς");
1698+
assert_eq!("Α''Σ".to_lowercase(), "α''ς");
1699+
1700+
assert_eq!("ΑΣ Α".to_lowercase(), "ας α");
1701+
assert_eq!("Α'Σ Α".to_lowercase(), "α'ς α");
1702+
assert_eq!("Α''Σ Α".to_lowercase(), "α''ς α");
1703+
1704+
assert_eq!("ΑΣ' Α".to_lowercase(), "ας' α");
1705+
assert_eq!("ΑΣ'' Α".to_lowercase(), "ας'' α");
1706+
1707+
assert_eq!("Α'Σ' Α".to_lowercase(), "α'ς' α");
1708+
assert_eq!("Α''Σ'' Α".to_lowercase(), "α''ς'' α");
1709+
1710+
assert_eq!("Α Σ".to_lowercase(), "α σ");
1711+
assert_eq!("Α 'Σ".to_lowercase(), "α 'σ");
1712+
assert_eq!("Α ''Σ".to_lowercase(), "α ''σ");
1713+
1714+
assert_eq!("Σ".to_lowercase(), "σ");
1715+
assert_eq!("'Σ".to_lowercase(), "'σ");
1716+
assert_eq!("''Σ".to_lowercase(), "''σ");
1717+
1718+
assert_eq!("ΑΣΑ".to_lowercase(), "ασα");
1719+
assert_eq!("ΑΣ'Α".to_lowercase(), "ασ'α");
1720+
assert_eq!("ΑΣ''Α".to_lowercase(), "ασ''α");
16951721
}
16961722

16971723
#[test]

src/librustc_lint/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#![feature(box_patterns)]
3434
#![feature(box_syntax)]
35-
#![feature(collections)]
35+
#![cfg_attr(stage0, feature(collections))]
3636
#![feature(core)]
3737
#![feature(quote)]
3838
#![feature(rustc_diagnostic_macros)]

src/librustc_unicode/char.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Iterator for ToUppercase {
7070
/// An iterator over the titlecase mapping of a given character, returned from
7171
/// the [`to_titlecase` method](../primitive.char.html#method.to_titlecase) on
7272
/// characters.
73-
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
73+
#[unstable(feature = "unicode", reason = "recently added")]
7474
pub struct ToTitlecase(CaseMappingIter);
7575

7676
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
@@ -481,7 +481,7 @@ impl char {
481481
/// Returns an iterator which yields the characters corresponding to the
482482
/// lowercase equivalent of the character. If no conversion is possible then
483483
/// an iterator with just the input character is returned.
484-
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
484+
#[unstable(feature = "unicode", reason = "recently added")]
485485
#[inline]
486486
pub fn to_titlecase(self) -> ToTitlecase {
487487
ToTitlecase(CaseMappingIter::new(conversions::to_title(self)))

0 commit comments

Comments
 (0)