diff --git a/crates/util/src/http.rs b/crates/util/src/http.rs index 62cf2d1239..3df8886fa4 100644 --- a/crates/util/src/http.rs +++ b/crates/util/src/http.rs @@ -128,22 +128,25 @@ impl HttpClient for isahc::HttpClient { } } +#[cfg(feature = "test-support")] +type FakeHttpHandler = Box< + dyn Fn(Request) -> BoxFuture<'static, Result, Error>> + + Send + + Sync + + 'static, +>; + #[cfg(feature = "test-support")] pub struct FakeHttpClient { - handler: Box< - dyn 'static - + Send - + Sync - + Fn(Request) -> BoxFuture<'static, Result, Error>>, - >, + handler: FakeHttpHandler, } #[cfg(feature = "test-support")] impl FakeHttpClient { pub fn create(handler: F) -> Arc where - Fut: 'static + Send + futures::Future, Error>>, - F: 'static + Send + Sync + Fn(Request) -> Fut, + Fut: futures::Future, Error>> + Send + 'static, + F: Fn(Request) -> Fut + Send + Sync + 'static, { Arc::new(HttpClientWithUrl { base_url: Mutex::new("http://test.example".into()), diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 9dbe64c418..27306bcfb7 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -459,7 +459,7 @@ mod tests { let path = Path::new("/work/node_modules"); let path_matcher = PathMatcher::new("**/node_modules/**").unwrap(); assert!( - path_matcher.is_match(&path), + path_matcher.is_match(path), "Path matcher {path_matcher} should match {path:?}" ); } @@ -469,7 +469,7 @@ mod tests { let path = Path::new("/Users/someonetoignore/work/zed/zed.dev/node_modules"); let path_matcher = PathMatcher::new("**/node_modules/**").unwrap(); assert!( - path_matcher.is_match(&path), + path_matcher.is_match(path), "Path matcher {path_matcher} should match {path:?}" ); } diff --git a/crates/util/src/test.rs b/crates/util/src/test.rs index e728281ea6..9915a6c159 100644 --- a/crates/util/src/test.rs +++ b/crates/util/src/test.rs @@ -29,8 +29,8 @@ fn write_tree(path: &Path, tree: serde_json::Value) { Value::Object(_) => { fs::create_dir(&path).unwrap(); - if path.file_name() == Some(&OsStr::new(".git")) { - git2::Repository::init(&path.parent().unwrap()).unwrap(); + if path.file_name() == Some(OsStr::new(".git")) { + git2::Repository::init(path.parent().unwrap()).unwrap(); } write_tree(&path, contents); diff --git a/crates/util/src/test/marked_text.rs b/crates/util/src/test/marked_text.rs index cf85a806e4..7ab45e9b20 100644 --- a/crates/util/src/test/marked_text.rs +++ b/crates/util/src/test/marked_text.rs @@ -12,7 +12,7 @@ pub fn marked_text_offsets_by( for char in marked_text.chars() { if markers.contains(&char) { - let char_offsets = extracted_markers.entry(char).or_insert(Vec::new()); + let char_offsets = extracted_markers.entry(char).or_default(); char_offsets.push(unmarked_text.len()); } else { unmarked_text.push(char); @@ -119,7 +119,7 @@ pub fn marked_text_ranges( let mut current_range_start = None; let mut current_range_cursor = None; - let marked_text = marked_text.replace("•", " "); + let marked_text = marked_text.replace('•', " "); for (marked_ix, marker) in marked_text.match_indices(&['«', '»', 'ˇ']) { unmarked_text.push_str(&marked_text[prev_marked_ix..marked_ix]); let unmarked_len = unmarked_text.len(); @@ -131,9 +131,9 @@ pub fn marked_text_ranges( if current_range_start.is_some() { if current_range_cursor.is_some() { panic!("duplicate point marker 'ˇ' at index {marked_ix}"); - } else { - current_range_cursor = Some(unmarked_len); } + + current_range_cursor = Some(unmarked_len); } else { ranges.push(unmarked_len..unmarked_len); } @@ -252,6 +252,7 @@ impl From<(char, char)> for TextRangeMarker { mod tests { use super::{generate_marked_text, marked_text_ranges}; + #[allow(clippy::reversed_empty_ranges)] #[test] fn test_marked_text() { let (text, ranges) = marked_text_ranges("one «ˇtwo» «threeˇ» «ˇfour» fiveˇ six", true);