aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/runnables.rs
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-08-25 05:44:36 +0100
committerZac Pullar-Strecker <[email protected]>2020-08-25 05:44:36 +0100
commitb835f06cecd2189cb32a431fdb85245fbf53032a (patch)
tree8bb4ba65f4922e9cca571a7d4a7fa17d047ae779 /crates/ide/src/runnables.rs
parent452afaebe188251cd4403e56999bf8b58de4fba9 (diff)
parentef9cea945d5767e7c60d5931a7649a73caea23ad (diff)
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Diffstat (limited to 'crates/ide/src/runnables.rs')
-rw-r--r--crates/ide/src/runnables.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 4139f329e..dd59d9e70 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -160,7 +160,7 @@ fn runnable_fn(
160 RunnableKind::Test { test_id, attr } 160 RunnableKind::Test { test_id, attr }
161 } else if fn_def.has_atom_attr("bench") { 161 } else if fn_def.has_atom_attr("bench") {
162 RunnableKind::Bench { test_id } 162 RunnableKind::Bench { test_id }
163 } else if has_doc_test(&fn_def) { 163 } else if has_runnable_doc_test(&fn_def) {
164 RunnableKind::DocTest { test_id } 164 RunnableKind::DocTest { test_id }
165 } else { 165 } else {
166 return None; 166 return None;
@@ -211,8 +211,13 @@ fn has_test_related_attribute(fn_def: &ast::Fn) -> bool {
211 .any(|attribute_text| attribute_text.contains("test")) 211 .any(|attribute_text| attribute_text.contains("test"))
212} 212}
213 213
214fn has_doc_test(fn_def: &ast::Fn) -> bool { 214fn has_runnable_doc_test(fn_def: &ast::Fn) -> bool {
215 fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```")) 215 fn_def.doc_comment_text().map_or(false, |comments_text| {
216 comments_text.contains("```")
217 && !comments_text.contains("```ignore")
218 && !comments_text.contains("```no_run")
219 && !comments_text.contains("```compile_fail")
220 })
216} 221}
217 222
218fn runnable_mod( 223fn runnable_mod(
@@ -417,6 +422,21 @@ fn main() {}
417/// let x = 5; 422/// let x = 5;
418/// ``` 423/// ```
419fn foo() {} 424fn foo() {}
425
426/// ```no_run
427/// let z = 55;
428/// ```
429fn should_have_no_runnable() {}
430
431/// ```ignore
432/// let z = 55;
433/// ```
434fn should_have_no_runnable_2() {}
435
436/// ```compile_fail
437/// let z = 55;
438/// ```
439fn should_have_no_runnable_3() {}
420"#, 440"#,
421 &[&BIN, &DOCTEST], 441 &[&BIN, &DOCTEST],
422 expect![[r#" 442 expect![[r#"