2 #![feature(lint_reasons)]
4 //! This file tests the `#[expect]` attribute implementation for tool lints. The same
5 //! file is used to test clippy and rustdoc. Any changes to this file should be synced
6 //! to the other test files as well.
9 //! * rustc: only rustc lint expectations are emitted
10 //! * clippy: rustc and Clippy's expectations are emitted
11 //! * rustdoc: only rustdoc lint expectations are emitted
13 //! This test can't cover every lint from Clippy, rustdoc and potentially other
14 //! tools that will be developed. This therefore only tests a small subset of lints
16 #![expect(rustdoc::missing_crate_level_docs)]
17 //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
18 //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
21 //! See <https://doc.rust-lang.org/rustc/lints/index.html>
24 pub fn rustc_lints() {
27 #[expect(illegal_floating_point_literal_pattern)]
37 //! See <https://doc.rust-lang.org/rustc/lints/index.html>
40 pub fn rustc_lints() {
43 #[expect(illegal_floating_point_literal_pattern)]
53 //! See <https://doc.rust-lang.org/rustdoc/lints.html>
55 #[expect(rustdoc::broken_intra_doc_links)]
56 /// I want to link to [`Nonexistent`] but it doesn't exist!
59 #[expect(rustdoc::invalid_html_tags)]
63 #[expect(rustdoc::bare_urls)]
64 /// http://example.org
68 pub mod rustdoc_warn {
69 //! See <https://doc.rust-lang.org/rustdoc/lints.html>
71 #[expect(rustdoc::broken_intra_doc_links)]
72 //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
73 /// I want to link to [`bar`] but it doesn't exist!
76 #[expect(rustdoc::invalid_html_tags)]
77 //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
81 #[expect(rustdoc::bare_urls)]
82 //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
83 /// <http://example.org>
88 //! See <https://rust-lang.github.io/rust-clippy/master/index.html>
90 #[expect(clippy::almost_swapped)]
98 #[expect(clippy::bytes_nth)]
100 let _ = "Hello".bytes().nth(3);
103 #[expect(clippy::if_same_then_else)]
112 #[expect(clippy::logic_bug)]
122 //! See <https://rust-lang.github.io/rust-clippy/master/index.html>
124 #[expect(clippy::almost_swapped)]
131 #[expect(clippy::bytes_nth)]
133 let _ = "Hello".as_bytes().get(3);
136 #[expect(clippy::if_same_then_else)]
145 #[expect(clippy::logic_bug)]
156 rustc_warn::rustc_lints();