]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/issue-97094.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / lint / issue-97094.rs
1 // revisions: interleaved nointerleaved
2 // [nointerleaved]compile-flags: -Z no-interleave-lints
3
4 // This test has two revisions because the logic change
5 // needed to make this test pass had to be adjusted
6 // for no-interleave-lints. Should the debug option
7 // be removed one day, please don't remove this
8 // test entirely, just remove the revision from it.
9
10 #![deny(warnings)]
11
12 // Ensure that unknown lints inside cfg-attr's are linted for
13
14 #![cfg_attr(all(), allow(nonex_lint_top_level))]
15 //~^ ERROR unknown lint
16 #![cfg_attr(all(), allow(bare_trait_object))]
17 //~^ ERROR has been renamed
18
19 #[cfg_attr(all(), allow(nonex_lint_mod))]
20 //~^ ERROR unknown lint
21 mod baz {
22     #![cfg_attr(all(), allow(nonex_lint_mod_inner))]
23     //~^ ERROR unknown lint
24 }
25
26 #[cfg_attr(all(), allow(nonex_lint_fn))]
27 //~^ ERROR unknown lint
28 pub fn main() {}
29
30 macro_rules! bar {
31     ($($t:tt)*) => {
32         $($t)*
33     };
34 }
35
36 bar!(
37     #[cfg_attr(all(), allow(nonex_lint_in_macro))]
38     //~^ ERROR unknown lint
39     pub fn _bar() {}
40 );
41
42 // No warning for non-applying cfg
43 #[cfg_attr(any(), allow(nonex_lint_fn))]
44 pub fn _foo() {}
45
46 // Allowing unknown lints works if inside cfg_attr
47 #[cfg_attr(all(), allow(unknown_lints))]
48 mod bar_allowed {
49     #[allow(nonex_lint_fn)]
50     fn _foo() {}
51 }
52
53 // ... but not if the cfg_attr doesn't evaluate
54 #[cfg_attr(any(), allow(unknown_lints))]
55 mod bar_not_allowed {
56     #[allow(nonex_lint_fn)]
57     //~^ ERROR unknown lint
58     fn _foo() {}
59 }