]> git.proxmox.com Git - rustc.git/blob - src/test/ui/lint/reasons-forbidden.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / lint / reasons-forbidden.rs
1 #![feature(lint_reasons)]
2
3 // If you turn off deduplicate diagnostics (which rustc turns on by default but
4 // compiletest turns off when it runs ui tests), then the errors are
5 // (unfortunately) repeated here because the checking is done as we read in the
6 // errors, and currently that happens two or three different times, depending on
7 // compiler flags.
8 //
9 // The test is much cleaner if we deduplicate, though.
10
11 // compile-flags: -Z deduplicate-diagnostics=yes
12
13 #![forbid(
14 unsafe_code,
15 //~^ NOTE `forbid` level set here
16 //~| NOTE the lint level is defined here
17 reason = "our errors & omissions insurance policy doesn't cover unsafe Rust"
18 )]
19
20 use std::ptr;
21
22 fn main() {
23 let a_billion_dollar_mistake = ptr::null();
24
25 #[allow(unsafe_code)]
26 //~^ ERROR allow(unsafe_code) incompatible with previous forbid
27 //~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust
28 //~| NOTE overruled by previous forbid
29 unsafe {
30 //~^ ERROR usage of an `unsafe` block
31 //~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust
32 *a_billion_dollar_mistake
33 }
34 }