From 2a68b8b7974365db4ad71ea239bdc7e9a8c5896e Mon Sep 17 00:00:00 2001 From: nineonine <mail4chemik@gmail.com> Date: Tue, 25 Jun 2019 17:45:14 -0700 Subject: [PATCH] Fix #16805 by formatting warning message --- compiler/main/GhcMake.hs | 12 ++++++------ .../warnings/should_compile/UnusedPackages.stderr | 7 +++++-- testsuite/tests/warnings/should_compile/all.T | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs index 491504d3bdbc..d4b5cb055953 100644 --- a/compiler/main/GhcMake.hs +++ b/compiler/main/GhcMake.hs @@ -302,12 +302,10 @@ warnUnusedPackages = do let warn = makeIntoWarning (Reason Opt_WarnUnusedPackages) (mkPlainErrMsg dflags noSrcSpan msg) - msg = hang - ( text "The following packages were specified " - <> text "via -package or -package-id flags, " - <> text "but were not needed for compilation: ") - 4 - (sep (map pprUnusedArg unusedArgs)) + msg = vcat [ text "The following packages were specified" <+> + text "via -package or -package-id flags," + , text "but were not needed for compilation:" + , nest 2 (vcat (map (withDash . pprUnusedArg) unusedArgs)) ] when (wopt Opt_WarnUnusedPackages dflags && not (null unusedArgs)) $ logWarnings (listToBag [warn]) @@ -319,6 +317,8 @@ warnUnusedPackages = do pprUnusedArg (PackageArg str) = text str pprUnusedArg (UnitIdArg uid) = ppr uid + withDash = (<+>) (text "-") + matchingStr :: String -> PackageConfig -> Bool matchingStr str p = str == sourcePackageIdString p diff --git a/testsuite/tests/warnings/should_compile/UnusedPackages.stderr b/testsuite/tests/warnings/should_compile/UnusedPackages.stderr index 7660287aa893..4eea3bfc8bf7 100644 --- a/testsuite/tests/warnings/should_compile/UnusedPackages.stderr +++ b/testsuite/tests/warnings/should_compile/UnusedPackages.stderr @@ -2,5 +2,8 @@ Linking UnusedPackages ... <no location info>: warning: [-Wunused-packages] - The following packages were specified via -package or -package-id flags, but were not needed for compilation: - bytestring + The following packages were specified via -package or -package-id flags, + but were not needed for compilation: + - ghc + - process + - bytestring diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T index eabe354fa8dd..914f4514d36c 100644 --- a/testsuite/tests/warnings/should_compile/all.T +++ b/testsuite/tests/warnings/should_compile/all.T @@ -28,4 +28,5 @@ test('StarBinder', normal, compile, ['']) test('Overflow', expect_broken_for(16543, ['hpc']), compile, ['']) -test('UnusedPackages', normal, multimod_compile, ['UnusedPackages.hs', '-package=bytestring -package=base -Wunused-packages']) +test('UnusedPackages', normal, multimod_compile, + ['UnusedPackages.hs', '-package=bytestring -package=base -package=process -package=ghc -Wunused-packages']) -- GitLab