File: unused-doc-comments-edge-cases.rs

package info (click to toggle)
rustc-web 1.70.0%2Bdfsg1-7~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,517,036 kB
  • sloc: xml: 147,962; javascript: 10,210; sh: 8,590; python: 8,220; ansic: 5,901; cpp: 4,635; makefile: 4,006; asm: 2,856
file content (46 lines) | stat: -rw-r--r-- 931 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![deny(unused_doc_comments)]

fn doc_comment_on_match_arms(num: u8) -> bool {
    match num {
        3 => true,
        /// useless doc comment
        //~^ ERROR: unused doc comment
        _ => false,
    }
}

fn doc_comment_between_if_else(num: u8) -> bool {
    if num == 3 {
        true //~ ERROR: mismatched types
    }
    /// useless doc comment
    else { //~ ERROR: expected expression, found keyword `else`
        false
    }
}

fn doc_comment_on_expr(num: u8) -> bool {
    /// useless doc comment
    //~^ ERROR: attributes on expressions are experimental
    //~| ERROR: unused doc comment
    num == 3
}

fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
//~^ ERROR: unused doc comment

fn doc_comment_on_block() {
    /// unused doc comment
    //~^ ERROR: unused doc comment
    {
        let x = 12;
    }
}

/// unused doc comment
//~^ ERROR: unused doc comment
extern "C" {
    fn foo();
}

fn main() {}