summaryrefslogtreecommitdiffstats
path: root/src/tools/suggest-tests/src/dynamic_suggestions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/suggest-tests/src/dynamic_suggestions.rs')
-rw-r--r--src/tools/suggest-tests/src/dynamic_suggestions.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/suggest-tests/src/dynamic_suggestions.rs b/src/tools/suggest-tests/src/dynamic_suggestions.rs
new file mode 100644
index 000000000..2b0213cdc
--- /dev/null
+++ b/src/tools/suggest-tests/src/dynamic_suggestions.rs
@@ -0,0 +1,23 @@
+use std::path::Path;
+
+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<_>>();
+
+ 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()
+ }
+}];