Skip to content

Commit

Permalink
auto merge of #19916 : SimonSapin/rust/ascii-reform, r=sfackler
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
bors committed Dec 27, 2014
2 parents 0201334 + 12e6071 commit 070ab63
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 616 deletions.
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn parse_expected(last_nonfollow_error: Option<uint>,
re: &Regex) -> Option<(WhichLine, ExpectedError)> {
re.captures(line).and_then(|caps| {
let adjusts = caps.name("adjusts").unwrap_or("").len();
let kind = caps.name("kind").unwrap_or("").to_ascii_lower();
let kind = caps.name("kind").unwrap_or("").to_ascii_lowercase();
let msg = caps.name("msg").unwrap_or("").trim().to_string();
let follow = caps.name("follow").unwrap_or("").len() > 0;

Expand Down
17 changes: 3 additions & 14 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use util::logv;
#[cfg(target_os = "windows")]
use util;

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

#[cfg(target_os = "windows")]
fn to_lower( s : &str ) -> String {
let i = s.chars();
let c : Vec<char> = i.map( |c| {
if c.is_ascii() {
c.to_ascii().to_lowercase().as_char()
} else {
c
}
} ).collect();
String::from_chars(c.as_slice())
}

#[cfg(windows)]
fn prefix_matches( line : &str, prefix : &str ) -> bool {
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
line.to_ascii_lowercase().starts_with(prefix.to_ascii_lowercase().as_slice())
}

#[cfg(unix)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct Lint {
impl Lint {
/// Get the lint's name, with ASCII letters converted to lowercase.
pub fn name_lower(&self) -> String {
self.name.to_ascii_lower()
self.name.to_ascii_lowercase()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
};

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

// This is a terrible hack working around how hoedown gives us rendered
Expand Down
Loading

0 comments on commit 070ab63

Please sign in to comment.