Skip to content

Commit

Permalink
Suggest pattern tests when modifying exhaustiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Feb 8, 2024
1 parent 8ace7ea commit 2b95b68
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/tools/suggest-tests/src/dynamic_suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ use crate::Suggestion;

type DynamicSuggestion = fn(&Path) -> Vec<Suggestion>;

pub(crate) const DYNAMIC_SUGGESTIONS: &[DynamicSuggestion] = &[|path: &Path| -> Vec<Suggestion> {
if path.starts_with("compiler/") || path.starts_with("library/") {
let path = path.components().take(2).collect::<Vec<_>>();
pub(crate) const DYNAMIC_SUGGESTIONS: &[DynamicSuggestion] = &[
|path: &Path| -> Vec<Suggestion> {
if path.starts_with("compiler/") || path.starts_with("library/") {
let path = path.components().take(2).collect::<Vec<_>>();

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<Suggestion> {
if path.starts_with("compiler/rustc_pattern_analysis") {
vec![Suggestion::new("test", None, &["tests/ui", "--test-args", "pattern"])]
} else {
Vec::new()
}
},
];

0 comments on commit 2b95b68

Please sign in to comment.