[commit: ghc] master: renamer: fix module-level deprecation message (b04bed0)

git at git.haskell.org git at git.haskell.org
Sat Jul 25 08:38:50 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b04bed0a391335e70b3c3bdbdccbaa0781697cce/ghc

>---------------------------------------------------------------

commit b04bed0a391335e70b3c3bdbdccbaa0781697cce
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date:   Sat Jul 25 09:37:44 2015 +0100

    renamer: fix module-level deprecation message
    
    Noticed today that deprecation warnings are
    slightly broken in -HEAD:
    
      mtl-2.2.1/Control/Monad/Error/Class.hs:46:1: warning:
        Module ‘Control.Monad.Trans.Error’ is deprecated:
          ([", U, s, e,  , C, o, n, t, r, o, l, ., M, o, n, a, d, ., T, r, a,
            n, s, ., E, x, c, e, p, t,  , i, n, s, t, e, a, d, "],
           Use Control.Monad.Trans.Except instead)
    
    Commit e6191d1cc37e98785af8b309100ea840084fa3ba
    slightly changed WarningTxt declaration:
    
    -data WarningTxt = WarningTxt (Located SourceText) [Located FastString]
    -                | DeprecatedTxt (Located SourceText) [Located FastString]
    +data WarningTxt = WarningTxt (Located SourceText)
    +                             [Located (SourceText,FastString)]
    +                | DeprecatedTxt (Located SourceText)
    +                                [Located (SourceText,FastString)]
    
    But 'moduleWarn' function was not updated to do the stripping.
    
    Signed-off-by: Sergei Trofimovich <siarheit at google.com>
    
    Reviewers: austin, bgamari, hvr, goldfire, rwbarton, alanz
    
    Reviewed By: rwbarton, alanz
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1096
    
    GHC Trac Issues: #10313


>---------------------------------------------------------------

b04bed0a391335e70b3c3bdbdccbaa0781697cce
 compiler/rename/RnNames.hs                           |  4 ++--
 testsuite/tests/warnings/should_compile/DeprM.hs     |  4 ++++
 testsuite/tests/warnings/should_compile/DeprU.hs     |  6 ++++++
 testsuite/tests/warnings/should_compile/DeprU.stderr | 10 ++++++++++
 testsuite/tests/warnings/should_compile/all.T        |  6 ++++++
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs
index 0c116df..aeb0388 100644
--- a/compiler/rename/RnNames.hs
+++ b/compiler/rename/RnNames.hs
@@ -1788,11 +1788,11 @@ missingImportListItem ie
 moduleWarn :: ModuleName -> WarningTxt -> SDoc
 moduleWarn mod (WarningTxt _ txt)
   = sep [ ptext (sLit "Module") <+> quotes (ppr mod) <> ptext (sLit ":"),
-          nest 2 (vcat (map ppr txt)) ]
+          nest 2 (vcat (map (ppr . snd . unLoc) txt)) ]
 moduleWarn mod (DeprecatedTxt _ txt)
   = sep [ ptext (sLit "Module") <+> quotes (ppr mod)
                                 <+> ptext (sLit "is deprecated:"),
-          nest 2 (vcat (map ppr txt)) ]
+          nest 2 (vcat (map (ppr . snd . unLoc) txt)) ]
 
 packageImportErr :: SDoc
 packageImportErr
diff --git a/testsuite/tests/warnings/should_compile/DeprM.hs b/testsuite/tests/warnings/should_compile/DeprM.hs
new file mode 100644
index 0000000..2a84622
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/DeprM.hs
@@ -0,0 +1,4 @@
+module DeprM {-# DEPRECATED "Here can be your menacing deprecation warning!" #-} where
+
+f :: Int
+f = 42
diff --git a/testsuite/tests/warnings/should_compile/DeprU.hs b/testsuite/tests/warnings/should_compile/DeprU.hs
new file mode 100644
index 0000000..d15a7c5
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/DeprU.hs
@@ -0,0 +1,6 @@
+module A where
+
+import DeprM -- here should be emitted deprecation warning
+
+g :: Int
+g = f
diff --git a/testsuite/tests/warnings/should_compile/DeprU.stderr b/testsuite/tests/warnings/should_compile/DeprU.stderr
new file mode 100644
index 0000000..c27dccb
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/DeprU.stderr
@@ -0,0 +1,10 @@
+[1 of 2] Compiling DeprM            ( DeprM.hs, DeprM.o )
+[2 of 2] Compiling A                ( DeprU.hs, DeprU.o )
+
+DeprU.hs:3:1: Warning:
+    Module ‘DeprM’ is deprecated:
+      Here can be your menacing deprecation warning!
+
+DeprU.hs:6:5: Warning:
+    In the use of ‘f’ (imported from DeprM):
+    Deprecated: "Here can be your menacing deprecation warning!"
diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T
index 7fa8caf..bbf5d1c 100644
--- a/testsuite/tests/warnings/should_compile/all.T
+++ b/testsuite/tests/warnings/should_compile/all.T
@@ -4,3 +4,9 @@ test('T9178', extra_clean(['T9178.o', 'T9178DataType.o',
 			   'T9178.hi', 'T9178DataType.hi']),
 	      multimod_compile, ['T9178', '-Wall'])
 test('T9230', normal, compile_without_flag('-fno-warn-tabs'), [''])
+
+test('DeprU',
+	extra_clean([
+		'DeprM.o',  'DeprU.o',
+		'DeprM.hi', 'DeprU.hi']),
+	multimod_compile, ['DeprU', '-Wall'])



More information about the ghc-commits mailing list