|
1 |
| -//@ aux-build:deny-macro.rs |
2 |
| -//@ check-pass |
| 1 | +//! Ensure that when a macro (or normal code) does `#[deny]` inside a `#[forbid]` context, no error |
| 2 | +//! is emitted, as both parties agree on the treatment of the lint. |
| 3 | +//! |
| 4 | +//! However, still emit an error if the macro does `#[allow]` or `#[warn]`. |
3 | 5 |
|
4 |
| -// Ensure that when a macro (or normal code) does #[deny] inside a #[forbid] |
5 |
| -// context, no error is emitted, as both parties agree on the treatment of the lint. |
| 6 | +//@ revisions: forbid deny warn allow |
| 7 | +//@[forbid] aux-build:forbid-macro.rs |
| 8 | +//@[deny] aux-build:deny-macro.rs |
| 9 | +//@[warn] aux-build:warn-macro.rs |
| 10 | +//@[allow] aux-build:allow-macro.rs |
| 11 | + |
| 12 | +//@[forbid] check-pass |
| 13 | +//@[deny] check-pass |
6 | 14 |
|
7 | 15 | #![forbid(unsafe_code)]
|
8 | 16 |
|
| 17 | +#[cfg(allow)] |
| 18 | +extern crate allow_macro; |
| 19 | +#[cfg(deny)] |
9 | 20 | extern crate deny_macro;
|
| 21 | +#[cfg(forbid)] |
| 22 | +extern crate forbid_macro; |
| 23 | +#[cfg(warn)] |
| 24 | +extern crate warn_macro; |
10 | 25 |
|
11 | 26 | fn main() {
|
12 |
| - deny_macro::emit_deny! {} |
| 27 | + #[cfg(forbid)] |
| 28 | + forbid_macro::emit_forbid! {} // OK |
| 29 | + |
| 30 | + #[cfg(deny)] |
| 31 | + deny_macro::emit_deny! {} // OK |
| 32 | + |
| 33 | + #[cfg(warn)] |
| 34 | + warn_macro::emit_warn! {} |
| 35 | + //[warn]~^ ERROR warn(unsafe_code) incompatible with previous forbid |
| 36 | + //[warn]~| ERROR warn(unsafe_code) incompatible with previous forbid |
| 37 | + |
| 38 | + #[cfg(allow)] |
| 39 | + allow_macro::emit_allow! {} |
| 40 | + //[allow]~^ ERROR allow(unsafe_code) incompatible with previous forbid |
| 41 | + //[allow]~| ERROR allow(unsafe_code) incompatible with previous forbid |
13 | 42 |
|
14 |
| - #[deny(unsafe_code)] |
| 43 | + #[deny(unsafe_code)] // OK |
15 | 44 | let _ = 0;
|
16 | 45 | }
|
0 commit comments