Don't include BufPos in interface files
authorDebian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>
Tue, 19 Sep 2023 23:00:36 +0000 (00:00 +0100)
committerRaspbian forward porter <root@raspbian.org>
Tue, 19 Sep 2023 23:00:36 +0000 (00:00 +0100)
Origin: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8972
Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/22162

===================================================================

Gbp-Pq: Name buildpath-abi-stability-2.patch

compiler/GHC/Iface/Ext/Types.hs
compiler/GHC/Types/SrcLoc.hs
compiler/GHC/Utils/Binary.hs

index ce6b564b130cf7142f4686f064bffa81538efcd4..57d636a60a90931f7e340ce48d6e490a0dd7bf36 100644 (file)
@@ -746,5 +746,5 @@ toHieName name
   | isKnownKeyName name = KnownKeyName (nameUnique name)
   | isExternalName name = ExternalName (nameModule name)
                                        (nameOccName name)
-                                       (nameSrcSpan name)
-  | otherwise = LocalName (nameOccName name) (nameSrcSpan name)
+                                       (removeBufSpan $ nameSrcSpan name)
+  | otherwise = LocalName (nameOccName name) (removeBufSpan $ nameSrcSpan name)
index 2ac2a13b041698e244e53a3a9b15db29dcc09731..2a037d1cb705d51609c7bf20f29e7c23bab4f432 100644 (file)
@@ -72,6 +72,7 @@ module GHC.Types.SrcLoc (
         getBufPos,
         BufSpan(..),
         getBufSpan,
+        removeBufSpan,
 
         -- * Located
         Located,
@@ -397,6 +398,10 @@ data UnhelpfulSpanReason
   | UnhelpfulOther !FastString
   deriving (Eq, Show)
 
+removeBufSpan :: SrcSpan -> SrcSpan
+removeBufSpan (RealSrcSpan s _) = RealSrcSpan s Nothing
+removeBufSpan s = s
+
 {- Note [Why Maybe BufPos]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 In SrcLoc we store (Maybe BufPos); in SrcSpan we store (Maybe BufSpan).
index 32d8608f81186c37c6382240bd5ac2fb4ace8dae..7495ed9b03043e646c1911b8188b4df537839310 100644 (file)
@@ -1444,19 +1444,6 @@ instance Binary RealSrcSpan where
             return (mkRealSrcSpan (mkRealSrcLoc f sl sc)
                                   (mkRealSrcLoc f el ec))
 
-instance Binary BufPos where
-  put_ bh (BufPos i) = put_ bh i
-  get bh = BufPos <$> get bh
-
-instance Binary BufSpan where
-  put_ bh (BufSpan start end) = do
-    put_ bh start
-    put_ bh end
-  get bh = do
-    start <- get bh
-    end <- get bh
-    return (BufSpan start end)
-
 instance Binary UnhelpfulSpanReason where
   put_ bh r = case r of
     UnhelpfulNoLocationInfo -> putByte bh 0
@@ -1475,10 +1462,11 @@ instance Binary UnhelpfulSpanReason where
       _ -> UnhelpfulOther <$> get bh
 
 instance Binary SrcSpan where
-  put_ bh (RealSrcSpan ss sb) = do
+  put_ bh (RealSrcSpan ss _sb) = do
           putByte bh 0
+          -- BufSpan doesn't ever get serialised because the positions depend
+          -- on build location.
           put_ bh ss
-          put_ bh sb
 
   put_ bh (UnhelpfulSpan s) = do
           putByte bh 1
@@ -1488,8 +1476,7 @@ instance Binary SrcSpan where
           h <- getByte bh
           case h of
             0 -> do ss <- get bh
-                    sb <- get bh
-                    return (RealSrcSpan ss sb)
+                    return (RealSrcSpan ss Nothing)
             _ -> do s <- get bh
                     return (UnhelpfulSpan s)