From 41d69da9faa7f9b8b62d479a24552ed00a839285 Mon Sep 17 00:00:00 2001 From: Allen Wild Date: Mon, 21 Feb 2022 16:03:31 -0500 Subject: [PATCH] remove unused fields to fix compiler warnings This code hasn't changed, but the warnings are new in Rust 1.57 because of "ignore derived Clone and Debug implementations during dead code analysis"[1]. Rust now doesn't count its generated derive code as a use of these fields, revealing that they're not actually needed. Sure enough, removing them compiles successfully and passes tests. [1] https://github.com/rust-lang/rust/pull/85200 --- 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 - 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/crates/ignore/src/types.rs b/crates/ignore/src/types.rs index efb9a8d9b..616a8d217 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 b6deda018..92daf1e08 100644 --- a/crates/searcher/src/searcher/core.rs +++ b/crates/searcher/src/searcher/core.rs @@ -467,7 +467,6 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> { let keepgoing = self.sink.context( &self.searcher, &SinkContext { - line_term: self.config.line_term, bytes: &buf[*range], kind: SinkContextKind::Before, absolute_byte_offset: offset, @@ -497,7 +496,6 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> { let keepgoing = self.sink.context( &self.searcher, &SinkContext { - line_term: self.config.line_term, bytes: &buf[*range], kind: SinkContextKind::After, absolute_byte_offset: offset, @@ -526,7 +524,6 @@ impl<'s, M: Matcher, S: Sink> Core<'s, M, S> { let keepgoing = self.sink.context( &self.searcher, &SinkContext { - line_term: self.config.line_term, bytes: &buf[*range], kind: SinkContextKind::Other, absolute_byte_offset: offset, diff --git a/crates/searcher/src/searcher/glue.rs b/crates/searcher/src/searcher/glue.rs index 21a58aa4c..1ff208bc5 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 41f425cc8..9016e716e 100644 --- a/crates/searcher/src/sink.rs +++ b/crates/searcher/src/sink.rs @@ -436,7 +436,6 @@ pub enum SinkContextKind { /// A type that describes a contextual line reported by a searcher. #[derive(Clone, Debug)] pub struct SinkContext<'b> { - pub(crate) line_term: LineTerminator, pub(crate) bytes: &'b [u8], pub(crate) kind: SinkContextKind, pub(crate) absolute_byte_offset: u64,