Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
eac418bb
by Recursion Ninja at 2025-12-18T13:19:48-05:00
-
e920e038
by Recursion Ninja at 2025-12-18T13:19:48-05:00
23 changed files:
- compiler/GHC/Builtin/Utils.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Warnings.hs
- compiler/GHC/Parser.y
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Types/DefaultEnv.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Unit/Module/Warnings.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- testsuite/tests/diagnostic-codes/codes.stdout
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
Changes:
| ... | ... | @@ -79,6 +79,7 @@ import GHC.Utils.Panic |
| 79 | 79 | import GHC.Utils.Constants (debugIsOn)
|
| 80 | 80 | import GHC.Parser.Annotation
|
| 81 | 81 | import GHC.Hs.Doc
|
| 82 | +import GHC.Hs.Extension (GhcPass)
|
|
| 82 | 83 | import GHC.Unit.Module.ModIface (IfaceExport)
|
| 83 | 84 | import GHC.Unit.Module.Warnings
|
| 84 | 85 | |
| ... | ... | @@ -263,7 +264,7 @@ ghcPrimNames |
| 263 | 264 | ]
|
| 264 | 265 | |
| 265 | 266 | -- See Note [GHC.Prim Deprecations]
|
| 266 | -ghcPrimWarns :: Warnings a
|
|
| 267 | +ghcPrimWarns :: Warnings (GhcPass p)
|
|
| 267 | 268 | ghcPrimWarns = WarnSome
|
| 268 | 269 | -- declaration warnings
|
| 269 | 270 | (map mk_decl_dep primOpDeprecations)
|
| ... | ... | @@ -7,7 +7,6 @@ |
| 7 | 7 | The bits common to GHC.Tc.TyCl.Instance and GHC.Tc.Deriv.
|
| 8 | 8 | -}
|
| 9 | 9 | |
| 10 | - |
|
| 11 | 10 | module GHC.Core.InstEnv (
|
| 12 | 11 | DFunId, InstMatch, ClsInstLookupResult,
|
| 13 | 12 | CanonicalEvidence(..), PotentialUnifiers(..), getCoherentUnifiers, nullUnifiers,
|
| ... | ... | @@ -54,7 +53,6 @@ import GHC.Types.Name.Set |
| 54 | 53 | import GHC.Types.Basic
|
| 55 | 54 | import GHC.Types.Id
|
| 56 | 55 | import GHC.Generics (Generic)
|
| 57 | -import Data.Data ( Data )
|
|
| 58 | 56 | import Data.List.NonEmpty ( NonEmpty (..), nonEmpty )
|
| 59 | 57 | import qualified Data.List.NonEmpty as NE
|
| 60 | 58 | import Data.Maybe ( isJust )
|
| ... | ... | @@ -113,7 +111,6 @@ data ClsInst |
| 113 | 111 | -- See Note [Implementation of deprecated instances]
|
| 114 | 112 | -- in GHC.Tc.Solver.Dict
|
| 115 | 113 | }
|
| 116 | - deriving Data
|
|
| 117 | 114 | |
| 118 | 115 | -- | A fuzzy comparison function for class instances, intended for sorting
|
| 119 | 116 | -- instances before displaying them to the user.
|
| ... | ... | @@ -1384,7 +1384,6 @@ type instance XWarning (GhcPass _) = (NamespaceSpecifier, (EpToken "[", EpT |
| 1384 | 1384 | |
| 1385 | 1385 | type instance XXWarnDecl (GhcPass _) = DataConCantHappen
|
| 1386 | 1386 | |
| 1387 | - |
|
| 1388 | 1387 | instance OutputableBndrId p
|
| 1389 | 1388 | => Outputable (WarnDecls (GhcPass p)) where
|
| 1390 | 1389 | ppr (Warnings ext decls)
|
| ... | ... | @@ -1404,7 +1403,7 @@ instance OutputableBndrId p |
| 1404 | 1403 | <+> ppr txt
|
| 1405 | 1404 | where
|
| 1406 | 1405 | ppr_category = case txt of
|
| 1407 | - WarningTxt (Just cat) _ _ -> ppr cat
|
|
| 1406 | + WarningTxt _ (Just cat) _ -> ppr cat
|
|
| 1408 | 1407 | _ -> empty
|
| 1409 | 1408 | |
| 1410 | 1409 | {-
|
| ... | ... | @@ -31,6 +31,7 @@ import GHC.Hs.ImpExp |
| 31 | 31 | import GHC.Parser.Annotation
|
| 32 | 32 | import GHC.Types.Name.Reader (WithUserRdr(..))
|
| 33 | 33 | import GHC.Data.BooleanFormula (BooleanFormula(..))
|
| 34 | +import Language.Haskell.Syntax.Decls
|
|
| 34 | 35 | import Language.Haskell.Syntax.Extension (Anno)
|
| 35 | 36 | |
| 36 | 37 | -- ---------------------------------------------------------------------
|
| ... | ... | @@ -272,6 +273,14 @@ deriving instance Data (WarnDecl GhcPs) |
| 272 | 273 | deriving instance Data (WarnDecl GhcRn)
|
| 273 | 274 | deriving instance Data (WarnDecl GhcTc)
|
| 274 | 275 | |
| 276 | +deriving instance Data (WarningTxt GhcPs)
|
|
| 277 | +deriving instance Data (WarningTxt GhcRn)
|
|
| 278 | +deriving instance Data (WarningTxt GhcTc)
|
|
| 279 | + |
|
| 280 | +deriving instance Data (InWarningCategory GhcPs)
|
|
| 281 | +deriving instance Data (InWarningCategory GhcRn)
|
|
| 282 | +deriving instance Data (InWarningCategory GhcTc)
|
|
| 283 | + |
|
| 275 | 284 | -- deriving instance (DataIdLR p p) => Data (AnnDecl p)
|
| 276 | 285 | deriving instance Data (AnnProvenance GhcPs)
|
| 277 | 286 | deriving instance Data (AnnProvenance GhcRn)
|
| ... | ... | @@ -422,8 +422,8 @@ data IfaceWarnings |
| 422 | 422 | [(IfExtName, IfaceWarningTxt)]
|
| 423 | 423 | |
| 424 | 424 | data IfaceWarningTxt
|
| 425 | - = IfWarningTxt (Maybe WarningCategory) SourceText [(IfaceStringLiteral, [IfExtName])]
|
|
| 426 | - | IfDeprecatedTxt SourceText [(IfaceStringLiteral, [IfExtName])]
|
|
| 425 | + = IfWarningTxt SourceText (Maybe WarningCategory) [(IfaceStringLiteral, [IfExtName])]
|
|
| 426 | + | IfDeprecatedTxt SourceText [(IfaceStringLiteral, [IfExtName])]
|
|
| 427 | 427 | |
| 428 | 428 | data IfaceStringLiteral
|
| 429 | 429 | = IfStringLiteral SourceText FastString
|
| ... | ... | @@ -662,7 +662,7 @@ fromIfaceWarnings = \case |
| 662 | 662 | |
| 663 | 663 | fromIfaceWarningTxt :: IfaceWarningTxt -> WarningTxt GhcRn
|
| 664 | 664 | fromIfaceWarningTxt = \case
|
| 665 | - IfWarningTxt mb_cat src strs -> WarningTxt (noLocA . fromWarningCategory <$> mb_cat) src (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
|
| 665 | + IfWarningTxt src mb_cat strs -> WarningTxt src (noLocA . fromWarningCategory <$> mb_cat) (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
|
| 666 | 666 | IfDeprecatedTxt src strs -> DeprecatedTxt src (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
| 667 | 667 | |
| 668 | 668 | fromIfaceStringLiteralWithNames :: (IfaceStringLiteral, [IfExtName]) -> WithHsDocIdentifiers StringLiteral GhcRn
|
| ... | ... | @@ -23,7 +23,7 @@ toIfaceWarnings (WarnSome vs ds) = IfWarnSome vs' ds' |
| 23 | 23 | ds' = [(occ, toIfaceWarningTxt txt) | (occ, txt) <- ds]
|
| 24 | 24 | |
| 25 | 25 | toIfaceWarningTxt :: WarningTxt GhcRn -> IfaceWarningTxt
|
| 26 | -toIfaceWarningTxt (WarningTxt mb_cat src strs) = IfWarningTxt (unLoc . iwc_wc . unLoc <$> mb_cat) src (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
|
| 26 | +toIfaceWarningTxt (WarningTxt src mb_cat strs) = IfWarningTxt src (unLoc . iwc_wc . unLoc <$> mb_cat) (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
|
| 27 | 27 | toIfaceWarningTxt (DeprecatedTxt src strs) = IfDeprecatedTxt src (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
| 28 | 28 | |
| 29 | 29 | toIfaceStringLiteralWithNames :: WithHsDocIdentifiers StringLiteral GhcRn -> (IfaceStringLiteral, [IfExtName])
|
| ... | ... | @@ -2047,12 +2047,12 @@ maybe_warning_pragma :: { Maybe (LWarningTxt GhcPs) } |
| 2047 | 2047 | {% fmap Just $ amsr (sLL $1 $> $ DeprecatedTxt (getDEPRECATED_PRAGs $1) (map stringLiteralToHsDocWst $ snd $ unLoc $2))
|
| 2048 | 2048 | (AnnPragma (glR $1) (epTok $3) (fst $ unLoc $2) noAnn noAnn noAnn noAnn) }
|
| 2049 | 2049 | | '{-# WARNING' warning_category strings '#-}'
|
| 2050 | - {% fmap Just $ amsr (sLL $1 $> $ WarningTxt $2 (getWARNING_PRAGs $1) (map stringLiteralToHsDocWst $ snd $ unLoc $3))
|
|
| 2050 | + {% fmap Just $ amsr (sLL $1 $> $ WarningTxt (getWARNING_PRAGs $1) $2 (map stringLiteralToHsDocWst $ snd $ unLoc $3))
|
|
| 2051 | 2051 | (AnnPragma (glR $1) (epTok $4) (fst $ unLoc $3) noAnn noAnn noAnn noAnn)}
|
| 2052 | 2052 | | {- empty -} { Nothing }
|
| 2053 | 2053 | |
| 2054 | -warning_category :: { Maybe (LocatedE InWarningCategory) }
|
|
| 2055 | - : 'in' STRING { Just (reLoc $ sLL $1 $> $ InWarningCategory (epTok $1) (getSTRINGs $2)
|
|
| 2054 | +warning_category :: { Maybe (LocatedE (InWarningCategory GhcPs)) }
|
|
| 2055 | + : 'in' STRING { Just (reLoc $ sLL $1 $> $ InWarningCategory (epTok $1, getSTRINGs $2)
|
|
| 2056 | 2056 | (reLoc $ sL1 $2 $ mkWarningCategory (getSTRING $2))) }
|
| 2057 | 2057 | | {- empty -} { Nothing }
|
| 2058 | 2058 | |
| ... | ... | @@ -2077,7 +2077,7 @@ warning :: { OrdList (LWarnDecl GhcPs) } |
| 2077 | 2077 | : warning_category namespace_spec namelist strings
|
| 2078 | 2078 | {% fmap unitOL $ amsA' (L (comb4 $1 $2 $3 $4)
|
| 2079 | 2079 | (Warning (unLoc $2, fst $ unLoc $4) (unLoc $3)
|
| 2080 | - (WarningTxt $1 NoSourceText $ map stringLiteralToHsDocWst $ snd $ unLoc $4))) }
|
|
| 2080 | + (WarningTxt NoSourceText $1 (map stringLiteralToHsDocWst $ snd $ unLoc $4)))) }
|
|
| 2081 | 2081 | |
| 2082 | 2082 | namespace_spec :: { Located NamespaceSpecifier }
|
| 2083 | 2083 | : 'type' { sL1 $1 $ TypeNamespaceSpecifier (epTok $1) }
|
| ... | ... | @@ -314,12 +314,16 @@ rnSrcWarnDecls bndr_set decls' |
| 314 | 314 | rdrNameOcc (unLoc x) == rdrNameOcc (unLoc y))
|
| 315 | 315 | |
| 316 | 316 | rnWarningTxt :: WarningTxt GhcPs -> RnM (WarningTxt GhcRn)
|
| 317 | -rnWarningTxt (WarningTxt mb_cat st wst) = do
|
|
| 318 | - forM_ mb_cat $ \(L _ (InWarningCategory _ _ (L loc cat))) ->
|
|
| 319 | - unless (validWarningCategory cat) $
|
|
| 320 | - addErrAt (locA loc) (TcRnInvalidWarningCategory cat)
|
|
| 317 | +rnWarningTxt (WarningTxt st mb_cat wst) = do
|
|
| 318 | + mb_cat' <- case mb_cat of
|
|
| 319 | + Nothing -> pure Nothing
|
|
| 320 | + Just (L x (InWarningCategory y (L loc cat))) -> do
|
|
| 321 | + unless (validWarningCategory cat) $
|
|
| 322 | + addErrAt (locA loc) (TcRnInvalidWarningCategory cat)
|
|
| 323 | + pure . Just $ L x (InWarningCategory y (L loc cat))
|
|
| 321 | 324 | wst' <- traverse (traverse rnHsDoc) wst
|
| 322 | - pure (WarningTxt mb_cat st wst')
|
|
| 325 | + pure (WarningTxt st mb_cat' wst')
|
|
| 326 | + |
|
| 323 | 327 | rnWarningTxt (DeprecatedTxt st wst) = do
|
| 324 | 328 | wst' <- traverse (traverse rnHsDoc) wst
|
| 325 | 329 | pure (DeprecatedTxt st wst')
|
| ... | ... | @@ -66,7 +66,6 @@ import GHC.Data.Bag ( mapBagM, headMaybe ) |
| 66 | 66 | import Control.Monad
|
| 67 | 67 | import GHC.Settings.Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE )
|
| 68 | 68 | import GHC.Unit.Module
|
| 69 | -import GHC.Unit.Module.Warnings ( WarningTxt(..) )
|
|
| 70 | 69 | import GHC.Iface.Load
|
| 71 | 70 | import qualified GHC.LanguageExtensions as LangExt
|
| 72 | 71 |
| ... | ... | @@ -56,7 +56,6 @@ import GHC.Types.Var.Env |
| 56 | 56 | import GHC.Types.Var.Set
|
| 57 | 57 | import GHC.Types.SrcLoc
|
| 58 | 58 | |
| 59 | -import GHC.Unit.Module.Warnings
|
|
| 60 | 59 | import GHC.Builtin.Names
|
| 61 | 60 | |
| 62 | 61 | import GHC.Utils.Error
|
| ... | ... | @@ -52,7 +52,6 @@ import GHC.Core.Type |
| 52 | 52 | import GHC.Hs
|
| 53 | 53 | import GHC.Driver.Session
|
| 54 | 54 | import GHC.Unit.Module (getModule)
|
| 55 | -import GHC.Unit.Module.Warnings
|
|
| 56 | 55 | import GHC.Unit.Module.ModIface (mi_fix)
|
| 57 | 56 | |
| 58 | 57 | import GHC.Iface.Load (loadInterfaceForName)
|
| ... | ... | @@ -1835,7 +1835,7 @@ instance Diagnostic TcRnMessage where |
| 1835 | 1835 | nest 2 (vcat (map (ppr . hsDocString . unLoc) msg)) ]
|
| 1836 | 1836 | where
|
| 1837 | 1837 | (extra, msg) = case txt of
|
| 1838 | - WarningTxt _ _ msg -> ("", msg)
|
|
| 1838 | + WarningTxt _ _ msg -> ("", msg)
|
|
| 1839 | 1839 | DeprecatedTxt _ msg -> (" is deprecated", msg)
|
| 1840 | 1840 | TcRnRedundantSourceImport mod_name
|
| 1841 | 1841 | -> mkSimpleDecorated $
|
| ... | ... | @@ -213,7 +213,6 @@ import GHC.Types.DefaultEnv (ClassDefaults) |
| 213 | 213 | |
| 214 | 214 | import GHC.Unit.Types (Module)
|
| 215 | 215 | import GHC.Unit.State (UnitState)
|
| 216 | -import GHC.Unit.Module.Warnings (WarningCategory, WarningTxt)
|
|
| 217 | 216 | import GHC.Unit.Module.ModIface (ModIface)
|
| 218 | 217 | |
| 219 | 218 | import GHC.Utils.Outputable
|
| ... | ... | @@ -60,7 +60,6 @@ import GHC.Core.PatSyn |
| 60 | 60 | import GHC.Core.Multiplicity ( scaledThing )
|
| 61 | 61 | |
| 62 | 62 | import GHC.Unit.Module
|
| 63 | -import GHC.Unit.Module.Warnings
|
|
| 64 | 63 | import GHC.Types.Id
|
| 65 | 64 | import GHC.Types.Name
|
| 66 | 65 | import GHC.Types.Name.Reader
|
| ... | ... | @@ -89,7 +89,6 @@ import GHC.Utils.Unique (sameUnique) |
| 89 | 89 | |
| 90 | 90 | import GHC.Unit.State
|
| 91 | 91 | import GHC.Unit.External
|
| 92 | -import GHC.Unit.Module.Warnings
|
|
| 93 | 92 | |
| 94 | 93 | import Data.List ( mapAccumL )
|
| 95 | 94 | import qualified Data.List.NonEmpty as NE
|
| ... | ... | @@ -18,13 +18,12 @@ where |
| 18 | 18 | |
| 19 | 19 | import GHC.Core.Class (Class (className))
|
| 20 | 20 | import GHC.Prelude
|
| 21 | -import GHC.Hs.Extension (GhcRn)
|
|
| 21 | +import GHC.Hs
|
|
| 22 | 22 | import GHC.Tc.Utils.TcType (Type)
|
| 23 | 23 | import GHC.Types.Name (Name, nameUnique, stableNameCmp)
|
| 24 | 24 | import GHC.Types.Name.Env
|
| 25 | 25 | import GHC.Types.Unique.FM (lookupUFM_Directly)
|
| 26 | 26 | import GHC.Types.SrcLoc (SrcSpan)
|
| 27 | -import GHC.Unit.Module.Warnings (WarningTxt)
|
|
| 28 | 27 | import GHC.Unit.Types (Module)
|
| 29 | 28 | import GHC.Utils.Outputable
|
| 30 | 29 |
| ... | ... | @@ -761,6 +761,7 @@ type family GhcDiagnosticCode c = n | n -> c where |
| 761 | 761 | -- TcRnPragmaWarning
|
| 762 | 762 | GhcDiagnosticCode "WarningTxt" = 63394
|
| 763 | 763 | GhcDiagnosticCode "DeprecatedTxt" = 68441
|
| 764 | + GhcDiagnosticCode "XWarningTxt" = 68077
|
|
| 764 | 765 | |
| 765 | 766 | -- TcRnRunSliceFailure/ConversionFail
|
| 766 | 767 | GhcDiagnosticCode "IllegalOccName" = 55017
|
| 1 | 1 | {-# LANGUAGE UndecidableInstances #-}
|
| 2 | 2 | {-# LANGUAGE TypeFamilies #-}
|
| 3 | 3 | |
| 4 | +-- Eq instances for WarningTxt, InWarningCategory
|
|
| 5 | +{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
| 6 | + |
|
| 4 | 7 | -- | Warnings for a module
|
| 5 | 8 | module GHC.Unit.Module.Warnings
|
| 6 | 9 | ( WarningCategory(..)
|
| ... | ... | @@ -38,7 +41,7 @@ where |
| 38 | 41 | |
| 39 | 42 | import GHC.Prelude
|
| 40 | 43 | |
| 41 | -import GHC.Data.FastString (FastString, mkFastString, unpackFS)
|
|
| 44 | +import GHC.Data.FastString (mkFastString, unpackFS)
|
|
| 42 | 45 | import GHC.Types.SourceText
|
| 43 | 46 | import GHC.Types.Name.Occurrence
|
| 44 | 47 | import GHC.Types.Name.Env
|
| ... | ... | @@ -55,77 +58,15 @@ import GHC.Utils.Binary |
| 55 | 58 | import GHC.Unicode
|
| 56 | 59 | |
| 57 | 60 | import Language.Haskell.Syntax.Extension
|
| 61 | +import Language.Haskell.Syntax.Decls
|
|
| 58 | 62 | |
| 59 | -import Data.Data
|
|
| 60 | 63 | import Data.List (isPrefixOf)
|
| 61 | -import GHC.Generics ( Generic )
|
|
| 62 | -import Control.DeepSeq
|
|
| 63 | - |
|
| 64 | - |
|
| 65 | -{-
|
|
| 66 | -Note [Warning categories]
|
|
| 67 | -~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 68 | -See GHC Proposal 541 for the design of the warning categories feature:
|
|
| 69 | -https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst
|
|
| 70 | - |
|
| 71 | -A WARNING pragma may be annotated with a category such as "x-partial" written
|
|
| 72 | -after the 'in' keyword, like this:
|
|
| 73 | - |
|
| 74 | - {-# WARNING in "x-partial" head "This function is partial..." #-}
|
|
| 75 | - |
|
| 76 | -This is represented by the 'Maybe (Located WarningCategory)' field in
|
|
| 77 | -'WarningTxt'. The parser will accept an arbitrary string as the category name,
|
|
| 78 | -then the renamer (in 'rnWarningTxt') will check it contains only valid
|
|
| 79 | -characters, so we can generate a nicer error message than a parse error.
|
|
| 80 | - |
|
| 81 | -The corresponding warnings can then be controlled with the -Wx-partial,
|
|
| 82 | --Wno-x-partial, -Werror=x-partial and -Wwarn=x-partial flags. Such a flag is
|
|
| 83 | -distinguished from an 'unrecognisedWarning' by the flag parser testing
|
|
| 84 | -'validWarningCategory'. The 'x-' prefix means we can still usually report an
|
|
| 85 | -unrecognised warning where the user has made a mistake.
|
|
| 86 | - |
|
| 87 | -A DEPRECATED pragma may not have a user-defined category, and is always treated
|
|
| 88 | -as belonging to the special category 'deprecations'. Similarly, a WARNING
|
|
| 89 | -pragma without a category belongs to the 'deprecations' category.
|
|
| 90 | -Thus the '-Wdeprecations' flag will enable all of the following:
|
|
| 91 | - |
|
| 92 | - {-# WARNING in "deprecations" foo "This function is deprecated..." #-}
|
|
| 93 | - {-# WARNING foo "This function is deprecated..." #-}
|
|
| 94 | - {-# DEPRECATED foo "This function is deprecated..." #-}
|
|
| 95 | - |
|
| 96 | -The '-Wwarnings-deprecations' flag is supported for backwards compatibility
|
|
| 97 | -purposes as being equivalent to '-Wdeprecations'.
|
|
| 98 | - |
|
| 99 | -The '-Wextended-warnings' warning group collects together all warnings with
|
|
| 100 | -user-defined categories, so they can be enabled or disabled
|
|
| 101 | -collectively. Moreover they are treated as being part of other warning groups
|
|
| 102 | -such as '-Wdefault' (see 'warningGroupIncludesExtendedWarnings').
|
|
| 103 | - |
|
| 104 | -'DynFlags' and 'DiagOpts' each contain a set of enabled and a set of fatal
|
|
| 105 | -warning categories, just as they do for the finite enumeration of 'WarningFlag's
|
|
| 106 | -built in to GHC. These are represented as 'WarningCategorySet's to allow for
|
|
| 107 | -the possibility of them being infinite.
|
|
| 108 | - |
|
| 109 | --}
|
|
| 110 | 64 | |
| 111 | -data InWarningCategory
|
|
| 112 | - = InWarningCategory
|
|
| 113 | - { iwc_in :: !(EpToken "in"),
|
|
| 114 | - iwc_st :: !SourceText,
|
|
| 115 | - iwc_wc :: (LocatedE WarningCategory)
|
|
| 116 | - } deriving Data
|
|
| 117 | 65 | |
| 118 | -fromWarningCategory :: WarningCategory -> InWarningCategory
|
|
| 119 | -fromWarningCategory wc = InWarningCategory noAnn NoSourceText (noLocA wc)
|
|
| 120 | - |
|
| 121 | - |
|
| 122 | --- See Note [Warning categories]
|
|
| 123 | -newtype WarningCategory = WarningCategory FastString
|
|
| 124 | - deriving stock Data
|
|
| 125 | - deriving newtype (Binary, Eq, Outputable, Show, Uniquable, NFData)
|
|
| 126 | - |
|
| 127 | -mkWarningCategory :: FastString -> WarningCategory
|
|
| 128 | -mkWarningCategory = WarningCategory
|
|
| 66 | +fromWarningCategory ::
|
|
| 67 | + HasAnnotation (Anno WarningCategory) =>
|
|
| 68 | + WarningCategory -> InWarningCategory (GhcPass p)
|
|
| 69 | +fromWarningCategory wc = InWarningCategory (noAnn, NoSourceText) (noLocA wc)
|
|
| 129 | 70 | |
| 130 | 71 | -- | The @deprecations@ category is used for all DEPRECATED pragmas and for
|
| 131 | 72 | -- WARNING pragmas that do not specify a category.
|
| ... | ... | @@ -143,7 +84,6 @@ validWarningCategory cat@(WarningCategory c) = |
| 143 | 84 | s = unpackFS c
|
| 144 | 85 | is_allowed c = isAlphaNum c || c == '\'' || c == '-'
|
| 145 | 86 | |
| 146 | - |
|
| 147 | 87 | -- | A finite or infinite set of warning categories.
|
| 148 | 88 | --
|
| 149 | 89 | -- Unlike 'WarningFlag', there are (in principle) infinitely many warning
|
| ... | ... | @@ -188,66 +128,74 @@ deleteWarningCategorySet c (CofiniteWarningCategorySet s) = CofiniteWarningCateg |
| 188 | 128 | |
| 189 | 129 | type LWarningTxt pass = XRec pass (WarningTxt pass)
|
| 190 | 130 | |
| 191 | --- | Warning Text
|
|
| 192 | ---
|
|
| 193 | --- reason/explanation from a WARNING or DEPRECATED pragma
|
|
| 194 | -data WarningTxt pass
|
|
| 195 | - = WarningTxt
|
|
| 196 | - (Maybe (LocatedE InWarningCategory))
|
|
| 197 | - -- ^ Warning category attached to this WARNING pragma, if any;
|
|
| 198 | - -- see Note [Warning categories]
|
|
| 199 | - SourceText
|
|
| 200 | - [LocatedE (WithHsDocIdentifiers StringLiteral pass)]
|
|
| 201 | - | DeprecatedTxt
|
|
| 202 | - SourceText
|
|
| 203 | - [LocatedE (WithHsDocIdentifiers StringLiteral pass)]
|
|
| 204 | - deriving Generic
|
|
| 205 | - |
|
| 206 | 131 | -- | To which warning category does this WARNING or DEPRECATED pragma belong?
|
| 207 | 132 | -- See Note [Warning categories].
|
| 208 | -warningTxtCategory :: WarningTxt pass -> WarningCategory
|
|
| 209 | -warningTxtCategory (WarningTxt (Just (L _ (InWarningCategory _ _ (L _ cat)))) _ _) = cat
|
|
| 133 | +warningTxtCategory :: WarningTxt (GhcPass p) -> WarningCategory
|
|
| 134 | +warningTxtCategory (WarningTxt _ (Just (L _ (InWarningCategory _ (L _ cat)))) _) = cat
|
|
| 210 | 135 | warningTxtCategory _ = defaultWarningCategory
|
| 211 | 136 | |
| 137 | + |
|
| 212 | 138 | -- | The message that the WarningTxt was specified to output
|
| 213 | -warningTxtMessage :: WarningTxt p -> [LocatedE (WithHsDocIdentifiers StringLiteral p)]
|
|
| 214 | -warningTxtMessage (WarningTxt _ _ m) = m
|
|
| 139 | +warningTxtMessage :: WarningTxt (GhcPass p) -> [LocatedE (WithHsDocIdentifiers StringLiteral (GhcPass p))]
|
|
| 140 | +warningTxtMessage (WarningTxt _ _ m) = m
|
|
| 215 | 141 | warningTxtMessage (DeprecatedTxt _ m) = m
|
| 216 | 142 | |
| 217 | 143 | -- | True if the 2 WarningTxts have the same category and messages
|
| 218 | -warningTxtSame :: WarningTxt p1 -> WarningTxt p2 -> Bool
|
|
| 144 | +warningTxtSame :: WarningTxt (GhcPass p) -> WarningTxt (GhcPass p) -> Bool
|
|
| 219 | 145 | warningTxtSame w1 w2
|
| 220 | 146 | = warningTxtCategory w1 == warningTxtCategory w2
|
| 221 | 147 | && literal_message w1 == literal_message w2
|
| 222 | 148 | && same_type
|
| 223 | 149 | where
|
| 224 | - literal_message :: WarningTxt p -> [StringLiteral]
|
|
| 150 | + literal_message :: WarningTxt (GhcPass p) -> [StringLiteral]
|
|
| 225 | 151 | literal_message = map (hsDocString . unLoc) . warningTxtMessage
|
| 226 | 152 | same_type | DeprecatedTxt {} <- w1, DeprecatedTxt {} <- w2 = True
|
| 227 | - | WarningTxt {} <- w1, WarningTxt {} <- w2 = True
|
|
| 153 | + | WarningTxt {} <- w1, WarningTxt {} <- w2 = True
|
|
| 228 | 154 | | otherwise = False
|
| 229 | 155 | |
| 230 | -deriving instance Eq InWarningCategory
|
|
| 156 | +instance Outputable (InWarningCategory (GhcPass pass)) where
|
|
| 157 | + ppr (InWarningCategory _ wt) = text "in" <+> doubleQuotes (ppr wt)
|
|
| 231 | 158 | |
| 232 | -deriving instance (Eq (IdP pass)) => Eq (WarningTxt pass)
|
|
| 233 | -deriving instance (Data pass, Data (IdP pass)) => Data (WarningTxt pass)
|
|
| 159 | +type instance XDeprecatedTxt (GhcPass _) = SourceText
|
|
| 160 | +type instance XWarningTxt (GhcPass _) = SourceText
|
|
| 161 | +type instance XXWarningTxt (GhcPass _) = DataConCantHappen
|
|
| 162 | +type instance XInWarningCategory (GhcPass _) = (EpToken "in", SourceText)
|
|
| 163 | +type instance XXInWarningCategory (GhcPass _) = DataConCantHappen
|
|
| 234 | 164 | |
| 165 | +type instance Anno (WithHsDocIdentifiers StringLiteral pass) = EpaLocation
|
|
| 166 | +type instance Anno (InWarningCategory (GhcPass pass)) = EpaLocation
|
|
| 167 | +type instance Anno (WarningCategory) = EpaLocation
|
|
| 235 | 168 | type instance Anno (WarningTxt (GhcPass pass)) = SrcSpanAnnP
|
| 236 | 169 | |
| 237 | -instance Outputable InWarningCategory where
|
|
| 238 | - ppr (InWarningCategory _ _ wt) = text "in" <+> doubleQuotes (ppr wt)
|
|
| 170 | +deriving stock instance Eq (WarningTxt GhcPs)
|
|
| 171 | +deriving stock instance Eq (WarningTxt GhcRn)
|
|
| 172 | +deriving stock instance Eq (WarningTxt GhcTc)
|
|
| 173 | + |
|
| 174 | +deriving stock instance Eq (InWarningCategory GhcPs)
|
|
| 175 | +deriving stock instance Eq (InWarningCategory GhcRn)
|
|
| 176 | +deriving stock instance Eq (InWarningCategory GhcTc)
|
|
| 177 | + |
|
| 178 | +-- TODO: Move to respecitive type-class definition modules after removing
|
|
| 179 | +-- the Language.Haskell.Syntax.Decls module's dependency on GHC.Hs.Doc.
|
|
| 180 | +-- Subsequently, create a Language.Haskell.Syntax.Decls.Warnings sub-module
|
|
| 181 | +-- with the "warning declaration" types and have Language.Haskell.Syntax.Decls
|
|
| 182 | +-- re-export Language.Haskell.Syntax.Decls.Warnings. This will prevent cyclic
|
|
| 183 | +-- import, but it will only work once GHC.Hs.Doc is no longer a GHC dependency.
|
|
| 184 | +deriving instance Binary WarningCategory
|
|
| 239 | 185 | |
| 186 | +deriving instance Outputable WarningCategory
|
|
| 240 | 187 | |
| 241 | -instance Outputable (WarningTxt pass) where
|
|
| 242 | - ppr (WarningTxt mcat lsrc ws)
|
|
| 188 | +deriving instance Uniquable WarningCategory
|
|
| 189 | + |
|
| 190 | +instance Outputable (WarningTxt (GhcPass pass)) where
|
|
| 191 | + ppr (WarningTxt lsrc mcat ws)
|
|
| 243 | 192 | = case lsrc of
|
| 244 | 193 | NoSourceText -> pp_ws ws
|
| 245 | 194 | SourceText src -> ftext src <+> ctg_doc <+> pp_ws ws <+> text "#-}"
|
| 246 | 195 | where
|
| 247 | 196 | ctg_doc = maybe empty (\ctg -> ppr ctg) mcat
|
| 248 | 197 | |
| 249 | - |
|
| 250 | - ppr (DeprecatedTxt lsrc ds)
|
|
| 198 | + ppr (DeprecatedTxt lsrc ds)
|
|
| 251 | 199 | = case lsrc of
|
| 252 | 200 | NoSourceText -> pp_ws ds
|
| 253 | 201 | SourceText src -> ftext src <+> pp_ws ds <+> text "#-}"
|
| ... | ... | @@ -260,7 +208,7 @@ pp_ws ws |
| 260 | 208 | <+> text "]"
|
| 261 | 209 | |
| 262 | 210 | |
| 263 | -pprWarningTxtForMsg :: WarningTxt p -> SDoc
|
|
| 211 | +pprWarningTxtForMsg :: WarningTxt (GhcPass pass) -> SDoc
|
|
| 264 | 212 | pprWarningTxtForMsg (WarningTxt _ _ ws)
|
| 265 | 213 | = doubleQuotes (vcat (map (ftext . sl_fs . hsDocString . unLoc) ws))
|
| 266 | 214 | pprWarningTxtForMsg (DeprecatedTxt _ ds)
|
| ... | ... | @@ -306,8 +254,6 @@ type DeclWarnOccNames pass = [(OccName, WarningTxt pass)] |
| 306 | 254 | -- | Names that are deprecated as exports
|
| 307 | 255 | type ExportWarnNames pass = [(Name, WarningTxt pass)]
|
| 308 | 256 | |
| 309 | -deriving instance Eq (IdP pass) => Eq (Warnings pass)
|
|
| 310 | - |
|
| 311 | 257 | emptyWarn :: Warnings p
|
| 312 | 258 | emptyWarn = WarnSome [] []
|
| 313 | 259 |
| ... | ... | @@ -72,7 +72,18 @@ module Language.Haskell.Syntax.Decls ( |
| 72 | 72 | FamilyResultSig(..), LFamilyResultSig, InjectivityAnn(..), LInjectivityAnn,
|
| 73 | 73 | |
| 74 | 74 | -- * Grouping
|
| 75 | - HsGroup(..)
|
|
| 75 | + HsGroup(..),
|
|
| 76 | + |
|
| 77 | + -- * Warnings
|
|
| 78 | + WarningTxt(..),
|
|
| 79 | + WarningCategory(..),
|
|
| 80 | + mkWarningCategory,
|
|
| 81 | + InWarningCategory(..),
|
|
| 82 | + -- ** Extension
|
|
| 83 | + XDeprecatedTxt,
|
|
| 84 | + XWarningTxt,
|
|
| 85 | + XXWarningTxt,
|
|
| 86 | + XInWarningCategory,
|
|
| 76 | 87 | ) where
|
| 77 | 88 | |
| 78 | 89 | -- friends:
|
| ... | ... | @@ -90,12 +101,14 @@ import GHC.Types.Basic (TopLevelFlag, OverlapMode, RuleName, Activation |
| 90 | 101 | ,TyConFlavour(..), TypeOrData(..), NewOrData(..))
|
| 91 | 102 | import GHC.Types.ForeignCall (CType, CCallConv, Safety, Header, CLabelString, CCallTarget, CExportSpec)
|
| 92 | 103 | |
| 93 | -import GHC.Unit.Module.Warnings (WarningTxt)
|
|
| 94 | - |
|
| 104 | +import GHC.Data.FastString (FastString)
|
|
| 95 | 105 | import GHC.Hs.Doc (LHsDoc) -- ROMES:TODO Discuss in #21592 whether this is parsed AST or base AST
|
| 106 | +import GHC.Hs.Doc (WithHsDocIdentifiers)
|
|
| 107 | +import GHC.Types.SourceText (StringLiteral)
|
|
| 96 | 108 | |
| 97 | -import Control.Monad
|
|
| 109 | +import Control.DeepSeq
|
|
| 98 | 110 | import Control.Exception (assert)
|
| 111 | +import Control.Monad
|
|
| 99 | 112 | import Data.Data hiding (TyCon, Fixity, Infix)
|
| 100 | 113 | import Data.Maybe
|
| 101 | 114 | import Data.String
|
| ... | ... | @@ -106,6 +119,8 @@ import Prelude (Show) |
| 106 | 119 | import Data.Foldable
|
| 107 | 120 | import Data.Traversable
|
| 108 | 121 | import Data.List.NonEmpty (NonEmpty (..))
|
| 122 | +import GHC.Generics ( Generic )
|
|
| 123 | + |
|
| 109 | 124 | |
| 110 | 125 | {-
|
| 111 | 126 | ************************************************************************
|
| ... | ... | @@ -1578,3 +1593,85 @@ data RoleAnnotDecl pass |
| 1578 | 1593 | (LIdP pass) -- type constructor
|
| 1579 | 1594 | [XRec pass (Maybe Role)] -- optional annotations
|
| 1580 | 1595 | | XRoleAnnotDecl !(XXRoleAnnotDecl pass)
|
| 1596 | + |
|
| 1597 | +{-
|
|
| 1598 | +************************************************************************
|
|
| 1599 | +* *
|
|
| 1600 | +\subsection[WarnAnnot]{Warning annotations}
|
|
| 1601 | +* *
|
|
| 1602 | +************************************************************************
|
|
| 1603 | +-}
|
|
| 1604 | + |
|
| 1605 | +-- | Warning Text
|
|
| 1606 | +--
|
|
| 1607 | +-- reason/explanation from a WARNING or DEPRECATED pragma
|
|
| 1608 | +data WarningTxt pass
|
|
| 1609 | + = DeprecatedTxt
|
|
| 1610 | + (XDeprecatedTxt pass)
|
|
| 1611 | + [XRec pass (WithHsDocIdentifiers StringLiteral pass)]
|
|
| 1612 | + | WarningTxt
|
|
| 1613 | + (XWarningTxt pass)
|
|
| 1614 | + (Maybe (XRec pass (InWarningCategory pass)))
|
|
| 1615 | + -- ^ Warning category attached to this WARNING pragma, if any;
|
|
| 1616 | + -- see Note [Warning categories]
|
|
| 1617 | + [XRec pass (WithHsDocIdentifiers StringLiteral pass)]
|
|
| 1618 | + | XWarningTxt !(XXWarningTxt pass)
|
|
| 1619 | + deriving Generic
|
|
| 1620 | + |
|
| 1621 | +{-
|
|
| 1622 | +Note [Warning categories]
|
|
| 1623 | +~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 1624 | +See GHC Proposal 541 for the design of the warning categories feature:
|
|
| 1625 | +https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst
|
|
| 1626 | + |
|
| 1627 | +A WARNING pragma may be annotated with a category such as "x-partial" written
|
|
| 1628 | +after the 'in' keyword, like this:
|
|
| 1629 | + |
|
| 1630 | + {-# WARNING in "x-partial" head "This function is partial..." #-}
|
|
| 1631 | + |
|
| 1632 | +This is represented by the 'Maybe (Located WarningCategory)' field in
|
|
| 1633 | +'WarningTxt'. The parser will accept an arbitrary string as the category name,
|
|
| 1634 | +then the renamer (in 'rnWarningTxt') will check it contains only valid
|
|
| 1635 | +characters, so we can generate a nicer error message than a parse error.
|
|
| 1636 | + |
|
| 1637 | +The corresponding warnings can then be controlled with the -Wx-partial,
|
|
| 1638 | +-Wno-x-partial, -Werror=x-partial and -Wwarn=x-partial flags. Such a flag is
|
|
| 1639 | +distinguished from an 'unrecognisedWarning' by the flag parser testing
|
|
| 1640 | +'validWarningCategory'. The 'x-' prefix means we can still usually report an
|
|
| 1641 | +unrecognised warning where the user has made a mistake.
|
|
| 1642 | + |
|
| 1643 | +A DEPRECATED pragma may not have a user-defined category, and is always treated
|
|
| 1644 | +as belonging to the special category 'deprecations'. Similarly, a WARNING
|
|
| 1645 | +pragma without a category belongs to the 'deprecations' category.
|
|
| 1646 | +Thus the '-Wdeprecations' flag will enable all of the following:
|
|
| 1647 | + |
|
| 1648 | + {-# WARNING in "deprecations" foo "This function is deprecated..." #-}
|
|
| 1649 | + {-# WARNING foo "This function is deprecated..." #-}
|
|
| 1650 | + {-# DEPRECATED foo "This function is deprecated..." #-}
|
|
| 1651 | +The '-Wwarnings-deprecations' flag is supported for backwards compatibility
|
|
| 1652 | +purposes as being equivalent to '-Wdeprecations'.
|
|
| 1653 | + |
|
| 1654 | +The '-Wextended-warnings' warning group collects together all warnings with
|
|
| 1655 | +user-defined categories, so they can be enabled or disabled
|
|
| 1656 | +collectively. Moreover they are treated as being part of other warning groups
|
|
| 1657 | +such as '-Wdefault' (see 'warningGroupIncludesExtendedWarnings').
|
|
| 1658 | + |
|
| 1659 | +'DynFlags' and 'DiagOpts' each contain a set of enabled and a set of fatal
|
|
| 1660 | +warning categories, just as they do for the finite enumeration of 'WarningFlag's
|
|
| 1661 | +built in to GHC. These are represented as 'WarningCategorySet's to allow for
|
|
| 1662 | +the possibility of them being infinite.
|
|
| 1663 | + |
|
| 1664 | +-}
|
|
| 1665 | +data InWarningCategory pass
|
|
| 1666 | + = InWarningCategory
|
|
| 1667 | + { iwc_st :: (XInWarningCategory pass),
|
|
| 1668 | + iwc_wc :: (XRec pass WarningCategory)
|
|
| 1669 | + }
|
|
| 1670 | + | XInWarningCategory !(XXInWarningCategory pass)
|
|
| 1671 | + |
|
| 1672 | +newtype WarningCategory = WarningCategory FastString
|
|
| 1673 | + deriving stock (Data)
|
|
| 1674 | + deriving newtype (Eq, Show, NFData)
|
|
| 1675 | + |
|
| 1676 | +mkWarningCategory :: FastString -> WarningCategory
|
|
| 1677 | +mkWarningCategory = WarningCategory |
| ... | ... | @@ -410,6 +410,17 @@ type family XXWarnDecls x |
| 410 | 410 | type family XWarning x
|
| 411 | 411 | type family XXWarnDecl x
|
| 412 | 412 | |
| 413 | +-- -------------------------------------
|
|
| 414 | +-- WarningTxt type families
|
|
| 415 | +type family XDeprecatedTxt x
|
|
| 416 | +type family XWarningTxt x
|
|
| 417 | +type family XXWarningTxt x
|
|
| 418 | + |
|
| 419 | +-- -------------------------------------
|
|
| 420 | +-- InWarningCategory type families
|
|
| 421 | +type family XInWarningCategory x
|
|
| 422 | +type family XXInWarningCategory x
|
|
| 423 | + |
|
| 413 | 424 | -- -------------------------------------
|
| 414 | 425 | -- AnnDecl type families
|
| 415 | 426 | type family XHsAnnotation x
|
| ... | ... | @@ -70,6 +70,7 @@ |
| 70 | 70 | [GHC-99991] is untested (constructor = TyVarMissingInEnv)
|
| 71 | 71 | [GHC-92834] is untested (constructor = BadCoercionRole)
|
| 72 | 72 | [GHC-93008] is untested (constructor = HsigShapeSortMismatch)
|
| 73 | +[GHC-68077] is untested (constructor = XWarningTxt)
|
|
| 73 | 74 | [GHC-68444] is untested (constructor = SumAltArityExceeded)
|
| 74 | 75 | [GHC-63966] is untested (constructor = IllegalSumAlt)
|
| 75 | 76 | [GHC-28709] is untested (constructor = MalformedType)
|
| ... | ... | @@ -53,7 +53,6 @@ import GHC.Types.PkgQual |
| 53 | 53 | import GHC.Types.SourceText
|
| 54 | 54 | import GHC.Types.SrcLoc
|
| 55 | 55 | import GHC.Types.Var
|
| 56 | -import GHC.Unit.Module.Warnings
|
|
| 57 | 56 | import GHC.Utils.Misc
|
| 58 | 57 | import GHC.Utils.Outputable hiding ( (<>) )
|
| 59 | 58 | import GHC.Utils.Panic
|
| ... | ... | @@ -1570,14 +1569,14 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where |
| 1570 | 1569 | getAnnotationEntry = entryFromLocatedA
|
| 1571 | 1570 | setAnnotationAnchor = setAnchorAn
|
| 1572 | 1571 | |
| 1573 | - exact (L (EpAnn l (AnnPragma o c (os,cs) l1 l2 t m) css) (WarningTxt mb_cat src ws)) = do
|
|
| 1572 | + exact (L (EpAnn l (AnnPragma o c (os,cs) l1 l2 t m) css) (WarningTxt src mb_cat ws)) = do
|
|
| 1574 | 1573 | o' <- markAnnOpen'' o src "{-# WARNING"
|
| 1575 | 1574 | mb_cat' <- markAnnotated mb_cat
|
| 1576 | 1575 | os' <- markEpToken os
|
| 1577 | 1576 | ws' <- markAnnotated ws
|
| 1578 | 1577 | cs' <- markEpToken cs
|
| 1579 | 1578 | c' <- markEpToken c
|
| 1580 | - return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (WarningTxt mb_cat' src ws'))
|
|
| 1579 | + return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (WarningTxt src mb_cat' ws'))
|
|
| 1581 | 1580 | |
| 1582 | 1581 | exact (L (EpAnn l (AnnPragma o c (os,cs) l1 l2 t m) css) (DeprecatedTxt src ws)) = do
|
| 1583 | 1582 | o' <- markAnnOpen'' o src "{-# DEPRECATED"
|
| ... | ... | @@ -1587,14 +1586,14 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where |
| 1587 | 1586 | c' <- markEpToken c
|
| 1588 | 1587 | return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (DeprecatedTxt src ws'))
|
| 1589 | 1588 | |
| 1590 | -instance ExactPrint InWarningCategory where
|
|
| 1589 | +instance Typeable p => ExactPrint (InWarningCategory (GhcPass p)) where
|
|
| 1591 | 1590 | getAnnotationEntry _ = NoEntryVal
|
| 1592 | 1591 | setAnnotationAnchor a _ _ _ = a
|
| 1593 | 1592 | |
| 1594 | - exact (InWarningCategory tkIn source (L l wc)) = do
|
|
| 1593 | + exact (InWarningCategory (tkIn, source) (L l wc)) = do
|
|
| 1595 | 1594 | tkIn' <- markEpToken tkIn
|
| 1596 | 1595 | L l' (_,wc') <- markAnnotated (L l (source, wc))
|
| 1597 | - return (InWarningCategory tkIn' source (L l' wc'))
|
|
| 1596 | + return (InWarningCategory (tkIn', source) (L l' wc'))
|
|
| 1598 | 1597 | |
| 1599 | 1598 | instance ExactPrint (SourceText, WarningCategory) where
|
| 1600 | 1599 | getAnnotationEntry _ = NoEntryVal
|
| ... | ... | @@ -1935,14 +1934,14 @@ instance ExactPrint (WarnDecl GhcPs) where |
| 1935 | 1934 | getAnnotationEntry _ = NoEntryVal
|
| 1936 | 1935 | setAnnotationAnchor a _ _ _ = a
|
| 1937 | 1936 | |
| 1938 | - exact (Warning (ns_spec, (o,c)) lns (WarningTxt mb_cat src ls )) = do
|
|
| 1937 | + exact (Warning (ns_spec, (o,c)) lns (WarningTxt src mb_cat ls )) = do
|
|
| 1939 | 1938 | mb_cat' <- markAnnotated mb_cat
|
| 1940 | 1939 | ns_spec' <- exactNsSpec ns_spec
|
| 1941 | 1940 | lns' <- markAnnotated lns
|
| 1942 | 1941 | o' <- markEpToken o
|
| 1943 | 1942 | ls' <- markAnnotated ls
|
| 1944 | 1943 | c' <- markEpToken c
|
| 1945 | - return (Warning (ns_spec', (o',c')) lns' (WarningTxt mb_cat' src ls'))
|
|
| 1944 | + return (Warning (ns_spec', (o',c')) lns' (WarningTxt src mb_cat' ls'))
|
|
| 1946 | 1945 | |
| 1947 | 1946 | exact (Warning (ns_spec, (o,c)) lns (DeprecatedTxt src ls)) = do
|
| 1948 | 1947 | ns_spec' <- exactNsSpec ns_spec
|
| ... | ... | @@ -354,7 +354,7 @@ parseWarning |
| 354 | 354 | -> IfM m (Doc Name)
|
| 355 | 355 | parseWarning parserOpts sDocContext w = case w of
|
| 356 | 356 | IfDeprecatedTxt _ msg -> format "Deprecated: " (map dstToDoc msg)
|
| 357 | - IfWarningTxt _ _ msg -> format "Warning: " (map dstToDoc msg)
|
|
| 357 | + IfWarningTxt _ _ msg -> format "Warning: " (map dstToDoc msg)
|
|
| 358 | 358 | where
|
| 359 | 359 | dstToDoc :: (IfaceStringLiteral, [Name]) -> HsDoc GhcRn
|
| 360 | 360 | dstToDoc ((IfStringLiteral _ fs), ids) = WithHsDocIdentifiers (fsToDoc fs) (map noLoc ids)
|