Apply suggestions from code review
This commit is contained in:
parent
594c499db9
commit
bb67915028
8 changed files with 126 additions and 51 deletions
|
|
@ -1,11 +1,4 @@
|
|||
#![deny(unused_unsafe)]
|
||||
|
||||
unsafe fn unsf() {}
|
||||
|
||||
unsafe fn foo() {
|
||||
unsafe { //~ ERROR unnecessary `unsafe` block
|
||||
unsf()
|
||||
}
|
||||
}
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
//~^ ERROR the `unsafe_op_in_unsafe_fn` lint is unstable
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,30 @@
|
|||
error: unnecessary `unsafe` block
|
||||
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:6:5
|
||||
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
|
||||
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:1
|
||||
|
|
||||
LL | unsafe fn foo() {
|
||||
| --------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
LL | #![deny(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:9
|
||||
|
|
||||
LL | #![deny(unused_unsafe)]
|
||||
| ^^^^^^^^^^^^^
|
||||
= note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information
|
||||
= help: add `#![feature(unsafe_block_in_unsafe_fn)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
|
||||
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:1
|
||||
|
|
||||
LL | #![deny(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information
|
||||
= help: add `#![feature(unsafe_block_in_unsafe_fn)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
|
||||
--> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:1
|
||||
|
|
||||
LL | #![deny(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information
|
||||
= help: add `#![feature(unsafe_block_in_unsafe_fn)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@ unsafe fn baz() {
|
|||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn qux() {
|
||||
unsf(); // no error
|
||||
|
||||
unsafe { unsf() }
|
||||
//~^ ERROR unnecessary `unsafe` block
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
unsf()
|
||||
//~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,20 @@ note: the lint level is defined here
|
|||
LL | #![deny(unused_unsafe)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:25:5
|
||||
|
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:30:5
|
||||
|
|
||||
LL | unsf()
|
||||
| ^^^^^^ call to unsafe function
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error: aborting due to 3 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0133`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue