File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ pub use crate::completion::{
9292/// already present, it should give all possible variants for the identifier at
9393/// the caret. In other words, for
9494///
95- /// ```no-run
95+ /// ```no_run
9696/// fn f() {
9797/// let foo = 92;
9898/// let _ = bar<|>
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ fn runnable_fn(
160160 RunnableKind :: Test { test_id, attr }
161161 } else if fn_def. has_atom_attr ( "bench" ) {
162162 RunnableKind :: Bench { test_id }
163- } else if has_doc_test ( & fn_def) {
163+ } else if has_runnable_doc_test ( & fn_def) {
164164 RunnableKind :: DocTest { test_id }
165165 } else {
166166 return None ;
@@ -211,8 +211,13 @@ fn has_test_related_attribute(fn_def: &ast::Fn) -> bool {
211211 . any ( |attribute_text| attribute_text. contains ( "test" ) )
212212}
213213
214- fn has_doc_test ( fn_def : & ast:: Fn ) -> bool {
215- fn_def. doc_comment_text ( ) . map_or ( false , |comment| comment. contains ( "```" ) )
214+ fn has_runnable_doc_test ( fn_def : & ast:: Fn ) -> bool {
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+ } )
216221}
217222
218223fn runnable_mod (
@@ -417,6 +422,21 @@ fn main() {}
417422/// let x = 5;
418423/// ```
419424fn foo() {}
425+
426+ /// ```no_run
427+ /// let z = 55;
428+ /// ```
429+ fn should_have_no_runnable() {}
430+
431+ /// ```ignore
432+ /// let z = 55;
433+ /// ```
434+ fn should_have_no_runnable_2() {}
435+
436+ /// ```compile_fail
437+ /// let z = 55;
438+ /// ```
439+ fn should_have_no_runnable_3() {}
420440"# ,
421441 & [ & BIN , & DOCTEST ] ,
422442 expect ! [ [ r#"
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ pub fn ancestors_at_offset(
3232/// imprecise: if the cursor is strictly between two nodes of the desired type,
3333/// as in
3434///
35- /// ```no-run
35+ /// ```no_run
3636/// struct Foo {}|struct Bar;
3737/// ```
3838///
You can’t perform that action at this time.
0 commit comments