mirror of
				https://github.com/BurntSushi/ripgrep.git
				synced 2025-10-30 23:17:47 +02: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 { | ||||
|     /// 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. | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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, | ||||
|         } | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user