style: apply rustfmt
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Maybe 2024 changes? Note that we now set `edition = "2024"` explicitly in `rustfmt.toml`. Without this, it seems like it's possible in some cases for rustfmt to run under an older edition's style. Not sure how though.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
40 files+96 added−121 removed
- tests:+30 added−10 removed
- other:+66 added−111 removed
Provenance
- Commit
bb8172f- Tree
00a8717- Author
Andrew Gallant <jamslam@gmail.com>- Committer
Andrew Gallant <jamslam@gmail.com>- Parent
64174b8
40 files changed+96 added−121 removed
This commit is too large to show whole: its files are listed by path, without their changes.
modified:crates/cli/src/hostname.rs+1 added-1 removed
14 unmodified lines15 /// `libc` linked into the program.16 pub fn hostname() -> io::Result<OsString> {17 #[cfg(windows)]18 {19- use winapi_util::sysinfo::{get_computer_name, ComputerNameKind};19+ use winapi_util::sysinfo::{ComputerNameKind, get_computer_name};20 get_computer_name(ComputerNameKind::PhysicalDnsHostname)21 }22 #[cfg(unix)]23 {62 unmodified linesmodified:crates/cli/src/lib.rs+6 added-6 removed
131 unmodified lines132 mod wtr;133 134 pub use crate::{135 decompress::{136- resolve_binary, DecompressionMatcher, DecompressionMatcherBuilder,137- DecompressionReader, DecompressionReaderBuilder,136+ DecompressionMatcher, DecompressionMatcherBuilder,137+ DecompressionReader, DecompressionReaderBuilder, resolve_binary,138 },139 escape::{escape, escape_os, unescape, unescape_os},140 hostname::hostname,141- human::{parse_human_readable_size, ParseSizeError},141+ human::{ParseSizeError, parse_human_readable_size},142 pattern::{143- pattern_from_bytes, pattern_from_os, patterns_from_path,144- patterns_from_reader, patterns_from_stdin, InvalidPatternError,143+ InvalidPatternError, pattern_from_bytes, pattern_from_os,144+ patterns_from_path, patterns_from_reader, patterns_from_stdin,145 },146 process::{CommandError, CommandReader, CommandReaderBuilder},147 wtr::{148- stdout, stdout_buffered_block, stdout_buffered_line, StandardStream,148+ StandardStream, stdout, stdout_buffered_block, stdout_buffered_line,149 },150 };151 152 /// Returns true if and only if stdin is believed to be readable.143 unmodified linesmodified:crates/core/flags/complete/fish.rs+2 added-3 removed
1 /*!2 Provides completions for ripgrep's CLI for the fish shell.3 */4 5-use crate::flags::{defs::FLAGS, CompletionType};5+use crate::flags::{CompletionType, defs::FLAGS};6 7 const TEMPLATE: &'static str = "complete -c rg !SHORT! -l !LONG! -d '!DOC!'";8-const TEMPLATE_NEGATED: &'static str =9- "complete -c rg -l !NEGATED! -n '__rg_contains_opt !LONG! !SHORT!' -d '!DOC!'\n";8+const TEMPLATE_NEGATED: &'static str = "complete -c rg -l !NEGATED! -n '__rg_contains_opt !LONG! !SHORT!' -d '!DOC!'\n";9 10 /// Generate completions for Fish.11 ///12 /// Reference: <https://fishshell.com/docs/current/completions.html>63 unmodified linesmodified:crates/core/flags/complete/powershell.rs+1 added-2 removed
32 unmodified lines33 Sort-Object -Property ListItemText34 }35 ";36 37-const TEMPLATE_FLAG: &'static str =38- "[CompletionResult]::new('!DASH_NAME!', '!NAME!', [CompletionResultType]::ParameterName, '!DOC!')";37+const TEMPLATE_FLAG: &'static str = "[CompletionResult]::new('!DASH_NAME!', '!NAME!', [CompletionResultType]::ParameterName, '!DOC!')";38 39 /// Generate completions for PowerShell.40 ///41 /// Note that these completions are based on what was produced for ripgrep <=1344 unmodified linesmodified:crates/core/flags/doc/help.rs+1 added-1 removed
6 unmodified lines7 */8 9 use std::{collections::BTreeMap, fmt::Write};10 11-use crate::flags::{defs::FLAGS, doc::version, Category, Flag};11+use crate::flags::{Category, Flag, defs::FLAGS, doc::version};12 13 const TEMPLATE_SHORT: &'static str = include_str!("template.short.help");14 const TEMPLATE_LONG: &'static str = include_str!("template.long.help");15 244 unmodified linesmodified:crates/core/flags/doc/man.rs+1 added-1 removed
2 unmodified lines3 */4 5 use std::{collections::BTreeMap, fmt::Write};6 7-use crate::flags::{defs::FLAGS, doc::version, Flag};7+use crate::flags::{Flag, defs::FLAGS, doc::version};8 9 const TEMPLATE: &'static str = include_str!("template.rg.1");10 11 /// Wraps `std::write!` and asserts there is no failure.99 unmodified linesmodified:crates/core/flags/doc/version.rs+1 added-5 removed
167 unmodified lines168 }169 170 /// Returns `+` when `enabled` is `true` and `-` otherwise.171 fn sign(enabled: bool) -> &'static str {172- if enabled {173- "+"174- } else {175- "-"176- }172+ if enabled { "+" } else { "-" }173 }modified:crates/core/flags/config.rs+1 added-1 removed
8 unmodified lines9 ffi::OsString,10 path::{Path, PathBuf},11 };12 13-use bstr::{io::BufReadExt, ByteSlice};13+use bstr::{ByteSlice, io::BufReadExt};14 15 /// Return a sequence of arguments derived from ripgrep rc configuration files.16 pub fn args() -> Vec<OsString> {17 let config_path = match std::env::var_os("RIPGREP_CONFIG_PATH") {153 unmodified linesmodified:crates/core/flags/defs.rs+1 added-1 removed
20 unmodified lines21 22 use {anyhow::Context as AnyhowContext, bstr::ByteVec};23 24 use crate::flags::{25+ Category, Flag, FlagValue,26 lowargs::{27 BinaryMode, BoundaryMode, BufferMode, CaseMode, ColorChoice,28 ContextMode, EncodingMode, EngineChoice, GenerateMode, LoggingMode,29 LowArgs, MmapMode, Mode, PatternSource, SearchMode, SortMode,30 SortModeKind, SpecialMode, TypeChange,31 },31- Category, Flag, FlagValue,32 };33 34 #[cfg(test)]35 use crate::flags::parse::parse_low_raw;7717 unmodified linesmodified:crates/core/flags/hiargs.rs+3 added-7 removed
577 unmodified lines578 SearchMode::FilesWithoutMatch => SummaryKind::PathWithoutMatch,579 SearchMode::Count => SummaryKind::Count,580 SearchMode::CountMatches => SummaryKind::CountMatches,581 SearchMode::JSON => {582- return Printer::JSON(self.printer_json(wtr))582+ return Printer::JSON(self.printer_json(wtr));583 }584 SearchMode::Standard => {585- return Printer::Standard(self.printer_standard(wtr))585+ return Printer::Standard(self.printer_standard(wtr));586 }587 }588 };589 Printer::Summary(self.printer_summary(wtr, summary_kind))218 unmodified lines808 (None, Some(_)) => Ordering::Greater,809 // When both error, we can't distinguish, so treat as equal.810 (None, None) => Ordering::Equal,811 };812- if sort.reverse {813- ordering.reverse()814- } else {815- ordering816- }812+ if sort.reverse { ordering.reverse() } else { ordering }813 });814 Box::new(with_timestamps.into_iter().map(|(s, _)| s))815 }816 661 unmodified linesmodified:crates/core/flags/mod.rs+1 added-1 removed
34 unmodified lines35 },36 },37 hiargs::HiArgs,38 lowargs::{GenerateMode, Mode, SearchMode, SpecialMode},39- parse::{parse, ParseResult},39+ parse::{ParseResult, parse},40 };41 42 mod complete;43 mod config;259 unmodified linesmodified:crates/core/flags/parse.rs+1 added-1 removed
5 unmodified lines6 7 use anyhow::Context;8 9 use crate::flags::{10+ Flag, FlagValue,11 defs::FLAGS,12 hiargs::HiArgs,13 lowargs::{LoggingMode, LowArgs, SpecialMode},13- Flag, FlagValue,14 };15 16 /// The result of parsing CLI arguments.17 ///459 unmodified linesmodified:crates/globset/src/glob.rs+6 added-22 removed
1 use std::fmt::Write;2-use std::path::{is_separator, Path};2+use std::path::{Path, is_separator};3 4 use regex_automata::meta::Regex;5 6-use crate::{new_regex, Candidate, Error, ErrorKind};6+use crate::{Candidate, Error, ErrorKind, new_regex};7 8 /// Describes a matching strategy for a particular pattern.9 ///10 /// This provides a way to more quickly determine whether a pattern matches328 unmodified lines339 for t in &*self.tokens {340 let Token::Literal(c) = *t else { return None };341 lit.push(c);342 }343- if lit.is_empty() {344- None345- } else {346- Some(lit)347- }343+ if lit.is_empty() { None } else { Some(lit) }344 }345 346 /// Returns an extension if this pattern matches a file path if and only347 /// if the file path has the extension returned.32 unmodified lines380 Token::Literal(c) => lit.push(c),381 _ => return None,382 }383 }388- if lit.is_empty() {389- None390- } else {391- Some(lit)392- }384+ if lit.is_empty() { None } else { Some(lit) }385 }386 387 /// This is like `ext`, but returns an extension even if it isn't sufficient388 /// to imply a match. Namely, if an extension is returned, then it is54 unmodified lines443 }444 if need_sep {445 lit.push('/');446 }455- if lit.is_empty() {456- None457- } else {458- Some(lit)459- }447+ if lit.is_empty() { None } else { Some(lit) }448 }449 450 /// Returns a literal suffix of this pattern if the entire pattern matches451 /// if the literal suffix matches.40 unmodified lines492 for t in &self.tokens[start..] {493 let Token::Literal(c) = *t else { return None };494 lit.push(c);495 }508- if lit.is_empty() || lit == "/" {509- None510- } else {511- Some((lit, entire))512- }496+ if lit.is_empty() || lit == "/" { None } else { Some((lit, entire)) }497 }498 499 /// If this pattern only needs to inspect the basename of a file path,500 /// then the tokens corresponding to only the basename match are returned.1186 unmodified linesmodified:crates/globset/src/lib.rs+3 added-7 removed
118 unmodified lines119 };120 121 use {122 aho_corasick::AhoCorasick,123- bstr::{ByteSlice, ByteVec, B},123+ bstr::{B, ByteSlice, ByteVec},124 regex_automata::{125+ PatternSet,126 meta::Regex,127 util::pool::{Pool, PoolGuard},127- PatternSet,128 },129 };130 131 use crate::{501 unmodified lines633 Candidate { path, basename, ext }634 }635 636 fn path_prefix(&self, max: usize) -> &[u8] {637- if self.path.len() <= max {638- &*self.path639- } else {640- &self.path[..max]641- }637+ if self.path.len() <= max { &*self.path } else { &self.path[..max] }638 }639 640 fn path_suffix(&self, max: usize) -> &[u8] {641 if self.path.len() <= max {494 unmodified linesmodified:crates/globset/src/pathutil.rs+1 added-1 removed
86 unmodified lines87 #[cfg(test)]88 mod tests {89 use std::borrow::Cow;90 91- use bstr::{ByteVec, B};91+ use bstr::{B, ByteVec};92 93 use super::{file_name_ext, normalize_path};94 95 macro_rules! ext {38 unmodified linesmodified:crates/ignore/src/dir.rs+1 added-1 removed
889 unmodified lines890 mod tests {891 use std::{io::Write, path::Path};892 893 use crate::{894- dir::IgnoreBuilder, gitignore::Gitignore, tests::TempDir, Error,894+ Error, dir::IgnoreBuilder, gitignore::Gitignore, tests::TempDir,895 };896 897 fn wfile<P: AsRef<Path>>(path: P, contents: &str) {898 let mut file = std::fs::File::create(path).unwrap();349 unmodified linesmodified:crates/ignore/src/gitignore.rs+1 added-1 removed
18 unmodified lines19 regex_automata::util::pool::Pool,20 };21 22 use crate::{23- pathutil::{is_file_name, strip_prefix},23 Error, Match, PartialErrorBuilder,24+ pathutil::{is_file_name, strip_prefix},25 };26 27 /// Glob represents a single glob in a gitignore file.28 ///818 unmodified linesmodified:crates/ignore/src/lib.rs+1 added-5 removed
475 unmodified lines476 }477 478 /// Return the match if it is not none. Otherwise, return other.479 pub fn or(self, other: Self) -> Self {480- if self.is_none() {481- other482- } else {483- self484- }480+ if self.is_none() { other } else { self }481 }482 }483 484 #[cfg(test)]60 unmodified linesmodified:crates/ignore/src/overrides.rs+1 added-1 removed
6 unmodified lines7 8 use std::path::Path;9 10 use crate::{11- gitignore::{self, Gitignore, GitignoreBuilder},11 Error, Match,12+ gitignore::{self, Gitignore, GitignoreBuilder},13 };14 15 /// Glob represents a single glob in an override matcher.16 ///277 unmodified linesmodified:crates/ignore/src/types.rs+1 added-1 removed
89 unmodified lines90 globset::{GlobBuilder, GlobSet, GlobSetBuilder},91 regex_automata::util::pool::Pool,92 };93 94-use crate::{default_types::DEFAULT_TYPES, pathutil::file_name, Error, Match};94+use crate::{Error, Match, default_types::DEFAULT_TYPES, pathutil::file_name};95 96 /// Glob represents a single glob in a set of file type definitions.97 ///98 /// There may be more than one glob for a particular file type.486 unmodified linesmodified:crates/ignore/src/walk.rs+4 added-8 removed
2 unmodified lines3 ffi::OsStr,4 fs::{self, FileType, Metadata},5 io,6 path::{Path, PathBuf},7- sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering},7 sync::Arc,8+ sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering},9 };10 11 use {12 crossbeam_deque::{Stealer, Worker as Deque},1 unmodified line14 walkdir::WalkDir,15 };16 17 use crate::{18+ Error, PartialErrorBuilder,19 dir::{Ignore, IgnoreBuilder},20 gitignore::GitignoreBuilder,21 overrides::Override,22 types::Types,22- Error, PartialErrorBuilder,23 };24 25 /// A directory entry with a possible error attached.26 ///1866 unmodified lines1893 }1894 1895 #[cfg(windows)]1896 fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> {1897- use winapi_util::{file, Handle};1897+ use winapi_util::{Handle, file};1898 1899 let h = Handle::from_path_any(path)?;1900 file::information(h).map(|info| info.volume_serial_number())1901 }37 unmodified lines1939 fs::create_dir_all(path).unwrap();1940 }1941 1942 fn normal_path(unix: &str) -> String {1943- if cfg!(windows) {1944- unix.replace("\\", "/")1945- } else {1946- unix.to_string()1947- }1943+ if cfg!(windows) { unix.replace("\\", "/") } else { unix.to_string() }1944 }1945 1946 fn walk_collect(prefix: &Path, builder: &WalkBuilder) -> Vec<String> {1947 let mut paths = vec![];366 unmodified linesmodified:crates/ignore/tests/gitignore_matched_path_or_any_parents_tests.rs+30 added-10 removed
198 unmodified lines199 // 00200 assert!(m("ROOT/parent_dir/dir_deep_00", true).is_ignore());201 assert!(m("ROOT/parent_dir/dir_deep_00/file", false).is_ignore());202 assert!(m("ROOT/parent_dir/dir_deep_00/child_dir", true).is_ignore());203- assert!(m("ROOT/parent_dir/dir_deep_00/child_dir/file", false).is_ignore());203+ assert!(204+ m("ROOT/parent_dir/dir_deep_00/child_dir/file", false).is_ignore()205+ );206 207 // 01208 assert!(m("ROOT/parent_dir/dir_deep_01", true).is_ignore());209 assert!(m("ROOT/parent_dir/dir_deep_01/file", false).is_ignore());210 assert!(m("ROOT/parent_dir/dir_deep_01/child_dir", true).is_ignore());209- assert!(m("ROOT/parent_dir/dir_deep_01/child_dir/file", false).is_ignore());211+ assert!(212+ m("ROOT/parent_dir/dir_deep_01/child_dir/file", false).is_ignore()213+ );214 215 // 02216 assert!(m("ROOT/parent_dir/dir_deep_02", true).is_none());217 assert!(m("ROOT/parent_dir/dir_deep_02/file", false).is_none());33 unmodified lines251 // 20252 assert!(m("ROOT/parent_dir/dir_deep_20", true).is_ignore());253 assert!(m("ROOT/parent_dir/dir_deep_20/file", false).is_ignore());254 assert!(m("ROOT/parent_dir/dir_deep_20/child_dir", true).is_ignore());251- assert!(m("ROOT/parent_dir/dir_deep_20/child_dir/file", false).is_ignore());255+ assert!(256+ m("ROOT/parent_dir/dir_deep_20/child_dir/file", false).is_ignore()257+ );258 259 // 21260 assert!(m("ROOT/parent_dir/dir_deep_21", true).is_ignore());261 assert!(m("ROOT/parent_dir/dir_deep_21/file", false).is_ignore());262 assert!(m("ROOT/parent_dir/dir_deep_21/child_dir", true).is_ignore());257- assert!(m("ROOT/parent_dir/dir_deep_21/child_dir/file", false).is_ignore());263+ assert!(264+ m("ROOT/parent_dir/dir_deep_21/child_dir/file", false).is_ignore()265+ );266 267 // 22268 // dir itself doesn't match269 assert!(m("ROOT/parent_dir/dir_deep_22", true).is_none());270 assert!(m("ROOT/parent_dir/dir_deep_22/file", false).is_ignore());271 assert!(m("ROOT/parent_dir/dir_deep_22/child_dir", true).is_ignore());264- assert!(m("ROOT/parent_dir/dir_deep_22/child_dir/file", false).is_ignore());272+ assert!(273+ m("ROOT/parent_dir/dir_deep_22/child_dir/file", false).is_ignore()274+ );275 276 // 23277 // dir itself doesn't match278 assert!(m("ROOT/parent_dir/dir_deep_23", true).is_none());279 assert!(m("ROOT/parent_dir/dir_deep_23/file", false).is_ignore());280 assert!(m("ROOT/parent_dir/dir_deep_23/child_dir", true).is_ignore());271- assert!(m("ROOT/parent_dir/dir_deep_23/child_dir/file", false).is_ignore());281+ assert!(282+ m("ROOT/parent_dir/dir_deep_23/child_dir/file", false).is_ignore()283+ );284 285 // 30286 assert!(m("ROOT/parent_dir/dir_deep_30", true).is_ignore());287 assert!(m("ROOT/parent_dir/dir_deep_30/file", false).is_ignore());288 assert!(m("ROOT/parent_dir/dir_deep_30/child_dir", true).is_ignore());277- assert!(m("ROOT/parent_dir/dir_deep_30/child_dir/file", false).is_ignore());289+ assert!(290+ m("ROOT/parent_dir/dir_deep_30/child_dir/file", false).is_ignore()291+ );292 293 // 31294 assert!(m("ROOT/parent_dir/dir_deep_31", true).is_ignore());295 assert!(m("ROOT/parent_dir/dir_deep_31/file", false).is_ignore());296 assert!(m("ROOT/parent_dir/dir_deep_31/child_dir", true).is_ignore());283- assert!(m("ROOT/parent_dir/dir_deep_31/child_dir/file", false).is_ignore());297+ assert!(298+ m("ROOT/parent_dir/dir_deep_31/child_dir/file", false).is_ignore()299+ );300 301 // 32302 // dir itself doesn't match303 assert!(m("ROOT/parent_dir/dir_deep_32", true).is_none());304 assert!(m("ROOT/parent_dir/dir_deep_32/file", false).is_ignore());305 assert!(m("ROOT/parent_dir/dir_deep_32/child_dir", true).is_ignore());290- assert!(m("ROOT/parent_dir/dir_deep_32/child_dir/file", false).is_ignore());306+ assert!(307+ m("ROOT/parent_dir/dir_deep_32/child_dir/file", false).is_ignore()308+ );309 310 // 33311 // dir itself doesn't match312 assert!(m("ROOT/parent_dir/dir_deep_33", true).is_none());313 assert!(m("ROOT/parent_dir/dir_deep_33/file", false).is_ignore());314 assert!(m("ROOT/parent_dir/dir_deep_33/child_dir", true).is_ignore());297- assert!(m("ROOT/parent_dir/dir_deep_33/child_dir/file", false).is_ignore());315+ assert!(316+ m("ROOT/parent_dir/dir_deep_33/child_dir/file", false).is_ignore()317+ );318 }modified:crates/matcher/src/interpolate.rs+1 added-1 removed
142 unmodified lines143 }144 145 #[cfg(test)]146 mod tests {147- use super::{find_cap_ref, interpolate, CaptureRef};147+ use super::{CaptureRef, find_cap_ref, interpolate};148 149 macro_rules! find {150 ($name:ident, $text:expr) => {151 #[test]180 unmodified linesmodified:crates/printer/src/json.rs+3 added-3 removed
12 unmodified lines13 serde_json as json,14 };15 16 use crate::{17- counter::CounterWriter, jsont, stats::Stats,18- util::find_iter_at_in_context, util::Replacer,17+ counter::CounterWriter, jsont, stats::Stats, util::Replacer,18+ util::find_iter_at_in_context,19 };20 21 /// The configuration for the JSON printer.22 ///945 unmodified lines968 use grep_matcher::LineTerminator;969 use grep_regex::{RegexMatcher, RegexMatcherBuilder};970 use grep_searcher::SearcherBuilder;971 972- use super::{JSONBuilder, JSON};972+ use super::{JSON, JSONBuilder};973 974 const SHERLOCK: &'static [u8] = b"\975 For the Doctor Watsons of this world, as opposed to the Sherlock976 Holmeses, success in the province of detective work must always147 unmodified linesmodified:crates/printer/src/lib.rs+4 added-4 removed
59 unmodified lines60 #![deny(missing_docs)]61 #![cfg_attr(docsrs, feature(doc_auto_cfg))]62 63 pub use crate::{64- color::{default_color_specs, ColorError, ColorSpecs, UserColorSpec},64+ color::{ColorError, ColorSpecs, UserColorSpec, default_color_specs},65 hyperlink::{66- hyperlink_aliases, HyperlinkAlias, HyperlinkConfig,67- HyperlinkEnvironment, HyperlinkFormat, HyperlinkFormatError,66+ HyperlinkAlias, HyperlinkConfig, HyperlinkEnvironment,67+ HyperlinkFormat, HyperlinkFormatError, hyperlink_aliases,68 },69 path::{PathPrinter, PathPrinterBuilder},70 standard::{Standard, StandardBuilder, StandardSink},71 stats::Stats,72 summary::{Summary, SummaryBuilder, SummaryKind, SummarySink},73 };74 75 #[cfg(feature = "serde")]76-pub use crate::json::{JSONBuilder, JSONSink, JSON};76+pub use crate::json::{JSON, JSONBuilder, JSONSink};77 78 // The maximum number of bytes to execute a search to account for look-ahead.79 //80 // This is an unfortunate kludge since PCRE2 doesn't provide a way to search23 unmodified linesmodified:crates/printer/src/standard.rs+1 added-1 removed
20 unmodified lines21 counter::CounterWriter,22 hyperlink::{self, HyperlinkConfig},23 stats::Stats,24 util::{25- find_iter_at_in_context, trim_ascii_prefix, trim_line_terminator,25 DecimalFormatter, PrinterPath, Replacer, Sunk,26+ find_iter_at_in_context, trim_ascii_prefix, trim_line_terminator,27 },28 };29 30 /// The configuration for the standard printer.3957 unmodified linesmodified:crates/printer/src/summary.rs+1 added-1 removed
15 unmodified lines16 color::ColorSpecs,17 counter::CounterWriter,18 hyperlink::{self, HyperlinkConfig},19 stats::Stats,20- util::{find_iter_at_in_context, PrinterPath},20+ util::{PrinterPath, find_iter_at_in_context},21 };22 23 /// The configuration for the summary printer.24 ///1153 unmodified linesmodified:crates/printer/src/util.rs+1 added-1 removed
6 unmodified lines7 LineIter, Searcher, SinkContext, SinkContextKind, SinkError, SinkMatch,8 },9 };10 11-use crate::{hyperlink::HyperlinkPath, MAX_LOOK_AHEAD};11+use crate::{MAX_LOOK_AHEAD, hyperlink::HyperlinkPath};12 13 /// A type for handling replacements while amortizing allocation.14 pub(crate) struct Replacer<M: Matcher> {15 space: Option<Space<M>>,587 unmodified linesmodified:crates/regex/src/config.rs+1 added-5 removed
339 unmodified lines340 }341 342 /// Returns the "end line" anchor for this configuration.343 fn line_anchor_end(&self) -> hir::Look {344- if self.config.crlf {345- hir::Look::EndCRLF346- } else {347- hir::Look::EndLF348- }344+ if self.config.crlf { hir::Look::EndCRLF } else { hir::Look::EndLF }345 }346 }347 348 /// Returns true if the given literal string contains any byte from the line8 unmodified linesmodified:crates/regex/src/literal.rs+2 added-7 removed
1 use {2 regex_automata::meta::Regex,3 regex_syntax::hir::{4- self,4+ self, Hir,5 literal::{Literal, Seq},6- Hir,6 },7 };8 9 use crate::{config::ConfiguredHIR, error::Error};211 unmodified lines221 // Note that 'cross' also dispatches based on whether we're222 // extracting prefixes or suffixes.223 seq = self.cross(seq, self.extract(hir));224 }226- if let Some(prev) = prev {227- prev.choose(seq)228- } else {229- seq230- }225+ if let Some(prev) = prev { prev.choose(seq) } else { seq }226 }227 228 /// Extract a sequence from the given alternation.229 ///787 unmodified linesmodified:crates/regex/src/matcher.rs+8 added-6 removed
2 unmodified lines3 ByteSet, Captures, LineMatchKind, LineTerminator, Match, Matcher,4 NoError,5 },6 regex_automata::{7- meta::Regex, util::captures::Captures as AutomataCaptures, Input,8- PatternID,7+ Input, PatternID, meta::Regex,8+ util::captures::Captures as AutomataCaptures,9 },10 };11 12 use crate::{config::Config, error::Error, literal::InnerLiterals};573 unmodified lines586 // Ensure that the builder returns an error if a line terminator is set587 // and the regex could not be modified to remove a line terminator.588 #[test]589 fn line_terminator_error() {590+ assert!(590- assert!(RegexMatcherBuilder::new()591- .line_terminator(Some(b'\n'))592- .build(r"a\nz")593- .is_err())591+ RegexMatcherBuilder::new()592+ .line_terminator(Some(b'\n'))593+ .build(r"a\nz")594+ .is_err()595+ )596 }597 598 // Test that enabling CRLF permits `$` to match at the end of a line.599 #[test]71 unmodified linesmodified:crates/regex/src/strip.rs+1 added-1 removed
120 unmodified lines121 #[cfg(test)]122 mod tests {123 use regex_syntax::Parser;124 125- use super::{strip_from_match, LineTerminator};125+ use super::{LineTerminator, strip_from_match};126 use crate::error::Error;127 128 fn roundtrip(pattern: &str, byte: u8) -> String {129 roundtrip_line_term(pattern, LineTerminator::byte(byte)).unwrap()41 unmodified linesmodified:crates/searcher/examples/search-stdin.rs+2 added-2 removed
2 unmodified lines3 use std::io;4 use std::process;5 6 use grep_regex::RegexMatcher;7-use grep_searcher::sinks::UTF8;7 use grep_searcher::Searcher;8+use grep_searcher::sinks::UTF8;9 10 fn main() {11 if let Err(err) = example() {12 eprintln!("{}", err);4 unmodified lines17 fn example() -> Result<(), Box<dyn Error>> {18 let pattern = match env::args().nth(1) {19 Some(pattern) => pattern,20 None => {21- return Err(From::from(format!("Usage: search-stdin <pattern>")))21+ return Err(From::from(format!("Usage: search-stdin <pattern>")));22 }23 };24 let matcher = RegexMatcher::new(&pattern)?;25 Searcher::new().search_reader(9 unmodified linesmodified:crates/searcher/src/searcher/glue.rsnot shown
Its text is not shown, modified.
modified:crates/searcher/src/searcher/mod.rsnot shown
Its text is not shown, modified.
modified:crates/searcher/src/lib.rs+2 added-2 removed
88 unmodified lines89 BinaryDetection, ConfigError, Encoding, MmapChoice, Searcher,90 SearcherBuilder,91 },92 sink::{93- sinks, Sink, SinkContext, SinkContextKind, SinkError, SinkFinish,94- SinkMatch,93+ Sink, SinkContext, SinkContextKind, SinkError, SinkFinish, SinkMatch,94+ sinks,95 },96 };97 98 #[macro_use]8 unmodified linesmodified:tests/feature.rsnot shown
Its text is not shown, modified.
modified:tests/misc.rsnot shown
Its text is not shown, modified.
modified:tests/regression.rsnot shown
Its text is not shown, modified.
modified:rustfmt.tomlnot shown
Its text is not shown, modified.