Skip to content

more tool clippy fixes #75856

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

Merged
merged 5 commits into from
Aug 24, 2020
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
8 changes: 3 additions & 5 deletions src/tools/expand-yaml-anchors/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ impl App {
// Parse CLI arguments
let args = std::env::args().skip(1).collect::<Vec<_>>();
let (mode, base) = match args.iter().map(|s| s.as_str()).collect::<Vec<_>>().as_slice() {
&["generate", ref base] => (Mode::Generate, PathBuf::from(base)),
&["check", ref base] => (Mode::Check, PathBuf::from(base)),
["generate", ref base] => (Mode::Generate, PathBuf::from(base)),
["check", ref base] => (Mode::Check, PathBuf::from(base)),
_ => {
eprintln!("usage: expand-yaml-anchors <source-dir> <dest-dir>");
std::process::exit(1);
Expand Down Expand Up @@ -138,9 +138,7 @@ fn filter_document(document: Yaml) -> Yaml {
.map(|(key, value)| (filter_document(key), filter_document(value)))
.collect(),
),
Yaml::Array(vec) => {
Yaml::Array(vec.into_iter().map(|item| filter_document(item)).collect())
}
Yaml::Array(vec) => Yaml::Array(vec.into_iter().map(filter_document).collect()),
other => other,
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/tools/linkchecker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti
{
return;
}
let mut parts = url.splitn(2, "#");
let mut parts = url.splitn(2, '#');
let url = parts.next().unwrap();
let fragment = parts.next();
let mut parts = url.splitn(2, "?");
let mut parts = url.splitn(2, '?');
let url = parts.next().unwrap();

// Once we've plucked out the URL, parse it using our base url and
Expand Down Expand Up @@ -258,7 +258,7 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti
}

// These appear to be broken in mdbook right now?
if fragment.starts_with("-") {
if fragment.starts_with('-') {
return;
}

Expand Down Expand Up @@ -324,7 +324,7 @@ fn load_file(
}

fn maybe_redirect(source: &str) -> Option<String> {
const REDIRECT: &'static str = "<p>Redirecting to <a href=";
const REDIRECT: &str = "<p>Redirecting to <a href=";

let mut lines = source.lines();
let redirect_line = lines.nth(6)?;
Expand All @@ -345,11 +345,11 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
// we can get away with using one pass.
let is_base = line[..j].ends_with("<base");
line = rest;
let pos_equals = match rest.find("=") {
let pos_equals = match rest.find('=') {
Some(i) => i,
None => continue,
};
if rest[..pos_equals].trim_start_matches(" ") != "" {
if rest[..pos_equals].trim_start_matches(' ') != "" {
continue;
}

Expand All @@ -361,7 +361,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
};
let quote_delim = rest.as_bytes()[pos_quote] as char;

if rest[..pos_quote].trim_start_matches(" ") != "" {
if rest[..pos_quote].trim_start_matches(' ') != "" {
continue;
}
let rest = &rest[pos_quote + 1..];
Expand Down
10 changes: 4 additions & 6 deletions src/tools/tidy/src/error_codes_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ fn check_error_code_explanation(
invalid_compile_fail_format
}

fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &String) -> bool {
let mut can_be_ignored = false;

fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool {
for line in f.lines() {
let s = line.trim();
if s.starts_with("#### Note: this error code is no longer emitted by the compiler") {
Expand All @@ -58,13 +56,13 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &String) -> boo
if s.starts_with("```") {
if s.contains("compile_fail") && s.contains(err_code) {
return true;
} else if s.contains("(") {
} else if s.contains('(') {
// It's very likely that we can't actually make it fail compilation...
can_be_ignored = true;
return true;
}
}
}
can_be_ignored
false
}

macro_rules! some_or_continue {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/unicode-table-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ fn version() -> String {
fn fmt_list<V: std::fmt::Debug>(values: impl IntoIterator<Item = V>) -> String {
let pieces = values.into_iter().map(|b| format!("{:?}, ", b)).collect::<Vec<_>>();
let mut out = String::new();
let mut line = format!("\n ");
let mut line = String::from("\n ");
for piece in pieces {
if line.len() + piece.len() < 98 {
line.push_str(&piece);
Expand Down
10 changes: 5 additions & 5 deletions src/tools/unicode-table-generator/src/raw_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl RawEmitter {
if self.file.is_empty() || self.file.ends_with("\n\n") {
return;
}
writeln!(&mut self.file, "").unwrap();
writeln!(&mut self.file).unwrap();
}

fn emit_bitset(&mut self, ranges: &[Range<u32>]) {
Expand Down Expand Up @@ -161,10 +161,10 @@ pub fn emit_codepoints(emitter: &mut RawEmitter, ranges: &[Range<u32>]) {

if bitset.bytes_used <= skiplist.bytes_used {
*emitter = bitset;
emitter.desc = format!("bitset");
emitter.desc = String::from("bitset");
} else {
*emitter = skiplist;
emitter.desc = format!("skiplist");
emitter.desc = String::from("skiplist");
}
}

Expand Down Expand Up @@ -289,7 +289,7 @@ impl Canonicalized {
// Remove the now-canonicalized word from other mappings,
// to ensure that we deprioritize them in the next iteration of
// the while loop.
for (_, mapped) in &mut mappings {
for mapped in mappings.values_mut() {
let mut i = 0;
while i != mapped.len() {
if mapped[i].0 == *from {
Expand All @@ -309,7 +309,7 @@ impl Canonicalized {

// Remove the now-canonical word from other mappings, to ensure that
// we deprioritize them in the next iteration of the while loop.
for (_, mapped) in &mut mappings {
for mapped in mappings.values_mut() {
let mut i = 0;
while i != mapped.len() {
if mapped[i].0 == to {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/unstable-book-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ fn copy_recursive(from: &Path, to: &Path) {
}

fn main() {
let library_path_str = env::args_os().skip(1).next().expect("library path required");
let src_path_str = env::args_os().skip(2).next().expect("source path required");
let dest_path_str = env::args_os().skip(3).next().expect("destination path required");
let library_path_str = env::args_os().nth(1).expect("library path required");
let src_path_str = env::args_os().nth(2).expect("source path required");
let dest_path_str = env::args_os().nth(3).expect("destination path required");
let library_path = Path::new(&library_path_str);
let src_path = Path::new(&src_path_str);
let dest_path = Path::new(&dest_path_str);
Expand Down