Merge pull request #2794 from jfinkels/nightly-clippy-fixes

fixes suggested by nightly version of clippy
This commit is contained in:
Sylvestre Ledru 2021-12-27 19:50:08 +01:00 committed by GitHub
commit f7584cb755
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 23 deletions

View file

@ -18,7 +18,7 @@ pub fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
// println!("cargo:warning=out_dir={}", out_dir);
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap().replace("\\", "/");
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap().replace('\\', "/");
// println!("cargo:warning=manifest_dir={}", manifest_dir);
let util_tests_dir = format!("{}/tests/by-util", manifest_dir);
// println!("cargo:warning=util_tests_dir={}", util_tests_dir);

View file

@ -462,7 +462,7 @@ fn numbered_backup_path(path: &Path) -> PathBuf {
}
fn existing_backup_path(path: &Path, suffix: &str) -> PathBuf {
let test_path = simple_backup_path(path, &".~1~".to_owned());
let test_path = simple_backup_path(path, ".~1~");
if test_path.exists() {
return numbered_backup_path(path);
}

View file

@ -45,13 +45,13 @@ impl<'a> Iterator for WhitespaceSplitter<'a> {
let (prefix, field) = haystack.split_at(
haystack
.find(|c: char| !c.is_whitespace())
.unwrap_or_else(|| haystack.len()),
.unwrap_or(haystack.len()),
);
let (field, rest) = field.split_at(
field
.find(|c: char| c.is_whitespace())
.unwrap_or_else(|| field.len()),
.unwrap_or(field.len()),
);
self.s = if !rest.is_empty() { Some(rest) } else { None };
@ -269,7 +269,7 @@ fn format_and_print_whitespace(s: &str, options: &NumfmtOptions) -> Result<()> {
print!(" ");
&prefix[1..]
} else {
&prefix
prefix
};
let implicit_padding = if !empty_prefix && options.padding == 0 {

View file

@ -151,5 +151,5 @@ fn unescape(s: String) -> String {
s.replace("\\n", "\n")
.replace("\\t", "\t")
.replace("\\\\", "\\")
.replace("\\", "")
.replace('\\', "")
}

View file

@ -916,8 +916,7 @@ fn read_stream_and_create_pages(
Box::new(
lines
.map(split_lines_if_form_feed)
.flatten()
.flat_map(split_lines_if_form_feed)
.enumerate()
.map(move |(i, line)| FileLine {
line_number: i + start_line_number,
@ -982,20 +981,18 @@ fn mpr(paths: &[String], options: &OutputOptions) -> Result<i32, PrError> {
.map(|(i, path)| {
let lines = BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()).lines();
read_stream_and_create_pages(options, lines, i)
.map(move |(x, line)| {
let file_line = line;
let page_number = x + 1;
file_line
.into_iter()
.map(|fl| FileLine {
page_number,
group_key: page_number * n_files + fl.file_id,
..fl
})
.collect::<Vec<_>>()
})
.flatten()
read_stream_and_create_pages(options, lines, i).flat_map(move |(x, line)| {
let file_line = line;
let page_number = x + 1;
file_line
.into_iter()
.map(|fl| FileLine {
page_number,
group_key: page_number * n_files + fl.file_id,
..fl
})
.collect::<Vec<_>>()
})
})
.kmerge_by(|a, b| {
if a.group_key == b.group_key {

View file

@ -526,7 +526,7 @@ fn format_tex_line(
}
fn format_roff_field(s: &str) -> String {
s.replace("\"", "\"\"")
s.replace('\"', "\"\"")
}
fn format_roff_line(

View file

@ -125,11 +125,13 @@ impl<R: Read> Data<R> {
}
}
#[must_use]
pub fn line_wrap(mut self, wrap: usize) -> Self {
self.line_wrap = wrap;
self
}
#[must_use]
pub fn ignore_garbage(mut self, ignore: bool) -> Self {
self.ignore_garbage = ignore;
self