Skip to content

Commit 7209b9c

Browse files
authored
Rollup merge of #75856 - matthiaskrgr:more_clippy, r=Dylan-DPC
more tool clippy fixes r? @Dylan-DPC
2 parents 648ad7c + a725001 commit 7209b9c

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

src/tools/expand-yaml-anchors/src/main.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl App {
4848
// Parse CLI arguments
4949
let args = std::env::args().skip(1).collect::<Vec<_>>();
5050
let (mode, base) = match args.iter().map(|s| s.as_str()).collect::<Vec<_>>().as_slice() {
51-
&["generate", ref base] => (Mode::Generate, PathBuf::from(base)),
52-
&["check", ref base] => (Mode::Check, PathBuf::from(base)),
51+
["generate", ref base] => (Mode::Generate, PathBuf::from(base)),
52+
["check", ref base] => (Mode::Check, PathBuf::from(base)),
5353
_ => {
5454
eprintln!("usage: expand-yaml-anchors <source-dir> <dest-dir>");
5555
std::process::exit(1);
@@ -138,9 +138,7 @@ fn filter_document(document: Yaml) -> Yaml {
138138
.map(|(key, value)| (filter_document(key), filter_document(value)))
139139
.collect(),
140140
),
141-
Yaml::Array(vec) => {
142-
Yaml::Array(vec.into_iter().map(|item| filter_document(item)).collect())
143-
}
141+
Yaml::Array(vec) => Yaml::Array(vec.into_iter().map(filter_document).collect()),
144142
other => other,
145143
}
146144
}

src/tools/linkchecker/main.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti
172172
{
173173
return;
174174
}
175-
let mut parts = url.splitn(2, "#");
175+
let mut parts = url.splitn(2, '#');
176176
let url = parts.next().unwrap();
177177
let fragment = parts.next();
178-
let mut parts = url.splitn(2, "?");
178+
let mut parts = url.splitn(2, '?');
179179
let url = parts.next().unwrap();
180180

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

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

@@ -324,7 +324,7 @@ fn load_file(
324324
}
325325

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

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

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

364-
if rest[..pos_quote].trim_start_matches(" ") != "" {
364+
if rest[..pos_quote].trim_start_matches(' ') != "" {
365365
continue;
366366
}
367367
let rest = &rest[pos_quote + 1..];

src/tools/tidy/src/error_codes_check.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ fn check_error_code_explanation(
4747
invalid_compile_fail_format
4848
}
4949

50-
fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &String) -> bool {
51-
let mut can_be_ignored = false;
52-
50+
fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool {
5351
for line in f.lines() {
5452
let s = line.trim();
5553
if s.starts_with("#### Note: this error code is no longer emitted by the compiler") {
@@ -58,13 +56,13 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &String) -> boo
5856
if s.starts_with("```") {
5957
if s.contains("compile_fail") && s.contains(err_code) {
6058
return true;
61-
} else if s.contains("(") {
59+
} else if s.contains('(') {
6260
// It's very likely that we can't actually make it fail compilation...
63-
can_be_ignored = true;
61+
return true;
6462
}
6563
}
6664
}
67-
can_be_ignored
65+
false
6866
}
6967

7068
macro_rules! some_or_continue {

src/tools/unicode-table-generator/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn version() -> String {
315315
fn fmt_list<V: std::fmt::Debug>(values: impl IntoIterator<Item = V>) -> String {
316316
let pieces = values.into_iter().map(|b| format!("{:?}, ", b)).collect::<Vec<_>>();
317317
let mut out = String::new();
318-
let mut line = format!("\n ");
318+
let mut line = String::from("\n ");
319319
for piece in pieces {
320320
if line.len() + piece.len() < 98 {
321321
line.push_str(&piece);

src/tools/unicode-table-generator/src/raw_emitter.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl RawEmitter {
2020
if self.file.is_empty() || self.file.ends_with("\n\n") {
2121
return;
2222
}
23-
writeln!(&mut self.file, "").unwrap();
23+
writeln!(&mut self.file).unwrap();
2424
}
2525

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

162162
if bitset.bytes_used <= skiplist.bytes_used {
163163
*emitter = bitset;
164-
emitter.desc = format!("bitset");
164+
emitter.desc = String::from("bitset");
165165
} else {
166166
*emitter = skiplist;
167-
emitter.desc = format!("skiplist");
167+
emitter.desc = String::from("skiplist");
168168
}
169169
}
170170

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

310310
// Remove the now-canonical word from other mappings, to ensure that
311311
// we deprioritize them in the next iteration of the while loop.
312-
for (_, mapped) in &mut mappings {
312+
for mapped in mappings.values_mut() {
313313
let mut i = 0;
314314
while i != mapped.len() {
315315
if mapped[i].0 == to {

src/tools/unstable-book-gen/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ fn copy_recursive(from: &Path, to: &Path) {
9494
}
9595

9696
fn main() {
97-
let library_path_str = env::args_os().skip(1).next().expect("library path required");
98-
let src_path_str = env::args_os().skip(2).next().expect("source path required");
99-
let dest_path_str = env::args_os().skip(3).next().expect("destination path required");
97+
let library_path_str = env::args_os().nth(1).expect("library path required");
98+
let src_path_str = env::args_os().nth(2).expect("source path required");
99+
let dest_path_str = env::args_os().nth(3).expect("destination path required");
100100
let library_path = Path::new(&library_path_str);
101101
let src_path = Path::new(&src_path_str);
102102
let dest_path = Path::new(&dest_path_str);

0 commit comments

Comments
 (0)