[Git][ghc/ghc][wip/derive-typeable-warning] 2 commits: Add -Wderiving-typeable to -Wall

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Tue May 21 16:14:46 UTC 2024



Matthew Pickering pushed to branch wip/derive-typeable-warning at Glasgow Haskell Compiler / GHC


Commits:
20133807 by Matthew Pickering at 2024-05-21T17:14:24+01:00
Add -Wderiving-typeable to -Wall

Deriving `Typeable` does nothing, and it hasn't done for a long while.

There has also been a warning for a long while which warns you about
uselessly deriving it but it wasn't enabled in -Wall.

Fixes #24784

- - - - -
53407e3d by Matthew Pickering at 2024-05-21T17:14:24+01:00
docs: Fix formatting of changelog entries

- - - - -


11 changed files:

- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Types.hs
- compiler/GHC/JS/JStg/Syntax.hs
- compiler/GHC/JS/Syntax.hs
- compiler/GHC/Types/FieldLabel.hs
- docs/users_guide/9.12.1-notes.rst
- docs/users_guide/using-warnings.rst
- hadrian/src/Settings/Warnings.hs
- testsuite/tests/warnings/should_compile/DerivingTypeable.stderr
- utils/haddock/haddock-api/src/Haddock/Types.hs


Changes:

=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -1345,7 +1345,8 @@ minusWallOpts
         Opt_WarnRedundantRecordWildcards,
         Opt_WarnIncompleteUniPatterns,
         Opt_WarnIncompletePatternsRecUpd,
-        Opt_WarnIncompleteExportWarnings
+        Opt_WarnIncompleteExportWarnings,
+        Opt_WarnDerivingTypeable
       ]
 
 -- | Things you get with -Weverything, i.e. *all* known warnings flags


=====================================
compiler/GHC/Iface/Ext/Ast.hs
=====================================
@@ -470,7 +470,7 @@ data PScoped a = PS (Maybe Span)
                     Scope       -- ^ use site of the pattern
                     Scope       -- ^ pattern to the right of a, not including a
                     a
-  deriving (Typeable, Data) -- Pattern Scope
+  deriving (Data) -- Pattern Scope
 
 {- Note [TyVar Scopes]
    ~~~~~~~~~~~~~~~~~~~


=====================================
compiler/GHC/Iface/Ext/Types.hs
=====================================
@@ -34,7 +34,7 @@ import qualified Data.Array as A
 import qualified Data.Map as M
 import qualified Data.Set as S
 import Data.ByteString            ( ByteString )
-import Data.Data                  ( Typeable, Data )
+import Data.Data                  ( Data )
 import Data.Semigroup             ( Semigroup(..) )
 import Data.Word                  ( Word8 )
 import Control.Applicative        ( (<|>) )
@@ -668,7 +668,7 @@ data Scope
   = NoScope
   | LocalScope Span
   | ModuleScope
-    deriving (Eq, Ord, Typeable, Data)
+    deriving (Eq, Ord, Data)
 
 instance Outputable Scope where
   ppr NoScope = text "NoScope"


=====================================
compiler/GHC/JS/JStg/Syntax.hs
=====================================
@@ -105,7 +105,7 @@ data JStgStat
   | BreakStat (Maybe JsLabel)                   -- ^ Break
   | ContinueStat (Maybe JsLabel)                -- ^ Continue
   | FuncStat   !Ident [Ident] JStgStat          -- ^ an explicit function definition
-  deriving (Eq, Typeable, Generic)
+  deriving (Eq, Generic)
 
 -- | A Label used for 'JStgStat', specifically 'BreakStat', 'ContinueStat' and of
 -- course 'LabelStat'
@@ -144,7 +144,7 @@ data JStgExpr
   | UOpExpr    UOp JStgExpr               -- ^ Unary Expressions
   | IfExpr     JStgExpr JStgExpr JStgExpr  -- ^ If-expression
   | ApplExpr   JStgExpr [JStgExpr]         -- ^ Application
-  deriving (Eq, Typeable, Generic)
+  deriving (Eq, Generic)
 
 instance Outputable JStgExpr where
   ppr x = case x of
@@ -265,7 +265,7 @@ data JVal
   | JBool    Bool                       -- ^ A Boolean
   | JHash    (UniqMap FastString JStgExpr) -- ^ A JS HashMap: @{"foo": 0}@
   | JFunc    [Ident] JStgStat              -- ^ A function
-  deriving (Eq, Typeable, Generic)
+  deriving (Eq, Generic)
 
 --------------------------------------------------------------------------------
 --                            Operators
@@ -296,7 +296,7 @@ data Op
   | LOrOp           -- ^ Logical Or:             ||
   | InstanceofOp    -- ^ @instanceof@
   | InOp            -- ^ @in@
-  deriving (Show, Eq, Ord, Enum, Data, Typeable, Generic)
+  deriving (Show, Eq, Ord, Enum, Data, Generic)
 
 instance NFData Op
 
@@ -315,7 +315,7 @@ data UOp
   | PostIncOp       -- ^ Postfix Increment: @x++@
   | PreDecOp        -- ^ Prefix Decrement:  @--x@
   | PostDecOp       -- ^ Postfix Decrement: @x--@
-  deriving (Show, Eq, Ord, Enum, Data, Typeable, Generic)
+  deriving (Show, Eq, Ord, Enum, Data, Generic)
 
 instance NFData UOp
 
@@ -324,7 +324,7 @@ data AOp
   = AssignOp    -- ^ Vanilla  Assignment: =
   | AddAssignOp -- ^ Addition Assignment: +=
   | SubAssignOp -- ^ Subtraction Assignment: -=
-  deriving (Show, Eq, Ord, Enum, Data, Typeable, Generic)
+  deriving (Show, Eq, Ord, Enum, Data, Generic)
 
 instance NFData AOp
 


=====================================
compiler/GHC/JS/Syntax.hs
=====================================
@@ -129,7 +129,7 @@ data JStat
   | BreakStat (Maybe JLabel)           -- ^ Break
   | ContinueStat (Maybe JLabel)        -- ^ Continue
   | FuncStat   !Ident [Ident] JStat    -- ^ an explicit function definition
-  deriving (Eq, Typeable, Generic)
+  deriving (Eq, Generic)
 
 -- | A Label used for 'JStat', specifically 'BreakStat', 'ContinueStat' and of
 -- course 'LabelStat'
@@ -168,7 +168,7 @@ data JExpr
   | UOpExpr    UOp JExpr         -- ^ Unary Expressions
   | IfExpr     JExpr JExpr JExpr -- ^ If-expression
   | ApplExpr   JExpr [JExpr]     -- ^ Application
-  deriving (Eq, Typeable, Generic)
+  deriving (Eq, Generic)
 
 -- * Useful pattern synonyms to ease programming with the deeply embedded JS
 --   AST. Each pattern wraps @UOp@ and @Op@ into a @JExpr at s to save typing and
@@ -274,7 +274,7 @@ data JVal
   | JBool    Bool         -- ^ A Boolean
   | JHash    (UniqMap FastString JExpr) -- ^ A JS HashMap: @{"foo": 0}@
   | JFunc    [Ident] JStat             -- ^ A function
-  deriving (Eq, Typeable, Generic)
+  deriving (Eq, Generic)
 
 
 --------------------------------------------------------------------------------
@@ -307,7 +307,7 @@ data Op
   | LOrOp           -- ^ Logical Or:             ||
   | InstanceofOp    -- ^ @instanceof@
   | InOp            -- ^ @in@
-  deriving (Show, Eq, Ord, Enum, Data, Typeable, Generic)
+  deriving (Show, Eq, Ord, Enum, Data, Generic)
 
 instance NFData Op
 
@@ -326,7 +326,7 @@ data UOp
   | PostIncOp       -- ^ Postfix Increment: @x++@
   | PreDecOp        -- ^ Prefix Decrement:  @--x@
   | PostDecOp       -- ^ Postfix Decrement: @x--@
-  deriving (Show, Eq, Ord, Enum, Data, Typeable, Generic)
+  deriving (Show, Eq, Ord, Enum, Data, Generic)
 
 instance NFData UOp
 
@@ -335,7 +335,7 @@ data AOp
   = AssignOp    -- ^ Vanilla  Assignment: =
   | AddAssignOp -- ^ Addition Assignment: +=
   | SubAssignOp -- ^ Subtraction Assignment: -=
-  deriving (Show, Eq, Ord, Enum, Data, Typeable, Generic)
+  deriving (Show, Eq, Ord, Enum, Data, Generic)
 
 instance NFData AOp
 


=====================================
compiler/GHC/Types/FieldLabel.hs
=====================================
@@ -99,7 +99,7 @@ instance Uniquable FieldLabelString where
 data DuplicateRecordFields
     = DuplicateRecordFields   -- ^ Fields may be duplicated in a single module
     | NoDuplicateRecordFields -- ^ Fields must be unique within a module (the default)
-  deriving (Show, Eq, Typeable, Data)
+  deriving (Show, Eq, Data)
 
 instance Binary DuplicateRecordFields where
     put_ bh f = put_ bh (f == DuplicateRecordFields)
@@ -118,7 +118,7 @@ instance NFData DuplicateRecordFields where
 data FieldSelectors
     = FieldSelectors   -- ^ Selector functions are available (the default)
     | NoFieldSelectors -- ^ Selector functions are not available
-  deriving (Show, Eq, Typeable, Data)
+  deriving (Show, Eq, Data)
 
 instance Binary FieldSelectors where
     put_ bh f = put_ bh (f == FieldSelectors)


=====================================
docs/users_guide/9.12.1-notes.rst
=====================================
@@ -34,24 +34,26 @@ Compiler
 ~~~~~~~~
 
 - Constructor ``PluginProv`` of type ``UnivCoProvenance``, relevant
-for typing plugins, gets an extra ``DCoVarSet`` argument.
-The argument is intended to contain the in-scope coercion variables
-that the the proof represented by the coercion makes use of.
-See ``Note [The importance of tracking free coercion variables]``
-in ``GHC.Core.TyCo.Rep``, :ref:`constraint-solving-with-plugins`
-and the migration guide.
+  for typing plugins, gets an extra ``DCoVarSet`` argument.
+  The argument is intended to contain the in-scope coercion variables
+  that the the proof represented by the coercion makes use of.
+  See ``Note [The importance of tracking free coercion variables]``
+  in ``GHC.Core.TyCo.Rep``, :ref:`constraint-solving-with-plugins`
+  and the migration guide.
 
-- The flag `-fprof-late` will no longer prevent top level constructors from being statically allocated.
+- The flag :ghc-flag:`-fprof-late` will no longer prevent top level constructors from being statically allocated.
 
-  It used to be the case that we would add a cost centre for bindings like `foo = Just bar`.
-  This turned the binding into a caf that would allocate the constructor on first evaluation.
+  It used to be the case that we would add a cost centre for bindings like ``foo = Just bar``.
+  This turned the binding into a CAF that would allocate the constructor on first evaluation.
 
-  However without the cost centre `foo` can be allocated at compile time. This reduces code-bloat and
+  However without the cost centre ``foo`` can be allocated at compile time. This reduces code-bloat and
   reduces overhead for short-running applications.
 
-  The tradeoff is that calling `whoCreated` on top level value definitions like `foo` will be less informative.
+  The tradeoff is that calling ``whoCreated`` on top level value definitions like ``foo`` will be less informative.
 
-- A new flag ``-fexpose-overloaded-unfoldings`` has been added providing a lightweight alternative to ``-fexpose-all-unfoldings``.
+- A new flag :ghc-flag:`-fexpose-overloaded-unfoldings` has been added providing a lightweight alternative to :ghc-flag:`-fexpose-all-unfoldings`.
+
+- :ghc-flag:`-Wderiving-typeable` has been added to :ghc-flag:`-Wall`.
 
 GHCi
 ~~~~


=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -138,6 +138,7 @@ as ``-Wno-...`` for every individual warning in the group.
         * :ghc-flag:`-Wunused-do-bind`
         * :ghc-flag:`-Wunused-record-wildcards`
         * :ghc-flag:`-Wincomplete-export-warnings`
+        * :ghc-flag:`-Wderive-typeable`
 
 .. ghc-flag:: -Weverything
     :shortdesc: enable all warnings supported by GHC


=====================================
hadrian/src/Settings/Warnings.hs
=====================================
@@ -26,7 +26,7 @@ ghcWarningsArgs = do
     mconcat
         [ stage0 ? mconcat
         [ libraryPackage       ? pure [ "-fno-warn-deprecated-flags" ]
-        , package terminfo     ? pure [ "-fno-warn-unused-imports" ]
+        , package terminfo     ? pure [ "-fno-warn-unused-imports", "-Wno-deriving-typeable"]
         , package transformers ? pure [ "-fno-warn-unused-matches"
                                       , "-fno-warn-unused-imports" ] ]
         , notStage0 ? mconcat
@@ -51,19 +51,27 @@ ghcWarningsArgs = do
                                       , "-Wno-x-partial"
                                       , "-Wno-unused-imports"
                                       , "-Wno-redundant-constraints"
-                                      , "-Wno-simplifiable-class-constraints" ]
+                                      , "-Wno-simplifiable-class-constraints"
+                                      , "-Wno-deriving-typeable" ]
         , package pretty       ? pure [ "-Wno-unused-imports" ]
         , package primitive    ? pure [ "-Wno-unused-imports"
                                       , "-Wno-deprecations" ]
         , package rts          ? pure [ "-Wcpp-undef" ]
-        , package text         ? pure [ "-Wno-deprecations" ]
-        , package terminfo     ? pure [ "-Wno-unused-imports" ]
+        , package text         ? pure [ "-Wno-deprecations", "-Wno-deriving-typeable" ]
+        , package terminfo     ? pure [ "-Wno-unused-imports", "-Wno-deriving-typeable" ]
+        , package stm          ? pure [ "-Wno-deriving-typeable" ]
+        , package osString     ? pure [ "-Wno-deriving-typeable" ]
+        , package parsec       ? pure [ "-Wno-deriving-typeable" ]
+        , package cabal        ? pure [ "-Wno-deriving-typeable" ]
+        , package cabalSyntax  ? pure [ "-Wno-deriving-typeable" ]
+        , package time         ? pure [ "-Wno-deriving-typeable" ]
         , package transformers ? pure [ "-Wno-unused-matches"
                                       , "-Wno-unused-imports"
                                       , "-Wno-redundant-constraints"
                                       , "-Wno-orphans" ]
-        , package unix         ? pure [ "-Wno-deprecations" ]
+        , package unix         ? pure [ "-Wno-deprecations", "-Wno-deriving-typeable" ]
         , package win32        ? pure [ "-Wno-trustworthy-safe"
                                       , "-Wno-deprecations" -- https://gitlab.haskell.org/ghc/ghc/-/issues/24240
+                                      , "-Wno-deriving-typeable" ]
                                       ]
         , package xhtml        ? pure [ "-Wno-unused-imports" ] ] ]


=====================================
testsuite/tests/warnings/should_compile/DerivingTypeable.stderr
=====================================
@@ -1,4 +1,4 @@
-
-DerivingTypeable.hs:8:12: warning: [GHC-90584] [-Wderiving-typeable]
+DerivingTypeable.hs:8:12: warning: [GHC-90584] [-Wderiving-typeable (in -Wall)]
     • Deriving ‘Typeable’ has no effect: all types now auto-derive Typeable
     • In the data declaration for ‘Foo’
+


=====================================
utils/haddock/haddock-api/src/Haddock/Types.hs
=====================================
@@ -762,7 +762,6 @@ type Renamer = String -> (NameSpace -> Bool) -> [Name]
 data HaddockException
   = HaddockException String
   | WithContext [String] SomeException
-  deriving (Typeable)
 
 instance Show HaddockException where
   show (HaddockException str) = str



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/24f882669306fd4533a258007fdd123bfea6bea4...53407e3dfe892d43e809b7dfc58fa373031e4c01

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/24f882669306fd4533a258007fdd123bfea6bea4...53407e3dfe892d43e809b7dfc58fa373031e4c01
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240521/a2b546f6/attachment-0001.html>


More information about the ghc-commits mailing list