From 0be21b05d6811936a22d491f2cea4c7fe244ce2f Mon Sep 17 00:00:00 2001 From: Francesco Zardi Date: Wed, 21 Oct 2020 21:53:05 +0200 Subject: Move safe intrinsic tests --- crates/hir_ty/src/diagnostics/unsafe_check.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crates/hir_ty/src/diagnostics') diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 21a121aad..2da9688ca 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs @@ -199,6 +199,24 @@ fn main() { let x = STATIC_MUT.a; } } +"#, + ); + } + + #[test] + fn no_missing_unsafe_diagnostic_with_safe_intrinsic() { + check_diagnostics( + r#" +extern "rust-intrinsic" { + pub fn bitreverse(x: u32) -> u32; // Safe intrinsic + pub fn floorf32(x: f32) -> f32; // Unsafe intrinsic +} + +fn main() { + let _ = bitreverse(12); + let _ = floorf32(12.0); + //^^^^^^^^^^^^^^ This operation is unsafe and requires an unsafe function or block +} "#, ); } -- cgit v1.2.3