mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
Add test
This commit is contained in:
parent
60a68bed7b
commit
efd111e502
16
src/test/ui/lint/lint-forbid-internal-unsafe.rs
Normal file
16
src/test/ui/lint/lint-forbid-internal-unsafe.rs
Normal file
@ -0,0 +1,16 @@
|
||||
#![forbid(unsafe_code)]
|
||||
#![feature(allow_internal_unsafe)]
|
||||
|
||||
#[allow_internal_unsafe]
|
||||
//~^ ERROR: cannot use `allow_internal_unsafe` with `forbid(unsafe_code)`
|
||||
macro_rules! evil {
|
||||
($e:expr) => {
|
||||
unsafe {
|
||||
$e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{}", evil!(*(0 as *const u8)));
|
||||
}
|
14
src/test/ui/lint/lint-forbid-internal-unsafe.stderr
Normal file
14
src/test/ui/lint/lint-forbid-internal-unsafe.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
error: cannot use `allow_internal_unsafe` with `forbid(unsafe_code)`
|
||||
--> $DIR/lint-forbid-internal-unsafe.rs:4:1
|
||||
|
|
||||
LL | #[allow_internal_unsafe]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/lint-forbid-internal-unsafe.rs:1:11
|
||||
|
|
||||
LL | #![forbid(unsafe_code)]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user