Skip to content

Rename things in std::ascii for consistency #14436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use std::io::{BufferedReader, File};
use std::ascii::StrAsciiExt;
use regex::Regex;

pub struct ExpectedError {
Expand All @@ -31,7 +32,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
re.captures(line).and_then(|caps| {
let adjusts = caps.name("adjusts").len();
let kind = caps.name("kind").to_ascii().to_lower().into_str().to_string();
let kind = caps.name("kind").to_ascii_lowercase();
let msg = caps.name("msg").trim().to_string();

debug!("line={} kind={} msg={}", line_num, kind, msg);
Expand Down
15 changes: 1 addition & 14 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,22 +801,9 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
format!("{}:{}:", testfile.display(), ee.line)
}).collect::<Vec<String> >();

#[cfg(target_os = "win32")]
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().to_char()
} else {
c
}
} ).collect();
str::from_chars(c.as_slice()).to_string()
}

#[cfg(target_os = "win32")]
fn prefix_matches( line : &str, prefix : &str ) -> bool {
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
line.len() >= prefix.len() && line.slice_to(prefix.len()).eq_ignore_ascii_case(prefix)
}

#[cfg(target_os = "linux")]
Expand Down
3 changes: 2 additions & 1 deletion src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ syn keyword rustEnumVariant Ok Err
"syn keyword rustFunction drop

" Types and traits {{{3
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
syn keyword rustTrait Ascii ToAscii IntoAscii AsciiStr
syn keyword rustTrait AsciiSlice AsciiVec IntoBytes
syn keyword rustTrait ToCStr
syn keyword rustTrait Char
syn keyword rustTrait Clone
Expand Down
32 changes: 19 additions & 13 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,17 +1257,18 @@ macro_rules! iterator {
if self.ptr == self.end {
None
} else {
let old = self.ptr;
self.ptr = if mem::size_of::<T>() == 0 {
if mem::size_of::<T>() == 0 {
// purposefully don't use 'ptr.offset' because for
// vectors with 0-size elements this would return the
// same pointer.
transmute(self.ptr as uint + 1)
self.ptr = transmute(self.ptr as uint + 1);
Some(transmute(1u)) // Use a non-NULL pointer value
} else {
self.ptr.offset(1)
};
let old = self.ptr;
self.ptr = self.ptr.offset(1);

Some(transmute(old))
Some(transmute(old))
}
}
}
}
Expand All @@ -1289,13 +1290,14 @@ macro_rules! iterator {
if self.end == self.ptr {
None
} else {
self.end = if mem::size_of::<T>() == 0 {
// See above for why 'ptr.offset' isn't used
transmute(self.end as uint - 1)
if mem::size_of::<T>() == 0 {
// See above for why `ptr.offset` isn't used
self.end = transmute(self.end as uint - 1);
Some(transmute(1u)) // Use a non-NULL pointer value
} else {
self.end.offset(-1)
};
Some(transmute(self.end))
self.end = self.end.offset(-1);
Some(transmute(self.end))
}
}
}
}
Expand All @@ -1314,7 +1316,11 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
fn idx(&mut self, index: uint) -> Option<&'a T> {
unsafe {
if index < self.indexable() {
transmute(self.ptr.offset(index as int))
if mem::size_of::<T>() == 0 {
Some(transmute(1u)) // Use a non-NULL pointer value
} else {
Some(transmute(self.ptr.offset(index as int)))
}
} else {
None
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/driver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use getopts::{optopt, optmulti, optflag, optflagopt};
use getopts;
use lib::llvm::llvm;
use std::cell::{RefCell};
use std::ascii::StrAsciiExt;


pub struct Config {
Expand Down Expand Up @@ -596,7 +597,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let level_name = lint::level_to_str(*level);

let level_short = level_name.slice_chars(0, 1);
let level_short = level_short.to_ascii().to_upper().into_str();
let level_short = level_short.to_ascii_uppercase();
let flags = matches.opt_strs(level_short.as_slice())
.move_iter()
.collect::<Vec<_>>()
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 @@ -207,7 +207,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.as_slice().words().map(|s| {
match s.to_ascii_opt() {
Some(s) => s.to_lower().into_str().to_string(),
Some(s) => s.to_lowercase().into_str(),
None => s.to_string()
}
}).collect::<Vec<String>>().connect("-")).to_string();
Expand Down
Loading