1 // This test is checking that you cannot override a `forbid` by adding in other 2 // attributes later in the same scope. (We already ensure that you cannot 3 // override it in nested scopes). 4 5 // If you turn off deduplicate diagnostics (which rustc turns on by default but 6 // compiletest turns off when it runs ui tests), then the errors are 7 // (unfortunately) repeated here because the checking is done as we read in the 8 // errors, and curretly that happens two or three different times, depending on 9 // compiler flags. 10 // 11 // I decided avoiding the redundant output was not worth the time in engineering 12 // effort for bug like this, which 1. end users are unlikely to run into in the 13 // first place, and 2. they won't see the redundant output anyway. 14 15 // compile-flags: -Z deduplicate-diagnostics=yes 16 17 #![forbid(forbidden_lint_groups)] 18 forbid_first(num: i32) -> i3219fn forbid_first(num: i32) -> i32 { 20 #![forbid(unused)] 21 #![deny(unused)] 22 //~^ ERROR: deny(unused) incompatible with previous forbid 23 //~| WARNING being phased out 24 #![warn(unused)] 25 #![allow(unused)] 26 27 num * num 28 } 29 forbid_last(num: i32) -> i3230fn forbid_last(num: i32) -> i32 { 31 #![deny(unused)] 32 #![warn(unused)] 33 #![allow(unused)] 34 #![forbid(unused)] 35 36 num * num 37 } 38 forbid_multiple(num: i32) -> i3239fn forbid_multiple(num: i32) -> i32 { 40 #![forbid(unused)] 41 #![forbid(unused)] 42 43 num * num 44 } 45 main()46fn main() { 47 forbid_first(10); 48 forbid_last(10); 49 forbid_multiple(10); 50 } 51