| ... |
... |
@@ -93,10 +93,10 @@ module Language.Haskell.Syntax.Decls ( |
|
93
|
93
|
mkWarningCategory,
|
|
94
|
94
|
InWarningCategory(..),
|
|
95
|
95
|
-- ** Extension
|
|
96
|
|
- XWarningTxt,
|
|
97
|
96
|
XDeprecatedTxt,
|
|
|
97
|
+ XWarningTxt,
|
|
|
98
|
+ XXWarningTxt,
|
|
98
|
99
|
XInWarningCategory,
|
|
99
|
|
- XInWarningCategoryIn,
|
|
100
|
100
|
XWarningCategory
|
|
101
|
101
|
) where
|
|
102
|
102
|
|
| ... |
... |
@@ -115,6 +115,7 @@ import GHC.Types.Basic (TopLevelFlag, OverlapMode, RuleName, Activation |
|
115
|
115
|
,TyConFlavour(..), TypeOrData(..), NewOrData(..))
|
|
116
|
116
|
import GHC.Types.ForeignCall (CType, CCallConv, Safety, Header, CLabelString, CCallTarget, CExportSpec)
|
|
117
|
117
|
|
|
|
118
|
+import GHC.Data.FastString (FastString)
|
|
118
|
119
|
import GHC.Hs.Doc (LHsDoc) -- ROMES:TODO Discuss in #21592 whether this is parsed AST or base AST
|
|
119
|
120
|
import GHC.Hs.Doc (WithHsDocIdentifiers)
|
|
120
|
121
|
import GHC.Types.SourceText (StringLiteral)
|
| ... |
... |
@@ -1608,6 +1609,13 @@ data RoleAnnotDecl pass |
|
1608
|
1609
|
[XRec pass (Maybe Role)] -- optional annotations
|
|
1609
|
1610
|
| XRoleAnnotDecl !(XXRoleAnnotDecl pass)
|
|
1610
|
1611
|
|
|
|
1612
|
+{-
|
|
|
1613
|
+************************************************************************
|
|
|
1614
|
+* *
|
|
|
1615
|
+\subsection[WarnAnnot]{Warning annotations}
|
|
|
1616
|
+* *
|
|
|
1617
|
+************************************************************************
|
|
|
1618
|
+-}
|
|
1611
|
1619
|
|
|
1612
|
1620
|
-- | Warning Text
|
|
1613
|
1621
|
--
|
| ... |
... |
@@ -1626,54 +1634,35 @@ data WarningTxt pass |
|
1626
|
1634
|
deriving Generic
|
|
1627
|
1635
|
-}
|
|
1628
|
1636
|
|
|
1629
|
|
-type family XWarningTxt p
|
|
1630
|
|
-type family XDeprecatedTxt p
|
|
1631
|
|
-
|
|
1632
|
1637
|
data WarningTxt pass
|
|
1633
|
|
- = WarningTxt
|
|
|
1638
|
+ = DeprecatedTxt
|
|
|
1639
|
+ (XDeprecatedTxt pass)
|
|
|
1640
|
+ [XRec pass (WithHsDocIdentifiers StringLiteral pass)]
|
|
|
1641
|
+ | WarningTxt
|
|
1634
|
1642
|
(Maybe (XRec pass (InWarningCategory pass)))
|
|
1635
|
1643
|
-- ^ Warning category attached to this WARNING pragma, if any;
|
|
1636
|
1644
|
-- see Note [Warning categories]
|
|
1637
|
1645
|
(XWarningTxt pass)
|
|
1638
|
1646
|
[XRec pass (WithHsDocIdentifiers StringLiteral pass)]
|
|
1639
|
|
- | DeprecatedTxt
|
|
1640
|
|
- (XDeprecatedTxt pass)
|
|
1641
|
|
- [XRec pass (WithHsDocIdentifiers StringLiteral pass)]
|
|
|
1647
|
+ | XWarningTxt !(XXWarningTxt pass)
|
|
1642
|
1648
|
deriving Generic
|
|
1643
|
1649
|
|
|
1644
|
|
-deriving stock instance (
|
|
1645
|
|
- Eq (XWarningTxt pass),
|
|
1646
|
|
- Eq (XDeprecatedTxt pass),
|
|
1647
|
|
- Eq (XRec pass (InWarningCategory pass)),
|
|
1648
|
|
- Eq (XRec pass (WithHsDocIdentifiers StringLiteral pass))
|
|
1649
|
|
- ) => Eq (WarningTxt pass)
|
|
1650
|
1650
|
deriving stock instance (
|
|
1651
|
1651
|
Data pass,
|
|
1652
|
|
- Data (XWarningTxt pass),
|
|
1653
|
1652
|
Data (XDeprecatedTxt pass),
|
|
|
1653
|
+ Data (XWarningTxt pass),
|
|
|
1654
|
+ Data (XXWarningTxt pass),
|
|
1654
|
1655
|
Data (XRec pass (InWarningCategory pass)),
|
|
1655
|
1656
|
Data (XRec pass (WithHsDocIdentifiers StringLiteral pass))
|
|
1656
|
1657
|
) => Data (WarningTxt pass)
|
|
1657
|
1658
|
|
|
1658
|
|
-{-
|
|
1659
|
|
--- | The message that the WarningTxt was specified to output
|
|
1660
|
|
-warningTxtMessage :: WarningTxt p -> [LocatedE (WithHsDocIdentifiers StringLiteral p)]
|
|
1661
|
|
-warningTxtMessage (WarningTxt _ _ m) = m
|
|
1662
|
|
-warningTxtMessage (DeprecatedTxt _ m) = m
|
|
1663
|
|
-
|
|
1664
|
|
--- | True if the 2 WarningTxts have the same category and messages
|
|
1665
|
|
-warningTxtSame :: WarningTxt p1 -> WarningTxt p2 -> Bool
|
|
1666
|
|
-warningTxtSame w1 w2
|
|
1667
|
|
- = warningTxtCategory w1 == warningTxtCategory w2
|
|
1668
|
|
- && literal_message w1 == literal_message w2
|
|
1669
|
|
- && same_type
|
|
1670
|
|
- where
|
|
1671
|
|
- literal_message :: WarningTxt p -> [StringLiteral]
|
|
1672
|
|
- literal_message = map (hsDocString . unLoc) . warningTxtMessage
|
|
1673
|
|
- same_type | DeprecatedTxt {} <- w1, DeprecatedTxt {} <- w2 = True
|
|
1674
|
|
- | WarningTxt {} <- w1, WarningTxt {} <- w2 = True
|
|
1675
|
|
- | otherwise = False
|
|
1676
|
|
--}
|
|
|
1659
|
+deriving stock instance (
|
|
|
1660
|
+ Eq (XDeprecatedTxt pass),
|
|
|
1661
|
+ Eq (XWarningTxt pass),
|
|
|
1662
|
+ Eq (XXWarningTxt pass),
|
|
|
1663
|
+ Eq (XRec pass (InWarningCategory pass)),
|
|
|
1664
|
+ Eq (XRec pass (WithHsDocIdentifiers StringLiteral pass))
|
|
|
1665
|
+ ) => Eq (WarningTxt pass)
|
|
1677
|
1666
|
|
|
1678
|
1667
|
{-
|
|
1679
|
1668
|
Note [Warning categories]
|
| ... |
... |
@@ -1728,40 +1717,29 @@ data InWarningCategory |
|
1728
|
1717
|
iwc_wc :: (LocatedE WarningCategory)
|
|
1729
|
1718
|
} deriving Data
|
|
1730
|
1719
|
-}
|
|
1731
|
|
-type family XInWarningCategory p
|
|
1732
|
|
-type family XInWarningCategoryIn p
|
|
1733
|
1720
|
|
|
1734
|
1721
|
data InWarningCategory pass
|
|
1735
|
1722
|
= InWarningCategory
|
|
1736
|
|
- { iwc_in :: !(XInWarningCategoryIn pass),
|
|
1737
|
|
--- iwc_in :: !(EpToken "in"),
|
|
1738
|
|
- iwc_st :: (XInWarningCategory pass),
|
|
1739
|
|
- iwc_wc :: (XRec pass (WarningCategory pass))
|
|
|
1723
|
+ { iwc_st :: (XInWarningCategory pass),
|
|
|
1724
|
+ iwc_wc :: (XRec pass WarningCategory)
|
|
1740
|
1725
|
}
|
|
|
1726
|
+ | XInWarningCategory pass
|
|
1741
|
1727
|
|
|
1742
|
1728
|
deriving stock instance (
|
|
1743
|
1729
|
Data pass,
|
|
1744
|
1730
|
Data (XInWarningCategory pass),
|
|
1745
|
|
- Data (XInWarningCategoryIn pass),
|
|
1746
|
|
- Data (XRec pass (WarningCategory pass))
|
|
|
1731
|
+ Data (XRec pass WarningCategory)
|
|
1747
|
1732
|
) => Data (InWarningCategory pass)
|
|
1748
|
1733
|
|
|
1749
|
|
-deriving instance (
|
|
|
1734
|
+deriving stock instance (
|
|
|
1735
|
+-- Eq p, -- Add this and then all the type family values complain about Eq instances.
|
|
1750
|
1736
|
Eq (XInWarningCategory p),
|
|
1751
|
|
- Eq (XInWarningCategoryIn p),
|
|
1752
|
|
- Eq (XRec p (WarningCategory p))
|
|
|
1737
|
+ Eq (XRec p WarningCategory)
|
|
1753
|
1738
|
) => Eq (InWarningCategory p)
|
|
1754
|
1739
|
|
|
1755
|
|
-type family XWarningCategory p
|
|
1756
|
|
-
|
|
1757
|
|
--- See Note [Warning categories]
|
|
1758
|
|
-newtype WarningCategory pass = WarningCategory (XWarningCategory pass)
|
|
1759
|
|
- -- Must add back Binary, Outputable, Uniquable
|
|
1760
|
|
-
|
|
1761
|
|
-deriving stock instance (Data pass, Data (XWarningCategory pass)) => Data (WarningCategory pass)
|
|
1762
|
|
-deriving newtype instance Eq (XWarningCategory pass) => Eq (WarningCategory pass)
|
|
1763
|
|
-deriving newtype instance Show (XWarningCategory pass) => Show (WarningCategory pass)
|
|
1764
|
|
-deriving newtype instance NFData (XWarningCategory pass) => NFData (WarningCategory pass)
|
|
|
1740
|
+newtype WarningCategory = WarningCategory FastString
|
|
|
1741
|
+ deriving stock (Data)
|
|
|
1742
|
+ deriving newtype (Eq, Show, NFData)
|
|
1765
|
1743
|
|
|
1766
|
|
-mkWarningCategory :: XWarningCategory pass -> WarningCategory pass
|
|
|
1744
|
+mkWarningCategory :: FastString -> WarningCategory
|
|
1767
|
1745
|
mkWarningCategory = WarningCategory |