Skip to content

Commit 070ab63

Browse files
committed
auto merge of #19916 : SimonSapin/rust/ascii-reform, r=sfackler
Implements [RFC 486](rust-lang/rfcs#486). Fixes #19908. * Rename `to_ascii_{lower,upper}` to `to_ascii_{lower,upper}case`, per #14401 * Remove the `Ascii` type and associated traits: `AsciiCast`, `OwnedAsciiCast`, `AsciiStr`, `IntoBytes`, and `IntoString`. * As a replacement, add `.is_ascii()` to `AsciiExt`, and implement `AsciiExt` for `u8` and `char`. [breaking-change]
2 parents 0201334 + 12e6071 commit 070ab63

File tree

13 files changed

+146
-616
lines changed

13 files changed

+146
-616
lines changed

src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn parse_expected(last_nonfollow_error: Option<uint>,
6767
re: &Regex) -> Option<(WhichLine, ExpectedError)> {
6868
re.captures(line).and_then(|caps| {
6969
let adjusts = caps.name("adjusts").unwrap_or("").len();
70-
let kind = caps.name("kind").unwrap_or("").to_ascii_lower();
70+
let kind = caps.name("kind").unwrap_or("").to_ascii_lowercase();
7171
let msg = caps.name("msg").unwrap_or("").trim().to_string();
7272
let follow = caps.name("follow").unwrap_or("").len() > 0;
7373

src/compiletest/runtest.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use util::logv;
2121
#[cfg(target_os = "windows")]
2222
use util;
2323

24+
#[cfg(target_os = "windows")]
25+
use std::ascii::AsciiExt;
2426
use std::io::File;
2527
use std::io::fs::PathExtensions;
2628
use std::io::fs;
@@ -985,22 +987,9 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
985987
format!("{}:{}:", testfile.display(), ee.line)
986988
}).collect::<Vec<String> >();
987989

988-
#[cfg(target_os = "windows")]
989-
fn to_lower( s : &str ) -> String {
990-
let i = s.chars();
991-
let c : Vec<char> = i.map( |c| {
992-
if c.is_ascii() {
993-
c.to_ascii().to_lowercase().as_char()
994-
} else {
995-
c
996-
}
997-
} ).collect();
998-
String::from_chars(c.as_slice())
999-
}
1000-
1001990
#[cfg(windows)]
1002991
fn prefix_matches( line : &str, prefix : &str ) -> bool {
1003-
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
992+
line.to_ascii_lowercase().starts_with(prefix.to_ascii_lowercase().as_slice())
1004993
}
1005994

1006995
#[cfg(unix)]

src/librustc/lint/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct Lint {
6868
impl Lint {
6969
/// Get the lint's name, with ASCII letters converted to lowercase.
7070
pub fn name_lower(&self) -> String {
71-
self.name.to_ascii_lower()
71+
self.name.to_ascii_lowercase()
7272
}
7373
}
7474

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
235235
};
236236

237237
// Transform the contents of the header into a hyphenated string
238-
let id = s.words().map(|s| s.to_ascii_lower())
238+
let id = s.words().map(|s| s.to_ascii_lowercase())
239239
.collect::<Vec<String>>().connect("-");
240240

241241
// This is a terrible hack working around how hoedown gives us rendered

0 commit comments

Comments
 (0)