From 5370064f00856b781c468aabfeaa875408171e03 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 21 Mar 2022 08:31:49 -0400 Subject: warnings: remove/tweak some dead code It looks like the dead code detector got better, so do a little code cleanup. --- crates/globset/src/glob.rs | 4 +--- crates/ignore/src/types.rs | 12 ++---------- crates/searcher/src/searcher/core.rs | 3 +++ crates/searcher/src/searcher/glue.rs | 2 -- crates/searcher/src/sink.rs | 1 + 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/crates/globset/src/glob.rs b/crates/globset/src/glob.rs index 71cd8bbb..6e35aeec 100644 --- a/crates/globset/src/glob.rs +++ b/crates/globset/src/glob.rs @@ -143,8 +143,6 @@ impl GlobMatcher { struct GlobStrategic { /// The match strategy to use. strategy: MatchStrategy, - /// The underlying pattern. - pat: Glob, /// The pattern, as a compiled regex. re: Regex, } @@ -273,7 +271,7 @@ impl Glob { let strategy = MatchStrategy::new(self); let re = new_regex(&self.re).expect("regex compilation shouldn't fail"); - GlobStrategic { strategy: strategy, pat: self.clone(), re: re } + GlobStrategic { strategy: strategy, re: re } } /// Returns the original glob pattern used to build this pattern. diff --git a/crates/ignore/src/types.rs b/crates/ignore/src/types.rs index efb9a8d9..616a8d21 100644 --- a/crates/ignore/src/types.rs +++ b/crates/ignore/src/types.rs @@ -122,10 +122,6 @@ enum GlobInner<'a> { Matched { /// The file type definition which provided the glob. def: &'a FileTypeDef, - /// The index of the glob that matched inside the file type definition. - which: usize, - /// Whether the selection was negated or not. - negated: bool, }, } @@ -291,13 +287,9 @@ impl Types { self.set.matches_into(name, &mut *matches); // The highest precedent match is the last one. if let Some(&i) = matches.last() { - let (isel, iglob) = self.glob_to_selection[i]; + let (isel, _) = self.glob_to_selection[i]; let sel = &self.selections[isel]; - let glob = Glob(GlobInner::Matched { - def: sel.inner(), - which: iglob, - negated: sel.is_negated(), - }); + let glob = Glob(GlobInner::Matched { def: sel.inner() }); return if sel.is_negated() { Match::Ignore(glob) } else { diff --git a/crates/searcher/src/searcher/core.rs b/crates/searcher/src/searcher/core.rs index b6deda01..7d6ccd66 100644 --- a/crates/searcher/src/searcher/core.rs +++ b/crates/searcher/src/searcher/core.rs @@ -467,6 +467,7 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> { let keepgoing = self.sink.context( &self.searcher, &SinkContext { + #[cfg(test)] line_term: self.config.line_term, bytes: &buf[*range], kind: SinkContextKind::Before, @@ -497,6 +498,7 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> { let keepgoing = self.sink.context( &self.searcher, &SinkContext { + #[cfg(test)] line_term: self.config.line_term, bytes: &buf[*range], kind: SinkContextKind::After, @@ -526,6 +528,7 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> { let keepgoing = self.sink.context( &self.searcher, &SinkContext { + #[cfg(test)] line_term: self.config.line_term, bytes: &buf[*range], kind: SinkContextKind::Other, diff --git a/crates/searcher/src/searcher/glue.rs b/crates/searcher/src/searcher/glue.rs index 21a58aa4..1ff208bc 100644 --- a/crates/searcher/src/searcher/glue.rs +++ b/crates/searcher/src/searcher/glue.rs @@ -88,7 +88,6 @@ where #[derive(Debug)] pub struct SliceByLine<'s, M, S> { - config: &'s Config, core: Core<'s, M, S>, slice: &'s [u8], } @@ -103,7 +102,6 @@ impl<'s, M: Matcher, S: Sink> SliceByLine<'s, M, S> { debug_assert!(!searcher.multi_line_with_matcher(&matcher)); SliceByLine { - config: &searcher.config, core: Core::new(searcher, matcher, write_to, true), slice: slice, } diff --git a/crates/searcher/src/sink.rs b/crates/searcher/src/sink.rs index 41f425cc..e82634cd 100644 --- a/crates/searcher/src/sink.rs +++ b/crates/searcher/src/sink.rs @@ -436,6 +436,7 @@ pub enum SinkContextKind { /// A type that describes a contextual line reported by a searcher. #[derive(Clone, Debug)] pub struct SinkContext<'b> { + #[cfg(test)] pub(crate) line_term: LineTerminator, pub(crate) bytes: &'b [u8], pub(crate) kind: SinkContextKind, -- cgit v1.2.3