Bodigrim pushed to branch wip/warning-for-last-and-init at Glasgow Haskell Compiler / GHC
Commits:
-
86560233
by Andrew Lelechenko at 2025-08-17T19:26:54+01:00
6 changed files:
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/ghc-pkg/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
Changes:
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | {-# LANGUAGE ScopedTypeVariables #-}
|
| 9 | 9 | {-# LANGUAGE TypeApplications #-}
|
| 10 | 10 | {-# LANGUAGE ViewPatterns #-}
|
| 11 | +{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
| 11 | 12 | -----------------------------------------------------------------------------
|
| 12 | 13 | -- |
|
| 13 | 14 | -- Module : Language.Haskell.GHC.ExactPrint.Transform
|
| ... | ... | @@ -96,7 +97,6 @@ import GHC.Data.FastString |
| 96 | 97 | import GHC.Types.SrcLoc
|
| 97 | 98 | |
| 98 | 99 | import Data.Data
|
| 99 | -import Data.List (unsnoc)
|
|
| 100 | 100 | import Data.List.NonEmpty (NonEmpty (..))
|
| 101 | 101 | import qualified Data.List.NonEmpty as NE
|
| 102 | 102 | import Data.Maybe
|
| ... | ... | @@ -213,9 +213,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (AnnSig (EpUniTok dca u) mp md) ns ( |
| 213 | 213 | where
|
| 214 | 214 | -- we want DPs for the distance from the end of the ns to the
|
| 215 | 215 | -- AnnDColon, and to the start of the ty
|
| 216 | - rd = case unsnoc ns of
|
|
| 217 | - Nothing -> error "unexpected empty list in 'ns' variable"
|
|
| 218 | - Just (_, L (EpAnn anc' _ _) _) -> epaLocationRealSrcSpan anc'
|
|
| 216 | + rd = case last ns of
|
|
| 217 | + L (EpAnn anc' _ _) _ -> epaLocationRealSrcSpan anc'
|
|
| 219 | 218 | dca' = case dca of
|
| 220 | 219 | EpaSpan ss@(RealSrcSpan r _) -> (EpaDelta ss (ss2delta (ss2posEnd rd) r) [])
|
| 221 | 220 | _ -> dca
|
| ... | ... | @@ -296,7 +295,7 @@ setEntryDP (L (EpAnn (EpaSpan ss@(RealSrcSpan r _)) an cs) a) dp |
| 296 | 295 | where
|
| 297 | 296 | cs'' = setPriorComments cs []
|
| 298 | 297 | csd = L (EpaDelta ss dp NoComments) c:commentOrigDeltas cs'
|
| 299 | - lc = NE.last (L ca c :| cs')
|
|
| 298 | + lc = last $ (L ca c:cs')
|
|
| 300 | 299 | delta = case getLoc lc of
|
| 301 | 300 | EpaSpan (RealSrcSpan rr _) -> ss2delta (ss2pos rr) r
|
| 302 | 301 | EpaSpan _ -> (SameLine 0)
|
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | {-# LANGUAGE NamedFieldPuns #-}
|
| 5 | 5 | {-# LANGUAGE RankNTypes #-}
|
| 6 | 6 | {-# LANGUAGE ScopedTypeVariables #-}
|
| 7 | +{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
| 7 | 8 | |
| 8 | 9 | module Utils
|
| 9 | 10 | -- (
|
| ... | ... | @@ -37,7 +38,7 @@ import GHC.Base (NonEmpty(..)) |
| 37 | 38 | import GHC.Parser.Lexer (allocateComments)
|
| 38 | 39 | |
| 39 | 40 | import Data.Data hiding ( Fixity )
|
| 40 | -import Data.List (sortBy, partition, unsnoc)
|
|
| 41 | +import Data.List (sortBy, partition)
|
|
| 41 | 42 | import qualified Data.Map.Strict as Map
|
| 42 | 43 | |
| 43 | 44 | import Debug.Trace
|
| ... | ... | @@ -734,9 +735,8 @@ ghead info [] = error $ "ghead "++info++" []" |
| 734 | 735 | ghead _info (h:_) = h
|
| 735 | 736 | |
| 736 | 737 | glast :: String -> [a] -> a
|
| 737 | -glast info xs = case unsnoc xs of
|
|
| 738 | - Nothing -> error $ "glast " ++ info ++ " []"
|
|
| 739 | - Just (_, lst) -> lst
|
|
| 738 | +glast info [] = error $ "glast " ++ info ++ " []"
|
|
| 739 | +glast _info h = last h
|
|
| 740 | 740 | |
| 741 | 741 | gtail :: String -> [a] -> [a]
|
| 742 | 742 | gtail info [] = error $ "gtail " ++ info ++ " []"
|
| ... | ... | @@ -8,7 +8,8 @@ |
| 8 | 8 | {-# LANGUAGE DataKinds #-}
|
| 9 | 9 | {-# LANGUAGE TupleSections #-}
|
| 10 | 10 | {-# LANGUAGE ScopedTypeVariables #-}
|
| 11 | -{-# OPTIONS_GHC -Wno-orphans -Wno-x-partial #-}
|
|
| 11 | +{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
| 12 | +{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
| 12 | 13 | |
| 13 | 14 | -- Fine if this comes from make/Hadrian or the pre-built base.
|
| 14 | 15 | #include <ghcplatform.h>
|
| 1 | +{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
| 1 | 2 | module GHC.Toolchain.CheckArm ( findArmIsa ) where
|
| 2 | 3 | |
| 3 | -import Data.List (isInfixOf, unsnoc)
|
|
| 4 | +import Data.List (isInfixOf)
|
|
| 4 | 5 | import Data.Maybe (catMaybes)
|
| 5 | 6 | import Control.Monad.IO.Class
|
| 6 | 7 | import System.Process
|
| ... | ... | @@ -76,7 +77,8 @@ findArmIsa cc = do |
| 76 | 77 | _ -> throwE $ "unexpected output from test program: " ++ out
|
| 77 | 78 | |
| 78 | 79 | lastLine :: String -> String
|
| 79 | -lastLine = maybe "" snd . unsnoc . lines
|
|
| 80 | +lastLine "" = ""
|
|
| 81 | +lastLine s = last $ lines s
|
|
| 80 | 82 | |
| 81 | 83 | -- | Raspbian unfortunately makes some extremely questionable packaging
|
| 82 | 84 | -- decisions, configuring gcc to compile for ARMv6 despite the fact that the
|
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | {-# LANGUAGE TupleSections #-}
|
| 7 | 7 | {-# LANGUAGE TypeApplications #-}
|
| 8 | 8 | {-# LANGUAGE TypeFamilies #-}
|
| 9 | -{-# OPTIONS_GHC -Wwarn=x-partial #-}
|
|
| 9 | +{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
| 10 | 10 | |
| 11 | 11 | -- |
|
| 12 | 12 | -- Module : Haddock.Backends.Html
|
| ... | ... | @@ -755,7 +755,7 @@ ppHtmlIndex |
| 755 | 755 | divAlphabet
|
| 756 | 756 | << unordList
|
| 757 | 757 | ( map (\str -> anchor ! [href (subIndexHtmlFile str)] << str) $
|
| 758 | - [ [c] | c <- initialChars, any (maybe False ((== c) . toUpper . fst) . List.uncons . fst) index
|
|
| 758 | + [ [c] | c <- initialChars, any ((== c) . toUpper . head . fst) index
|
|
| 759 | 759 | ]
|
| 760 | 760 | ++ [merged_name]
|
| 761 | 761 | )
|
| ... | ... | @@ -772,7 +772,7 @@ ppHtmlIndex |
| 772 | 772 | writeUtf8File (joinPath [odir, subIndexHtmlFile [c]]) (renderToString debug html)
|
| 773 | 773 | where
|
| 774 | 774 | html = indexPage True (Just c) index_part
|
| 775 | - index_part = [(n, stuff) | (n@(headN : _), stuff) <- this_ix, toUpper headN == c]
|
|
| 775 | + index_part = [(n, stuff) | (n, stuff) <- this_ix, toUpper (head n) == c]
|
|
| 776 | 776 | |
| 777 | 777 | index :: [(String, Map GHC.Name [(Module, Bool)])]
|
| 778 | 778 | index = sortBy cmp (Map.toAscList full_index)
|
| 1 | 1 | {-# LANGUAGE LambdaCase #-}
|
| 2 | 2 | {-# LANGUAGE OverloadedStrings #-}
|
| 3 | 3 | {-# LANGUAGE ViewPatterns #-}
|
| 4 | +{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
| 4 | 5 | |
| 5 | 6 | -- |
|
| 6 | 7 | -- Module : Documentation.Haddock.Parser
|
| ... | ... | @@ -30,7 +31,7 @@ import Control.Arrow (first) |
| 30 | 31 | import Control.Monad
|
| 31 | 32 | import Data.Char (chr, isAlpha, isSpace, isUpper)
|
| 32 | 33 | import Data.Functor (($>))
|
| 33 | -import Data.List (elemIndex, intercalate, intersperse, unfoldr, unsnoc)
|
|
| 34 | +import Data.List (elemIndex, intercalate, intersperse, unfoldr)
|
|
| 34 | 35 | import Data.Maybe (fromMaybe, mapMaybe)
|
| 35 | 36 | import Data.Monoid
|
| 36 | 37 | import qualified Data.Set as Set
|
| ... | ... | @@ -870,10 +871,10 @@ codeblock = |
| 870 | 871 | DocCodeBlock . parseParagraph . dropSpaces
|
| 871 | 872 | <$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
|
| 872 | 873 | where
|
| 873 | - dropSpaces xs = let ys = splitByNl xs in
|
|
| 874 | - case unsnoc ys of
|
|
| 875 | - Nothing -> xs
|
|
| 876 | - Just (_, lastYs) -> case T.uncons lastYs of
|
|
| 874 | + dropSpaces xs =
|
|
| 875 | + case splitByNl xs of
|
|
| 876 | + [] -> xs
|
|
| 877 | + ys -> case T.uncons (last ys) of
|
|
| 877 | 878 | Just (' ', _) -> case mapM dropSpace ys of
|
| 878 | 879 | Nothing -> xs
|
| 879 | 880 | Just zs -> T.intercalate "\n" zs
|