From 2b95b68304b4bf48031e8dd7cd4754c647022f03 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 8 Feb 2024 01:46:06 +0100 Subject: [PATCH] Suggest pattern tests when modifying exhaustiveness --- .../suggest-tests/src/dynamic_suggestions.rs | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/tools/suggest-tests/src/dynamic_suggestions.rs b/src/tools/suggest-tests/src/dynamic_suggestions.rs index 2b0213cdc223c..f09720f1c91fa 100644 --- a/src/tools/suggest-tests/src/dynamic_suggestions.rs +++ b/src/tools/suggest-tests/src/dynamic_suggestions.rs @@ -4,20 +4,29 @@ use crate::Suggestion; type DynamicSuggestion = fn(&Path) -> Vec; -pub(crate) const DYNAMIC_SUGGESTIONS: &[DynamicSuggestion] = &[|path: &Path| -> Vec { - if path.starts_with("compiler/") || path.starts_with("library/") { - let path = path.components().take(2).collect::>(); +pub(crate) const DYNAMIC_SUGGESTIONS: &[DynamicSuggestion] = &[ + |path: &Path| -> Vec { + if path.starts_with("compiler/") || path.starts_with("library/") { + let path = path.components().take(2).collect::>(); - vec![Suggestion::with_single_path( - "test", - None, - &format!( - "{}/{}", - path[0].as_os_str().to_str().unwrap(), - path[1].as_os_str().to_str().unwrap() - ), - )] - } else { - Vec::new() - } -}]; + vec![Suggestion::with_single_path( + "test", + None, + &format!( + "{}/{}", + path[0].as_os_str().to_str().unwrap(), + path[1].as_os_str().to_str().unwrap() + ), + )] + } else { + Vec::new() + } + }, + |path: &Path| -> Vec { + if path.starts_with("compiler/rustc_pattern_analysis") { + vec![Suggestion::new("test", None, &["tests/ui", "--test-args", "pattern"])] + } else { + Vec::new() + } + }, +];