summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-27 01:18:49 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-27 10:10:33 -0400
commit81cf52bb301592ff3d043d03eb9a0d547891a3e1 (patch)
tree52c9276526b0aadcbf85a86f300749ce861d1f46
parent5a7f0deee64f32777db8b87b056b4e9ba154093f (diff)
downloadhaskell-81cf52bb301592ff3d043d03eb9a0d547891a3e1.tar.gz
Mark GHC.Prim.PtrEq as Unsafe
This module exports unsafe pointer equality operations, so we accordingly mark it as Unsafe. Fixes #21433
-rw-r--r--libraries/ghc-prim/GHC/Prim/PtrEq.hs2
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/T21433.hs8
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/T21433.stderr4
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/all.T1
4 files changed, 14 insertions, 1 deletions
diff --git a/libraries/ghc-prim/GHC/Prim/PtrEq.hs b/libraries/ghc-prim/GHC/Prim/PtrEq.hs
index ba58857868..34285a879a 100644
--- a/libraries/ghc-prim/GHC/Prim/PtrEq.hs
+++ b/libraries/ghc-prim/GHC/Prim/PtrEq.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MagicHash #-}
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/T21433.hs b/testsuite/tests/safeHaskell/unsafeLibs/T21433.hs
new file mode 100644
index 0000000000..a5ebd98b92
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/T21433.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE Safe #-}
+
+module T21433 where
+
+import GHC.Prim.PtrEq
+
+f x y = reallyUnsafePtrEquality x y
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/T21433.stderr b/testsuite/tests/safeHaskell/unsafeLibs/T21433.stderr
new file mode 100644
index 0000000000..1604b39c9b
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/T21433.stderr
@@ -0,0 +1,4 @@
+
+T21433.hs:6:1: error:
+ GHC.Prim.PtrEq: Can't be safely imported!
+ The module itself isn't safe.
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/all.T b/testsuite/tests/safeHaskell/unsafeLibs/all.T
index 8bcda5f402..774143e4a6 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/all.T
+++ b/testsuite/tests/safeHaskell/unsafeLibs/all.T
@@ -23,6 +23,7 @@ test('BadImport06', normal, compile_fail, [''])
test('BadImport07', normal, compile_fail, [''])
test('BadImport08', normal, compile_fail, [''])
test('BadImport09', normal, compile_fail, [''])
+test('T21433', normal, compile_fail, [''])
# check safe modules are marked safe
test('GoodImport01', normal, compile, [''])