Skip to content

Documentation test triggered without ``` #49717

Closed
@benhansen-io

Description

@benhansen-io

If you'd like to fix this bug, here's how!


The follow documentation comment is considered a documentation test. All of the Rust references I have read indicate ``` are needed to indicate a documentation test.

lib.rs

///                   
///     a             
/// b                 
pub fn some_lib_fn() {
                  
} 

Then running cargo test gives the following output:

 running 0 tests                                                                   
                                                                                   
 test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out        
                                                                                   
    Doc-tests reproduce-doc-test                                                   
                                                                                   
 running 1 test                                                                    
 test src/lib.rs - some_lib_fn (line 1) ... FAILED                                 
                                                                                   
 failures:                                                                         
                                                                                   
 ---- src/lib.rs - some_lib_fn (line 1) stdout ----                                
         error[E0425]: cannot find value `a` in this scope                         
  --> src/lib.rs:2:1                                                               
   |                                                                               
 3 | a                                                                             
   | ^ not found in this scope                                                     
                                                                                   
 thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:298:13 
 note: Run with `RUST_BACKTRACE=1` for a backtrace.                                
                                                                                   
                                                                                   
 failures:                                                                         
     src/lib.rs - some_lib_fn (line 1)                                             
                                                                                   
 test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out    
                                                                                   
 error: test failed, to rerun pass '--doc'                                         

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions