diff options
author | Hécate <hecate+gitlab@glitchbra.in> | 2020-10-10 21:15:36 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-01 01:11:09 -0400 |
commit | dfd27445308d1ed2df8826c2a045130e918e8192 (patch) | |
tree | 99fc01edeebc2924ddb7533864e0d4ca18cfe800 /compiler/GHC/Rename | |
parent | bd4abdc953427e084e7ecba89db64860f6859822 (diff) | |
download | haskell-dfd27445308d1ed2df8826c2a045130e918e8192.tar.gz |
Add the proper HLint rules and remove redundant keywords from compiler
Diffstat (limited to 'compiler/GHC/Rename')
-rw-r--r-- | compiler/GHC/Rename/Bind.hs | 18 | ||||
-rw-r--r-- | compiler/GHC/Rename/Expr.hs | 22 | ||||
-rw-r--r-- | compiler/GHC/Rename/Module.hs | 20 | ||||
-rw-r--r-- | compiler/GHC/Rename/Names.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Rename/Splice.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Rename/Utils.hs | 4 |
6 files changed, 37 insertions, 38 deletions
diff --git a/compiler/GHC/Rename/Bind.hs b/compiler/GHC/Rename/Bind.hs index 9215ef26fc..953d3c2c9b 100644 --- a/compiler/GHC/Rename/Bind.hs +++ b/compiler/GHC/Rename/Bind.hs @@ -885,7 +885,7 @@ rnMethodBindLHS :: Bool -> Name -> LHsBindsLR GhcRn GhcPs -> RnM (LHsBindsLR GhcRn GhcPs) rnMethodBindLHS _ cls (L loc bind@(FunBind { fun_id = name })) rest - = setSrcSpan loc $ do + = setSrcSpan loc $ do { sel_name <- wrapLocM (lookupInstDeclBndr cls (text "method")) name -- We use the selector name as the binder ; let bind' = bind { fun_id = sel_name, fun_ext = noExtField } @@ -1034,7 +1034,7 @@ renameSig _ctxt sig@(CompleteMatchSig _ s (L l bf) mty) new_mty <- traverse lookupLocatedOccRn mty this_mod <- fmap tcg_mod getGblEnv - unless (any (nameIsLocalOrFrom this_mod . unLoc) new_bf) $ do + unless (any (nameIsLocalOrFrom this_mod . unLoc) new_bf) $ -- Why 'any'? See Note [Orphan COMPLETE pragmas] addErrCtxt (text "In" <+> ppr sig) $ failWithTc orphanError @@ -1173,20 +1173,20 @@ rnMatch :: Outputable (body GhcPs) => HsMatchContext GhcRn -> RnM (LMatch GhcRn (Located (body GhcRn)), FreeVars) rnMatch ctxt rnBody = wrapLocFstM (rnMatch' ctxt rnBody) +-- Note that there are no local fixity decls for matches rnMatch' :: Outputable (body GhcPs) => HsMatchContext GhcRn -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> Match GhcPs (Located (body GhcPs)) -> RnM (Match GhcRn (Located (body GhcRn)), FreeVars) -rnMatch' ctxt rnBody (Match { m_ctxt = mf, m_pats = pats, m_grhss = grhss }) - = do { -- Note that there are no local fixity decls for matches - ; rnPats ctxt pats $ \ pats' -> do +rnMatch' ctxt rnBody (Match { m_ctxt = mf, m_pats = pats, m_grhss = grhss }) = + rnPats ctxt pats $ \ pats' -> do { (grhss', grhss_fvs) <- rnGRHSs ctxt rnBody grhss ; let mf' = case (ctxt, mf) of - (FunRhs { mc_fun = L _ funid }, FunRhs { mc_fun = L lf _ }) - -> mf { mc_fun = L lf funid } - _ -> ctxt + (FunRhs { mc_fun = L _ funid }, FunRhs { mc_fun = L lf _ }) -> + mf { mc_fun = L lf funid } + _ -> ctxt ; return (Match { m_ext = noExtField, m_ctxt = mf', m_pats = pats' - , m_grhss = grhss'}, grhss_fvs ) }} + , m_grhss = grhss'}, grhss_fvs ) } emptyCaseErr :: HsMatchContext GhcRn -> SDoc emptyCaseErr ctxt = hang (text "Empty list of alternatives in" <+> pp_ctxt) diff --git a/compiler/GHC/Rename/Expr.hs b/compiler/GHC/Rename/Expr.hs index 14218b01f6..b38b4679b1 100644 --- a/compiler/GHC/Rename/Expr.hs +++ b/compiler/GHC/Rename/Expr.hs @@ -108,16 +108,16 @@ finishHsVar (L l name) ; return (HsVar noExtField (L l name), unitFV name) } rnUnboundVar :: RdrName -> RnM (HsExpr GhcRn, FreeVars) -rnUnboundVar v - = do { if isUnqual v - then -- Treat this as a "hole" - -- Do not fail right now; instead, return HsUnboundVar - -- and let the type checker report the error - return (HsUnboundVar noExtField (rdrNameOcc v), emptyFVs) +rnUnboundVar v = + if isUnqual v + then -- Treat this as a "hole" + -- Do not fail right now; instead, return HsUnboundVar + -- and let the type checker report the error + return (HsUnboundVar noExtField (rdrNameOcc v), emptyFVs) - else -- Fail immediately (qualified name) - do { n <- reportUnboundName v - ; return (HsVar noExtField (noLoc n), emptyFVs) } } + else -- Fail immediately (qualified name) + do { n <- reportUnboundName v + ; return (HsVar noExtField (noLoc n), emptyFVs) } rnExpr (HsVar _ (L l v)) = do { opt_DuplicateRecordFields <- xoptM LangExt.DuplicateRecordFields @@ -847,10 +847,10 @@ rnStmt ctxt rnBody (L loc (BindStmt _ pat body)) thing_inside -- but it does not matter because the names are unique rnStmt _ _ (L loc (LetStmt _ (L l binds))) thing_inside - = do { rnLocalBindsAndThen binds $ \binds' bind_fvs -> do + = rnLocalBindsAndThen binds $ \binds' bind_fvs -> do { (thing, fvs) <- thing_inside (collectLocalBinders binds') ; return ( ([(L loc (LetStmt noExtField (L l binds')), bind_fvs)], thing) - , fvs) } } + , fvs) } rnStmt ctxt rnBody (L loc (RecStmt { recS_stmts = rec_stmts })) thing_inside = do { (return_op, fvs1) <- lookupQualifiedDoStmtName ctxt returnMName diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs index f815cd5c4a..d535f008ae 100644 --- a/compiler/GHC/Rename/Module.hs +++ b/compiler/GHC/Rename/Module.hs @@ -449,8 +449,8 @@ checkCanonicalInstances cls poly_ty mbinds = do -- * Warn if '(*>)' is defined backwards (i.e. @(*>) = (>>)@). -- checkCanonicalMonadInstances refURL - | cls == applicativeClassName = do - forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ do + | cls == applicativeClassName = + forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ case mbind of FunBind { fun_id = L _ name , fun_matches = mg } @@ -464,8 +464,8 @@ checkCanonicalInstances cls poly_ty mbinds = do _ -> return () - | cls == monadClassName = do - forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ do + | cls == monadClassName = + forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ case mbind of FunBind { fun_id = L _ name , fun_matches = mg } @@ -495,8 +495,8 @@ checkCanonicalInstances cls poly_ty mbinds = do -- * Warn if '(<>)' is defined backwards (i.e. @(<>) = mappend@). -- checkCanonicalMonoidInstances refURL - | cls == semigroupClassName = do - forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ do + | cls == semigroupClassName = + forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ case mbind of FunBind { fun_id = L _ name , fun_matches = mg } @@ -506,8 +506,8 @@ checkCanonicalInstances cls poly_ty mbinds = do _ -> return () - | cls == monoidClassName = do - forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ do + | cls == monoidClassName = + forM_ (bagToList mbinds) $ \(L loc mbind) -> setSrcSpan loc $ case mbind of FunBind { fun_id = L _ name , fun_matches = mg } @@ -531,7 +531,7 @@ checkCanonicalInstances cls poly_ty mbinds = do isAliasMG _ = Nothing -- got "lhs = rhs" but expected something different - addWarnNonCanonicalMethod1 refURL flag lhs rhs = do + addWarnNonCanonicalMethod1 refURL flag lhs rhs = addWarn (Reason flag) $ vcat [ text "Noncanonical" <+> quotes (text (lhs ++ " = " ++ rhs)) <+> @@ -545,7 +545,7 @@ checkCanonicalInstances cls poly_ty mbinds = do ] -- expected "lhs = rhs" but got something else - addWarnNonCanonicalMethod2 refURL flag lhs rhs = do + addWarnNonCanonicalMethod2 refURL flag lhs rhs = addWarn (Reason flag) $ vcat [ text "Noncanonical" <+> quotes (text lhs) <+> diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs index ac8117e4a1..cde4fe6d4a 100644 --- a/compiler/GHC/Rename/Names.hs +++ b/compiler/GHC/Rename/Names.hs @@ -1025,7 +1025,7 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items)) -- different parents). See Note [Dealing with imports] lookup_ie :: IE GhcPs -> IELookupM ([(IE GhcRn, AvailInfo)], [IELookupWarning]) - lookup_ie ie = handle_bad_import $ do + lookup_ie ie = handle_bad_import $ case ie of IEVar _ (L l n) -> do (name, avail, _) <- lookup_name ie $ ieWrappedName n diff --git a/compiler/GHC/Rename/Splice.hs b/compiler/GHC/Rename/Splice.hs index c18074097d..48378ba670 100644 --- a/compiler/GHC/Rename/Splice.hs +++ b/compiler/GHC/Rename/Splice.hs @@ -37,17 +37,16 @@ import Control.Monad ( unless, when ) import {-# SOURCE #-} GHC.Rename.Expr ( rnLExpr ) -import GHC.Tc.Utils.Env ( checkWellStaged ) -import GHC.Builtin.Names.TH ( liftName ) +import GHC.Tc.Utils.Env ( checkWellStaged, tcMetaTy ) import GHC.Driver.Session import GHC.Data.FastString import GHC.Utils.Error ( dumpIfSet_dyn_printer, DumpFormat (..) ) import GHC.Utils.Panic -import GHC.Tc.Utils.Env ( tcMetaTy ) import GHC.Driver.Hooks -import GHC.Builtin.Names.TH ( quoteExpName, quotePatName, quoteDecName, quoteTypeName - , decsQTyConName, expQTyConName, patQTyConName, typeQTyConName, ) +import GHC.Builtin.Names.TH ( decsQTyConName, expQTyConName, liftName + , patQTyConName, quoteDecName, quoteExpName + , quotePatName, quoteTypeName, typeQTyConName) import {-# SOURCE #-} GHC.Tc.Gen.Expr ( tcCheckPolyExpr ) import {-# SOURCE #-} GHC.Tc.Gen.Splice diff --git a/compiler/GHC/Rename/Utils.hs b/compiler/GHC/Rename/Utils.hs index a29a8b6602..68d453a68f 100644 --- a/compiler/GHC/Rename/Utils.hs +++ b/compiler/GHC/Rename/Utils.hs @@ -366,8 +366,8 @@ checkUnusedRecordWildcard :: SrcSpan -> FreeVars -> Maybe [Name] -> RnM () -checkUnusedRecordWildcard _ _ Nothing = return () -checkUnusedRecordWildcard loc _ (Just []) = do +checkUnusedRecordWildcard _ _ Nothing = return () +checkUnusedRecordWildcard loc _ (Just []) = -- Add a new warning if the .. pattern binds no variables setSrcSpan loc $ warnRedundantRecordWildcard checkUnusedRecordWildcard loc fvs (Just dotdot_names) = |