2 #![feature(lint_reasons)]
3 //! This file tests the `#[expect]` attribute implementation for tool lints. The same
4 //! file is used to test clippy and rustdoc. Any changes to this file should be synced
5 //! to the other test files as well.
8 //! * rustc: only rustc lint expectations are emitted
9 //! * clippy: rustc and Clippy's expectations are emitted
10 //! * rustdoc: only rustdoc lint expectations are emitted
12 //! This test can't cover every lint from Clippy, rustdoc and potentially other
13 //! tools that will be developed. This therefore only tests a small subset of lints
14 #![expect(rustdoc::missing_crate_level_docs)]
17 //! See <https://doc.rust-lang.org/rustc/lints/index.html>
20 pub fn rustc_lints() {
23 #[expect(illegal_floating_point_literal_pattern)]
33 //! See <https://doc.rust-lang.org/rustc/lints/index.html>
36 pub fn rustc_lints() {
39 #[expect(illegal_floating_point_literal_pattern)]
49 //! See <https://doc.rust-lang.org/rustdoc/lints.html>
51 #[expect(rustdoc::broken_intra_doc_links)]
52 /// I want to link to [`Nonexistent`] but it doesn't exist!
55 #[expect(rustdoc::invalid_html_tags)]
59 #[expect(rustdoc::bare_urls)]
60 /// http://example.org
64 pub mod rustdoc_warn {
65 //! See <https://doc.rust-lang.org/rustdoc/lints.html>
67 #[expect(rustdoc::broken_intra_doc_links)]
68 /// I want to link to [`bar`] but it doesn't exist!
71 #[expect(rustdoc::invalid_html_tags)]
75 #[expect(rustdoc::bare_urls)]
76 /// <http://example.org>
81 //! See <https://rust-lang.github.io/rust-clippy/master/index.html>
83 #[expect(clippy::almost_swapped)]
91 #[expect(clippy::bytes_nth)]
93 let _ = "Hello".bytes().nth(3);
96 #[expect(clippy::if_same_then_else)]
98 let _ = if true { 42 } else { 42 };
101 #[expect(clippy::overly_complex_bool_expr)]
111 //! See <https://rust-lang.github.io/rust-clippy/master/index.html>
113 #[expect(clippy::almost_swapped)]
120 #[expect(clippy::bytes_nth)]
122 let _ = "Hello".as_bytes().get(3);
125 #[expect(clippy::if_same_then_else)]
127 let _ = if true { 33 } else { 42 };
130 #[expect(clippy::overly_complex_bool_expr)]
141 rustc_warn::rustc_lints();