Skip to content
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

Change single char str patterns to chars #52646

Merged
merged 1 commit into from
Jul 24, 2018
Merged
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
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl DepNodeFilter {
/// Tests whether `node` meets the filter, returning true if so.
pub fn test(&self, node: &DepNode) -> bool {
let debug_str = format!("{:?}", node);
self.text.split("&")
self.text.split('&')
.map(|s| s.trim())
.all(|f| debug_str.contains(f))
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
&attr::Stable {since: stab_since}) = (&stab.rustc_depr, &stab.level) {
// Explicit version of iter::order::lt to handle parse errors properly
for (dep_v, stab_v) in
dep_since.as_str().split(".").zip(stab_since.as_str().split(".")) {
dep_since.as_str().split('.').zip(stab_since.as_str().split('.')) {
if let (Ok(dep_v), Ok(stab_v)) = (dep_v.parse::<u64>(), stab_v.parse()) {
match dep_v.cmp(&stab_v) {
Ordering::Less => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/util/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ pub fn dump_enabled<'a, 'gcx, 'tcx>(
// see notes on #41697 below
tcx.item_path_str(source.def_id)
});
filters.split("|").any(|or_filter| {
or_filter.split("&").all(|and_filter| {
filters.split('|').any(|or_filter| {
or_filter.split('&').all(|and_filter| {
and_filter == "all" || pass_name.contains(and_filter) || node_path.contains(and_filter)
})
})
Expand Down Expand Up @@ -388,7 +388,7 @@ struct ExtraComments<'cx, 'gcx: 'tcx, 'tcx: 'cx> {

impl<'cx, 'gcx, 'tcx> ExtraComments<'cx, 'gcx, 'tcx> {
fn push(&mut self, lines: &str) {
for line in lines.split("\n") {
for line in lines.split('\n') {
self.comments.push(line.to_string());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_target/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl TargetDataLayout {

let mut dl = TargetDataLayout::default();
let mut i128_align_src = 64;
for spec in target.data_layout.split("-") {
match &spec.split(":").collect::<Vec<_>>()[..] {
for spec in target.data_layout.split('-') {
match &spec.split(':').collect::<Vec<_>>()[..] {
&["e"] => dl.endian = Endian::Little,
&["E"] => dl.endian = Endian::Big,
&["a", ref a..] => dl.aggregate_align = align(a, "a")?,
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/redox/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ impl Iterator for LookupHost {
pub fn lookup_host(host: &str) -> Result<LookupHost> {
let mut ip_string = String::new();
File::open("/etc/net/ip")?.read_to_string(&mut ip_string)?;
let ip: Vec<u8> = ip_string.trim().split(".").map(|part| part.parse::<u8>()
let ip: Vec<u8> = ip_string.trim().split('.').map(|part| part.parse::<u8>()
.unwrap_or(0)).collect();

let mut dns_string = String::new();
File::open("/etc/net/dns")?.read_to_string(&mut dns_string)?;
let dns: Vec<u8> = dns_string.trim().split(".").map(|part| part.parse::<u8>()
let dns: Vec<u8> = dns_string.trim().split('.').map(|part| part.parse::<u8>()
.unwrap_or(0)).collect();

if ip.len() == 4 && dns.len() == 4 {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fn glibc_version_cstr() -> Option<&'static CStr> {
// ignoring any extra dot-separated parts. Otherwise return None.
#[cfg(target_env = "gnu")]
fn parse_glibc_version(version: &str) -> Option<(usize, usize)> {
let mut parsed_ints = version.split(".").map(str::parse::<usize>).fuse();
let mut parsed_ints = version.split('.').map(str::parse::<usize>).fuse();
match (parsed_ints.next(), parsed_ints.next()) {
(Some(Ok(major)), Some(Ok(minor))) => Some((major, minor)),
_ => None
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'a> Crate<'a> {
impl<'a> CrateVersion<'a> {
/// Returns the struct and whether or not the dep is in-tree
pub fn from_str(s: &'a str) -> (Self, bool) {
let mut parts = s.split(" ");
let mut parts = s.split(' ');
let name = parts.next().unwrap();
let version = parts.next().unwrap();
let path = parts.next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
None
} else {
next_feature_is_rustc_internal = false;
let s = issue_str.split("(").nth(1).unwrap().split(")").nth(0).unwrap();
let s = issue_str.split('(').nth(1).unwrap().split(')').nth(0).unwrap();
Some(s.parse().unwrap())
};
Some((name.to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn check(path: &Path, bad: &mut bool) {
let skip_length = contents.contains("ignore-tidy-linelength");
let skip_end_whitespace = contents.contains("ignore-tidy-end-whitespace");
let mut trailing_new_lines = 0;
for (i, line) in contents.split("\n").enumerate() {
for (i, line) in contents.split('\n').enumerate() {
let mut err = |msg: &str| {
tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg);
};
Expand Down