mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-20 14:43:47 -07:00
warnings: remove/tweak some dead code
It looks like the dead code detector got better, so do a little code cleanup.
This commit is contained in:
@@ -143,8 +143,6 @@ impl GlobMatcher {
|
|||||||
struct GlobStrategic {
|
struct GlobStrategic {
|
||||||
/// The match strategy to use.
|
/// The match strategy to use.
|
||||||
strategy: MatchStrategy,
|
strategy: MatchStrategy,
|
||||||
/// The underlying pattern.
|
|
||||||
pat: Glob,
|
|
||||||
/// The pattern, as a compiled regex.
|
/// The pattern, as a compiled regex.
|
||||||
re: Regex,
|
re: Regex,
|
||||||
}
|
}
|
||||||
@@ -273,7 +271,7 @@ impl Glob {
|
|||||||
let strategy = MatchStrategy::new(self);
|
let strategy = MatchStrategy::new(self);
|
||||||
let re =
|
let re =
|
||||||
new_regex(&self.re).expect("regex compilation shouldn't fail");
|
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.
|
/// Returns the original glob pattern used to build this pattern.
|
||||||
|
@@ -122,10 +122,6 @@ enum GlobInner<'a> {
|
|||||||
Matched {
|
Matched {
|
||||||
/// The file type definition which provided the glob.
|
/// The file type definition which provided the glob.
|
||||||
def: &'a FileTypeDef,
|
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);
|
self.set.matches_into(name, &mut *matches);
|
||||||
// The highest precedent match is the last one.
|
// The highest precedent match is the last one.
|
||||||
if let Some(&i) = matches.last() {
|
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 sel = &self.selections[isel];
|
||||||
let glob = Glob(GlobInner::Matched {
|
let glob = Glob(GlobInner::Matched { def: sel.inner() });
|
||||||
def: sel.inner(),
|
|
||||||
which: iglob,
|
|
||||||
negated: sel.is_negated(),
|
|
||||||
});
|
|
||||||
return if sel.is_negated() {
|
return if sel.is_negated() {
|
||||||
Match::Ignore(glob)
|
Match::Ignore(glob)
|
||||||
} else {
|
} else {
|
||||||
|
@@ -467,6 +467,7 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> {
|
|||||||
let keepgoing = self.sink.context(
|
let keepgoing = self.sink.context(
|
||||||
&self.searcher,
|
&self.searcher,
|
||||||
&SinkContext {
|
&SinkContext {
|
||||||
|
#[cfg(test)]
|
||||||
line_term: self.config.line_term,
|
line_term: self.config.line_term,
|
||||||
bytes: &buf[*range],
|
bytes: &buf[*range],
|
||||||
kind: SinkContextKind::Before,
|
kind: SinkContextKind::Before,
|
||||||
@@ -497,6 +498,7 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> {
|
|||||||
let keepgoing = self.sink.context(
|
let keepgoing = self.sink.context(
|
||||||
&self.searcher,
|
&self.searcher,
|
||||||
&SinkContext {
|
&SinkContext {
|
||||||
|
#[cfg(test)]
|
||||||
line_term: self.config.line_term,
|
line_term: self.config.line_term,
|
||||||
bytes: &buf[*range],
|
bytes: &buf[*range],
|
||||||
kind: SinkContextKind::After,
|
kind: SinkContextKind::After,
|
||||||
@@ -526,6 +528,7 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> {
|
|||||||
let keepgoing = self.sink.context(
|
let keepgoing = self.sink.context(
|
||||||
&self.searcher,
|
&self.searcher,
|
||||||
&SinkContext {
|
&SinkContext {
|
||||||
|
#[cfg(test)]
|
||||||
line_term: self.config.line_term,
|
line_term: self.config.line_term,
|
||||||
bytes: &buf[*range],
|
bytes: &buf[*range],
|
||||||
kind: SinkContextKind::Other,
|
kind: SinkContextKind::Other,
|
||||||
|
@@ -88,7 +88,6 @@ where
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SliceByLine<'s, M, S> {
|
pub struct SliceByLine<'s, M, S> {
|
||||||
config: &'s Config,
|
|
||||||
core: Core<'s, M, S>,
|
core: Core<'s, M, S>,
|
||||||
slice: &'s [u8],
|
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));
|
debug_assert!(!searcher.multi_line_with_matcher(&matcher));
|
||||||
|
|
||||||
SliceByLine {
|
SliceByLine {
|
||||||
config: &searcher.config,
|
|
||||||
core: Core::new(searcher, matcher, write_to, true),
|
core: Core::new(searcher, matcher, write_to, true),
|
||||||
slice: slice,
|
slice: slice,
|
||||||
}
|
}
|
||||||
|
@@ -436,6 +436,7 @@ pub enum SinkContextKind {
|
|||||||
/// A type that describes a contextual line reported by a searcher.
|
/// A type that describes a contextual line reported by a searcher.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct SinkContext<'b> {
|
pub struct SinkContext<'b> {
|
||||||
|
#[cfg(test)]
|
||||||
pub(crate) line_term: LineTerminator,
|
pub(crate) line_term: LineTerminator,
|
||||||
pub(crate) bytes: &'b [u8],
|
pub(crate) bytes: &'b [u8],
|
||||||
pub(crate) kind: SinkContextKind,
|
pub(crate) kind: SinkContextKind,
|
||||||
|
Reference in New Issue
Block a user