]> git.proxmox.com Git - rustc.git/blame - tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / tests / ui / lint / unused / unused-doc-comments-edge-cases.rs
CommitLineData
136023e0
XL
1#![deny(unused_doc_comments)]
2
3fn 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
12fn 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
22fn 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
781aab86
FG
29fn doc_comment_on_expr_field() -> bool {
30 struct S { foo: i32 }
31
32 let x = S {
33 /// useless doc comment
34 //~^ ERROR: unused doc comment
35 foo: 3
36 };
37
38 true
39}
40
41fn doc_comment_on_pat_field() -> bool {
42 struct S { foo: i32 }
43
44 let S {
45 /// useless doc comment
46 //~^ ERROR: unused doc comment
47 foo
48 } = S {
49 foo: 3
50 };
51
52 true
53}
54
a2a8927a
XL
55fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
56//~^ ERROR: unused doc comment
57
5e7ed085
FG
58fn doc_comment_on_block() {
59 /// unused doc comment
60 //~^ ERROR: unused doc comment
61 {
62 let x = 12;
63 }
64}
65
66/// unused doc comment
67//~^ ERROR: unused doc comment
68extern "C" {
69 fn foo();
70}
71
136023e0 72fn main() {}