Skip to content

Commit 0a5b2bc

Browse files
Use user-facing display names for binders
1 parent 2ec7138 commit 0a5b2bc

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

src/Fusion/Plugin/Common.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ dumpBindCore
536536
dumpBindCore dflags pkgName modName allBinds b = do
537537
path <- writeBindCore dflags pkgName modName ".dump-simpl" allBinds b
538538
putMsgS $ "fusion-plugin: "
539-
++ showWithUnique dflags b ++ ": dumped core to " ++ path
539+
++ binderDisplayName b ++ ": dumped core to " ++ path
540540

541541
-------------------------------------------------------------------------------
542542
-- Report unfused constructors

src/Fusion/Plugin/Inspect.hs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import Fusion.Plugin.Common
6161
, showDetailsCaseMatch
6262
, showDetailsConstr
6363
, showInfo
64-
, showWithUnique
6564
, subsumedBySameName
6665
)
6766

@@ -448,7 +447,7 @@ reportInspected
448447
stale = filter (`notElem` present) allowed
449448
unless (null stale) $
450449
putMsgS $ "fusion-plugin: "
451-
++ getOccString (getName b)
450+
++ binderDisplayName b
452451
++ ": redundant " ++ label
453452
++ " entries (safe to remove): ["
454453
++ DL.intercalate ", " (map qualifiedName stale)
@@ -457,13 +456,13 @@ reportInspected
457456
terse ni results =
458457
let names = DL.nub (mapMaybe (contextQualifiedName . snd) results)
459458
in putMsgS $ "fusion-plugin: "
460-
++ getOccString (getName b)
459+
++ binderDisplayName b
461460
++ ": found " ++ niForbidLabel ni ++ " ["
462461
++ DL.intercalate ", " names ++ "]"
463462

464463
detailed ni results = do
465464
putMsgS $ "fusion-plugin: "
466-
++ showWithUnique dflags b
465+
++ binderDisplayName b
467466
++ ": inspecting (" ++ niBanner ni ++ ")..."
468467
let getAlts x =
469468
case x of
@@ -572,15 +571,15 @@ reportInspectedClasses dflags reportMode classAnns allBinds (NonRec b _) =
572571
ReportWarn -> report ispec hits
573572
_ -> do
574573
putMsgS $ "fusion-plugin: "
575-
++ showWithUnique dflags b
574+
++ binderDisplayName b
576575
++ ": inspecting (" ++ showSDoc dflags (ppr ispec) ++ ")..."
577576
report ispec hits
578577
return 1
579578

580579
report _ hits =
581580
let names = DL.nub (map qualifiedTyConName hits)
582581
in putMsgS $ "fusion-plugin: "
583-
++ getOccString (getName b)
582+
++ binderDisplayName b
584583
++ ": found forbidden type classes ["
585584
++ DL.intercalate ", " names ++ "]"
586585

@@ -592,7 +591,7 @@ reportInspectedClasses dflags reportMode classAnns allBinds (NonRec b _) =
592591
stale = filter (`notElem` present) allowed
593592
unless (null stale) $
594593
putMsgS $ "fusion-plugin: "
595-
++ getOccString (getName b)
594+
++ binderDisplayName b
596595
++ ": redundant PermitTypeClasses entries (safe to remove): ["
597596
++ DL.intercalate ", " (map qualifiedName stale) ++ "]"
598597
warnStalePermitted _ _ = return ()
@@ -629,9 +628,9 @@ dumpCoreSize dflags pkgName modName allBinds b = liftIO $ do
629628

630629
-- Returns 0 on no violations and 1 otherwise.
631630
reportCoreSize
632-
:: DynFlags -> ReportMode -> MAX_CORE_SIZE_FM
631+
:: ReportMode -> MAX_CORE_SIZE_FM
633632
-> [(CoreBndr, CoreExpr)] -> CoreBind -> CoreM Int
634-
reportCoreSize dflags reportMode sizeAnns allBinds (NonRec b _) =
633+
reportCoreSize reportMode sizeAnns allBinds (NonRec b _) =
635634
case lookupBinderAnn b sizeAnns of
636635
Just ann | not (subsumedBySameName allBinds b) -> go ann
637636
_ -> return 0
@@ -647,21 +646,21 @@ reportCoreSize dflags reportMode sizeAnns allBinds (NonRec b _) =
647646
ReportWarn -> return ()
648647
_ ->
649648
putMsgS $ "fusion-plugin: "
650-
++ showWithUnique dflags b
649+
++ binderDisplayName b
651650
++ ": core size "
652651
++ show terms
653652
++ " terms (set of " ++ show (length clSet)
654653
++ " bindings)"
655654
if terms > maxSize
656655
then do
657656
putMsgS $ "fusion-plugin: "
658-
++ showWithUnique dflags b
657+
++ binderDisplayName b
659658
++ ": core size (" ++ show terms
660659
++ " terms) exceeds the specified size ("
661660
++ show maxSize ++ " terms)."
662661
return 1
663662
else return 0
664-
reportCoreSize _ _ _ _ (Rec _) =
663+
reportCoreSize _ _ _ (Rec _) =
665664
error "reportCoreSize: expecting only NonRec binders"
666665

667666
-------------------------------------------------------------------------------
@@ -853,7 +852,7 @@ fusionReport mesg reportMode runInspect opts guts = do
853852
dflags reportMode classAnns allBinds bind
854853
else return 0
855854
n3 <- if runInspect
856-
then reportCoreSize dflags reportMode sizeAnns allBinds bind
855+
then reportCoreSize reportMode sizeAnns allBinds bind
857856
else return 0
858857
let hasViolationAnn =
859858
isJust (lookupBinderAnn b pmAnns)

0 commit comments

Comments
 (0)