Update for new rustfmt
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by David Peter · parent 9628d7f · Browse files · 7 files·+22 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+22 added−13 removed
- tests:+4 added−2 removed
- other:+18 added−11 removed
Provenance
- Commit
c1ef686- Tree
1d7a087- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
9628d7f
7 files changed+22 added−13 removed
modified:src/app.rs+2 added-2 removed
13 unmodified lines14 long: &'static str,15 }16 17 macro_rules! doc {18- ($map: expr, $name: expr, $short: expr) => {18+ ($map:expr, $name:expr, $short:expr) => {19 doc!($map, $name, $short, $short)20 };21- ($map: expr, $name: expr, $short: expr, $long: expr) => {21+ ($map:expr, $name:expr, $short:expr, $long:expr) => {22 $map.insert(23 $name,24 Help {25 short: $short,258 unmodified linesmodified:src/main.rs+7 added-4 removed
35 unmodified lines36 use atty::Stream;37 use regex::{RegexBuilder, RegexSetBuilder};38 39 use exec::CommandTemplate;40-use internal::{error, pattern_has_uppercase_char, transform_args_with_exec, FdOptions, FileTypes,41- SizeFilter};40+use internal::{41+ error, pattern_has_uppercase_char, transform_args_with_exec, FdOptions, FileTypes, SizeFilter,42+};43 use lscolors::LsColors;44 45 fn main() {46 let checked_args = transform_args_with_exec(env::args_os());37 unmodified lines84 .collect();85 }86 87 // Detect if the user accidentally supplied a path instead of a search pattern87- if !matches.is_present("full-path") && pattern.contains(std::path::MAIN_SEPARATOR)88+ if !matches.is_present("full-path")89+ && pattern.contains(std::path::MAIN_SEPARATOR)90 && fshelper::is_dir(Path::new(pattern))91 {92 error(&format!(93 "Error: The search pattern '{pattern}' contains a path-separation character ('{sep}') \96 unmodified lines190 }191 file_types192 }),193 extensions: matches.values_of("extension").map(|exts| {192- let patterns = exts.map(|e| e.trim_left_matches('.'))194+ let patterns = exts195+ .map(|e| e.trim_left_matches('.'))196 .map(|e| format!(r".\.{}$", regex::escape(e)));197 match RegexSetBuilder::new(patterns)198 .case_insensitive(true)199 .build()32 unmodified linesmodified:src/output.rs+6 added-3 removed
103 unmodified lines104 write!(&mut io::stdout(), "{}{}", path_str, separator)105 }106 107 fn get_path_style<'a>(path: &Path, ls_colors: &'a LsColors) -> Option<&'a ansi_term::Style> {108+ if path108- if path.symlink_metadata()109+ .symlink_metadata()110 .map(|md| md.file_type().is_symlink())111 .unwrap_or(false)112 {113 return Some(&ls_colors.symlink);4 unmodified lines118 if metadata.as_ref().map(|md| md.is_dir()).unwrap_or(false) {119 Some(&ls_colors.directory)120 } else if metadata.map(|md| is_executable(&md)).unwrap_or(false) {121 Some(&ls_colors.executable)121- } else if let Some(filename_style) = path.file_name()122+ } else if let Some(filename_style) = path123+ .file_name()124 .and_then(|n| n.to_str())125 .and_then(|n| ls_colors.filenames.get(n))126 {127 Some(filename_style)126- } else if let Some(extension_style) = path.extension()128+ } else if let Some(extension_style) = path129+ .extension()130 .and_then(|e| e.to_str())131 .and_then(|e| ls_colors.extensions.get(e))132 {133 Some(extension_style)4 unmodified linesmodified:src/walk.rs+2 added-1 removed
222 unmodified lines223 && !fshelper::is_executable(&entry.metadata().unwrap())224 && file_types.executables_only)225 {226 return ignore::WalkState::Continue;227- } else if !(entry_type.is_file() || entry_type.is_dir()227+ } else if !(entry_type.is_file()228+ || entry_type.is_dir()229 || entry_type.is_symlink())230 {231 // This is probably a block device, char device, fifo or socket. Skip it.232 return ignore::WalkState::Continue;70 unmodified linesmodified:tests/testenv/mod.rs+2 added-1 removed
118 unmodified lines119 120 /// Normalize the output for comparison.121 fn normalize_output(s: &str, trim_left: bool) -> String {122 // Split into lines and normalize separators.123- let mut lines = s.replace('\0', "NULL\n")123+ let mut lines = s124+ .replace('\0', "NULL\n")125 .lines()126 .map(|line| {127 let line =128 if trim_left { line.trim_left() } else { line };67 unmodified linesmodified:tests/tests.rs+2 added-1 removed
31 unmodified lines32 "e1 e2",33 ];34 35 fn get_absolute_root_path(env: &TestEnv) -> String {36- let path = env.test_root()36+ let path = env37+ .test_root()38 .canonicalize()39 .expect("absolute path")40 .to_str()41 .expect("string")1043 unmodified linesmodified:.travis.yml+1 added-1 removed
78 unmodified lines7980818283838485868754 unmodified lines78 unmodified lines rust: nightly # skip the global install step install: - cargo install --debug --force rustfmt-nightly script: cargo fmt -- --write-mode=diff script: cargo fmt -- --check
addons: apt: packages:54 unmodified lines