]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/issue-97094.rs
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / tests / ui / lint / issue-97094.rs
1 #![deny(warnings)]
2
3 // Ensure that unknown lints inside cfg-attr's are linted for
4
5 #![cfg_attr(all(), allow(nonex_lint_top_level))]
6 //~^ ERROR unknown lint
7 #![cfg_attr(all(), allow(bare_trait_object))]
8 //~^ ERROR has been renamed
9
10 #[cfg_attr(all(), allow(nonex_lint_mod))]
11 //~^ ERROR unknown lint
12 mod baz {
13     #![cfg_attr(all(), allow(nonex_lint_mod_inner))]
14     //~^ ERROR unknown lint
15 }
16
17 #[cfg_attr(all(), allow(nonex_lint_fn))]
18 //~^ ERROR unknown lint
19 pub fn main() {}
20
21 macro_rules! bar {
22     ($($t:tt)*) => {
23         $($t)*
24     };
25 }
26
27 bar!(
28     #[cfg_attr(all(), allow(nonex_lint_in_macro))]
29     //~^ ERROR unknown lint
30     pub fn _bar() {}
31 );
32
33 // No warning for non-applying cfg
34 #[cfg_attr(any(), allow(nonex_lint_fn))]
35 pub fn _foo() {}
36
37 // Allowing unknown lints works if inside cfg_attr
38 #[cfg_attr(all(), allow(unknown_lints))]
39 mod bar_allowed {
40     #[allow(nonex_lint_fn)]
41     fn _foo() {}
42 }
43
44 // ... but not if the cfg_attr doesn't evaluate
45 #[cfg_attr(any(), allow(unknown_lints))]
46 mod bar_not_allowed {
47     #[allow(nonex_lint_fn)]
48     //~^ ERROR unknown lint
49     fn _foo() {}
50 }