blob: 0901ac3640fdda75db09625d7e7de9546675f6b1 (
plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// check-pass
#![feature(lint_reasons)]
//! This file tests the `#[expect]` attribute implementation for tool lints. The same
//! file is used to test clippy and rustdoc. Any changes to this file should be synced
//! to the other test files as well.
//!
//! Expectations:
//! * rustc: only rustc lint expectations are emitted
//! * clippy: rustc and Clippy's expectations are emitted
//! * rustdoc: only rustdoc lint expectations are emitted
//!
//! This test can't cover every lint from Clippy, rustdoc and potentially other
//! tools that will be developed. This therefore only tests a small subset of lints
#![expect(rustdoc::missing_crate_level_docs)]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
//~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
mod rustc_ok {
//! See <https://doc.rust-lang.org/rustc/lints/index.html>
#[expect(dead_code)]
pub fn rustc_lints() {
let x = 42.0;
#[expect(illegal_floating_point_literal_pattern)]
match x {
5.0 => {}
6.0 => {}
_ => {}
}
}
}
mod rustc_warn {
//! See <https://doc.rust-lang.org/rustc/lints/index.html>
#[expect(dead_code)]
pub fn rustc_lints() {
let x = 42;
#[expect(illegal_floating_point_literal_pattern)]
match x {
5 => {}
6 => {}
_ => {}
}
}
}
pub mod rustdoc_ok {
//! See <https://doc.rust-lang.org/rustdoc/lints.html>
#[expect(rustdoc::broken_intra_doc_links)]
/// I want to link to [`Nonexistent`] but it doesn't exist!
pub fn foo() {}
#[expect(rustdoc::invalid_html_tags)]
/// <h1>
pub fn bar() {}
#[expect(rustdoc::bare_urls)]
/// http://example.org
pub fn baz() {}
}
pub mod rustdoc_warn {
//! See <https://doc.rust-lang.org/rustdoc/lints.html>
#[expect(rustdoc::broken_intra_doc_links)]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
/// I want to link to [`bar`] but it doesn't exist!
pub fn foo() {}
#[expect(rustdoc::invalid_html_tags)]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
/// <h1></h1>
pub fn bar() {}
#[expect(rustdoc::bare_urls)]
//~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
/// <http://example.org>
pub fn baz() {}
}
mod clippy_ok {
//! See <https://rust-lang.github.io/rust-clippy/master/index.html>
#[expect(clippy::almost_swapped)]
fn foo() {
let mut a = 0;
let mut b = 9;
a = b;
b = a;
}
#[expect(clippy::bytes_nth)]
fn bar() {
let _ = "Hello".bytes().nth(3);
}
#[expect(clippy::if_same_then_else)]
fn baz() {
let _ = if true {
42
} else {
42
};
}
#[expect(clippy::logic_bug)]
fn burger() {
let a = false;
let b = true;
if a && b || a {}
}
}
mod clippy_warn {
//! See <https://rust-lang.github.io/rust-clippy/master/index.html>
#[expect(clippy::almost_swapped)]
fn foo() {
let mut a = 0;
let mut b = 9;
a = b;
}
#[expect(clippy::bytes_nth)]
fn bar() {
let _ = "Hello".as_bytes().get(3);
}
#[expect(clippy::if_same_then_else)]
fn baz() {
let _ = if true {
33
} else {
42
};
}
#[expect(clippy::logic_bug)]
fn burger() {
let a = false;
let b = true;
let c = false;
if a && b || c {}
}
}
fn main() {
rustc_warn::rustc_lints();
}
|