summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs')
-rw-r--r--src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs b/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs
index 08aee4332..c05eb447b 100644
--- a/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs
+++ b/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.rs
@@ -1,6 +1,6 @@
// aux-build:proc_macro_unsafe.rs
-#![warn(clippy::undocumented_unsafe_blocks)]
+#![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)]
#![allow(clippy::let_unit_value, clippy::missing_safety_doc)]
extern crate proc_macro_unsafe;
@@ -490,4 +490,23 @@ unsafe impl CrateRoot for () {}
// SAFETY: ok
unsafe impl CrateRoot for (i32) {}
+fn issue_9142() {
+ // SAFETY: ok
+ let _ =
+ // we need this comment to avoid rustfmt putting
+ // it all on one line
+ unsafe {};
+
+ // SAFETY: this is more than one level away, so it should warn
+ let _ = {
+ if unsafe { true } {
+ todo!();
+ } else {
+ let bar = unsafe {};
+ todo!();
+ bar
+ }
+ };
+}
+
fn main() {}