]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-se
[rust.git] / tests / ui / lint / unused / unused-doc-comments-edge-cases.rs
1 #![deny(unused_doc_comments)]
2
3 fn doc_comment_on_match_arms(num: u8) -> bool {
4     match num {
5         3 => true,
6         /// useless doc comment
7         //~^ ERROR: unused doc comment
8         _ => false,
9     }
10 }
11
12 fn doc_comment_between_if_else(num: u8) -> bool {
13     if num == 3 {
14         true //~ ERROR: mismatched types
15     }
16     /// useless doc comment
17     else { //~ ERROR: expected expression, found keyword `else`
18         false
19     }
20 }
21
22 fn doc_comment_on_expr(num: u8) -> bool {
23     /// useless doc comment
24     //~^ ERROR: attributes on expressions are experimental
25     //~| ERROR: unused doc comment
26     num == 3
27 }
28
29 fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
30 //~^ ERROR: unused doc comment
31
32 fn doc_comment_on_block() {
33     /// unused doc comment
34     //~^ ERROR: unused doc comment
35     {
36         let x = 12;
37     }
38 }
39
40 /// unused doc comment
41 //~^ ERROR: unused doc comment
42 extern "C" {
43     fn foo();
44 }
45
46 fn main() {}