Skip to content

Commit

Permalink
warnings: remove/tweak some dead code
Browse files Browse the repository at this point in the history
It looks like the dead code detector got better, so do a little code
cleanup.
  • Loading branch information
BurntSushi committed Mar 21, 2022
1 parent b6189c6 commit 5370064
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
4 changes: 1 addition & 3 deletions crates/globset/src/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 2 additions & 10 deletions crates/ignore/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions crates/searcher/src/searcher/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions crates/searcher/src/searcher/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ where

#[derive(Debug)]
pub struct SliceByLine<'s, M, S> {
config: &'s Config,
core: Core<'s, M, S>,
slice: &'s [u8],
}
Expand All @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crates/searcher/src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5370064

Please sign in to comment.