diff options
author | Aaron Allen <aaron@flipstone.com> | 2022-01-09 22:12:09 -0600 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-16 02:27:48 -0400 |
commit | c1fed9da095303591c37c53bad5f5559381048d7 (patch) | |
tree | ab5e40fa10263c1c1bf8f584da0f0396f7a9de15 /compiler/GHC/Tc/Errors | |
parent | 577135bf2251cf0aecf07ebb4966659d3fcc62b5 (diff) | |
download | haskell-c1fed9da095303591c37c53bad5f5559381048d7.tar.gz |
Suggest FFI extensions as hints (#20116)
- Use extension suggestion hints instead of suggesting extensions in the
error message body for several FFI errors.
- Adds a test case for `TcRnForeignImportPrimExtNotSet`
Diffstat (limited to 'compiler/GHC/Tc/Errors')
-rw-r--r-- | compiler/GHC/Tc/Errors/Ppr.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Types.hs | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs index 6cdfe963c7..29da277c8d 100644 --- a/compiler/GHC/Tc/Errors/Ppr.hs +++ b/compiler/GHC/Tc/Errors/Ppr.hs @@ -48,7 +48,6 @@ import {-# SOURCE #-} GHC.Tc.Types (getLclEnvLoc) import GHC.Tc.Types.Origin import GHC.Tc.Types.Rank (Rank(..)) import GHC.Tc.Utils.TcType -import GHC.Types.Basic (UnboxedTupleOrSum(..), unboxedTupleOrSumExtension) import GHC.Types.Error import GHC.Types.FieldLabel (flIsOverloaded) import GHC.Types.Hint.Ppr () -- Outputable GhcHint @@ -715,7 +714,7 @@ instance Diagnostic TcRnMessage where TcRnForeignImportPrimExtNotSet _decl -> mkSimpleDecorated $ - text "Use GHCForeignImportPrim to allow `foreign import prim'." + text "`foreign import prim' requires GHCForeignImportPrim." TcRnForeignImportPrimSafeAnn _decl -> mkSimpleDecorated $ @@ -771,7 +770,7 @@ instance Diagnostic TcRnMessage where text "because the data constructor for" <+> quotes (ppr tc) <+> text "is not in scope" UnliftedFFITypesNeeded -> - innerMsg $$ text "To marshal unlifted types, use UnliftedFFITypes" + innerMsg $$ text "UnliftedFFITypes is required to marshal unlifted types" NotABoxedMarshalableTyCon -> innerMsg ForeignLabelNotAPtr -> innerMsg $$ text "A foreign-imported address (via &foo) must have type (Ptr a) or (FunPtr a)" @@ -1298,7 +1297,7 @@ instance Diagnostic TcRnMessage where TcRnWarnDefaulting {} -> noHints TcRnForeignImportPrimExtNotSet{} - -> noHints + -> [suggestExtension LangExt.GHCForeignImportPrim] TcRnForeignImportPrimSafeAnn{} -> noHints TcRnForeignFunctionImportAsValue{} @@ -1313,6 +1312,7 @@ instance Diagnostic TcRnMessage where -> case reason of TypeCannotBeMarshaled _ why | NewtypeDataConNotInScope{} <- why -> [SuggestImportingDataCon] + | UnliftedFFITypesNeeded <- why -> [suggestExtension LangExt.UnliftedFFITypes] _ -> noHints TcRnInvalidCIdentifier{} -> noHints diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs index 7a44ab08ef..78be225cf9 100644 --- a/compiler/GHC/Tc/Errors/Types.hs +++ b/compiler/GHC/Tc/Errors/Types.hs @@ -1701,7 +1701,7 @@ data TcRnMessage where Example(s): foreign import prim "foo" foo :: ByteArray# -> (# Int#, Int# #) - Test cases: None + Test cases: ffi/should_fail/T20116 -} TcRnForeignImportPrimExtNotSet :: ForeignImport -> TcRnMessage |