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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// Same test as dead-code-module but with 2 doc(test(attr())) at different levels.
//@ edition: 2024
//@ compile-flags:--test --test-args=--test-threads=1
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME"
//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME"
//@ failure-status: 101
#![doc(test(attr(deny(warnings))))]
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait OnlyWarning { fn no_deny_warnings(); }
/// ```
static S: u32 = 5;
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// let unused_error = 5;
///
/// fn dead_code_but_no_error() {}
/// ```
const C: u32 = 5;
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait OnlyWarningAtA { fn no_deny_warnings(); }
/// ```
struct A {
#[doc(test(attr(deny(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait DeadCodeInField {}
/// ```
field: u32
}
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait OnlyWarningAtU { fn no_deny_warnings(); }
/// ```
union U {
#[doc(test(attr(deny(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait DeadCodeInUnionField {}
/// ```
field: u32,
/// Example
///
/// ```rust,no_run
/// trait NotDeadCodeInUnionField {}
/// ```
field2: u64,
}
#[doc(test(attr(deny(dead_code))))]
/// Example
///
/// ```rust,no_run
/// let not_dead_code_but_unused = 5;
/// ```
enum Enum {
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait NotDeadCodeInVariant {}
///
/// fn main() { let unused_in_variant = 5; }
/// ```
Variant1,
}
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait OnlyWarningAtImplA { fn no_deny_warnings(); }
/// ```
impl A {
/// Example
///
/// ```rust,no_run
/// trait NotDeadCodeInImplMethod {}
/// ```
fn method() {}
}
#[doc(test(attr(deny(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait StillDeadCodeAtMyTrait { }
/// ```
trait MyTrait {
#[doc(test(attr(allow(dead_code))))]
/// Example
///
/// ```rust,no_run
/// trait NotDeadCodeAtImplFn {}
///
/// fn main() { let unused_in_impl = 5; }
/// ```
fn my_trait_fn();
}
|