Hannes Siebenhandl pushed to branch wip/fendor/homeunit-is-just at Glasgow Haskell Compiler / GHC

Commits:

21 changed files:

Changes:

  • compiler/GHC.hs
    ... ... @@ -678,7 +678,7 @@ setUnitDynFlagsNoCheck uid dflags1 = do
    678 678
            hue
    
    679 679
               { homeUnitEnv_units = unit_state
    
    680 680
               , homeUnitEnv_dflags = updated_dflags
    
    681
    -          , homeUnitEnv_home_unit = Just home_unit
    
    681
    +          , homeUnitEnv_home_unit = home_unit
    
    682 682
               }
    
    683 683
     
    
    684 684
       let unit_env = UnitEnv.ue_updateHomeUnitEnv upd uid (hsc_unit_env hsc_env)
    
    ... ... @@ -767,7 +767,7 @@ setProgramDynFlags_ invalidate_needed dflags = do
    767 767
                 { homeUnitEnv_units = unit_state
    
    768 768
                 , homeUnitEnv_dflags = updated_dflags
    
    769 769
                 , homeUnitEnv_hpt = old_hpt
    
    770
    -            , homeUnitEnv_home_unit = Just home_unit
    
    770
    +            , homeUnitEnv_home_unit = home_unit
    
    771 771
                 }
    
    772 772
     
    
    773 773
             let dflags1 = homeUnitEnv_dflags $ HUG.unitEnv_lookup (ue_currentUnit old_unit_env) home_unit_graph
    
    ... ... @@ -891,7 +891,7 @@ setProgramHUG_ invalidate_needed new_hug0 = do
    891 891
             { homeUnitEnv_units = unit_state
    
    892 892
             , homeUnitEnv_dflags = updated_dflags
    
    893 893
             , homeUnitEnv_hpt = old_hpt
    
    894
    -        , homeUnitEnv_home_unit = Just home_unit
    
    894
    +        , homeUnitEnv_home_unit = home_unit
    
    895 895
             }
    
    896 896
     
    
    897 897
     -- When changing the DynFlags, we want the changes to apply to future
    
    ... ... @@ -1684,7 +1684,7 @@ findQualifiedModule :: GhcMonad m => PkgQual -> ModuleName -> m Module
    1684 1684
     findQualifiedModule pkgqual mod_name = withSession $ \hsc_env -> do
    
    1685 1685
       let logger = hsc_logger hsc_env
    
    1686 1686
       liftIO $ trace_if logger (text "findQualifiedModule" <+> ppr mod_name <+> ppr pkgqual)
    
    1687
    -  let mhome_unit = hsc_home_unit_maybe hsc_env
    
    1687
    +  let home_unit = hsc_home_unit hsc_env
    
    1688 1688
       let dflags = hsc_dflags hsc_env
    
    1689 1689
       let sec = initSourceErrorContext dflags
    
    1690 1690
       case pkgqual of
    
    ... ... @@ -1695,7 +1695,7 @@ findQualifiedModule pkgqual mod_name = withSession $ \hsc_env -> do
    1695 1695
             Nothing -> liftIO $ do
    
    1696 1696
                res <- findImportedModule hsc_env mod_name pkgqual
    
    1697 1697
                case res of
    
    1698
    -             Found loc m | notHomeModuleMaybe mhome_unit m -> return m
    
    1698
    +             Found loc m | notHomeModule home_unit m -> return m
    
    1699 1699
                              | otherwise -> modNotLoadedError dflags m loc
    
    1700 1700
                  err -> throwOneError sec $ noModError hsc_env noSrcSpan mod_name err
    
    1701 1701
     
    

  • compiler/GHC/Driver/Backpack.hs
    ... ... @@ -473,7 +473,7 @@ addUnit u = do
    473 473
               , ue_home_unit_graph =
    
    474 474
                     HUG.unitEnv_singleton
    
    475 475
                         (homeUnitId home_unit)
    
    476
    -                    (HUG.mkHomeUnitEnv unit_state dflags (ue_hpt old_unit_env) (Just home_unit))
    
    476
    +                    (HUG.mkHomeUnitEnv unit_state dflags (ue_hpt old_unit_env) home_unit)
    
    477 477
               , ue_eps       = ue_eps old_unit_env
    
    478 478
               , ue_module_graph = ue_module_graph old_unit_env
    
    479 479
               , ue_uic = ue_uic old_unit_env
    

  • compiler/GHC/Driver/Env.hs
    ... ... @@ -7,7 +7,6 @@ module GHC.Driver.Env
    7 7
        , hscUpdateFlags
    
    8 8
        , hscSetFlags
    
    9 9
        , hsc_home_unit
    
    10
    -   , hsc_home_unit_maybe
    
    11 10
        , hsc_units
    
    12 11
        , hsc_HPT
    
    13 12
        , hsc_HUE
    
    ... ... @@ -120,10 +119,7 @@ runInteractiveHsc :: HscEnv -> Hsc a -> IO a
    120 119
     runInteractiveHsc hsc_env = runHsc (mkInteractiveHscEnv hsc_env)
    
    121 120
     
    
    122 121
     hsc_home_unit :: HscEnv -> HomeUnit
    
    123
    -hsc_home_unit = ue_unsafeHomeUnit . hsc_unit_env
    
    124
    -
    
    125
    -hsc_home_unit_maybe :: HscEnv -> Maybe HomeUnit
    
    126
    -hsc_home_unit_maybe = ue_homeUnit . hsc_unit_env
    
    122
    +hsc_home_unit = ue_homeUnit . hsc_unit_env
    
    127 123
     
    
    128 124
     hsc_units :: HasDebugCallStack => HscEnv -> UnitState
    
    129 125
     hsc_units = ue_homeUnitState . hsc_unit_env
    
    ... ... @@ -388,7 +384,7 @@ lookupIfaceByModuleHsc hsc_env mod = do
    388 384
       lookupIfaceByModule (hsc_HUG hsc_env) (eps_PIT eps) mod
    
    389 385
     
    
    390 386
     mainModIs :: HomeUnitEnv -> Module
    
    391
    -mainModIs hue = mkHomeModule (expectJust $ homeUnitEnv_home_unit hue) (mainModuleNameIs (homeUnitEnv_dflags hue))
    
    387
    +mainModIs hue = mkHomeModule (homeUnitEnv_home_unit hue) (mainModuleNameIs (homeUnitEnv_dflags hue))
    
    392 388
     
    
    393 389
     -- | Retrieve the target code interpreter
    
    394 390
     --
    

  • compiler/GHC/Driver/Main/Hsc.hs
    ... ... @@ -112,7 +112,7 @@ newHscEnv top_dir dflags = do
    112 112
       where
    
    113 113
         home_unit_graph hpt = HUG.unitEnv_singleton
    
    114 114
                             (homeUnitId_ dflags)
    
    115
    -                        (HUG.mkHomeUnitEnv emptyUnitState dflags hpt Nothing)
    
    115
    +                        (HUG.mkHomeUnitEnv emptyUnitState dflags hpt (DefiniteHomeUnit (homeUnitId_ dflags) Nothing))
    
    116 116
     
    
    117 117
     newHscEnvWithHUG :: FilePath -> DynFlags -> UnitId -> HomeUnitGraph -> IO HscEnv
    
    118 118
     newHscEnvWithHUG top_dir top_dynflags cur_unit home_unit_graph = do
    

  • compiler/GHC/Driver/Make.hs
    ... ... @@ -1665,7 +1665,7 @@ maybeRehydrateBefore hsc_env mni (Just mns) = do
    1665 1665
     
    
    1666 1666
       where
    
    1667 1667
        initialise_knot_var hsc_env = liftIO $
    
    1668
    -    let mod_name = homeModuleInstantiation (hsc_home_unit_maybe hsc_env) (moduleNodeInfoModule mni)
    
    1668
    +    let mod_name = homeModuleInstantiation (hsc_home_unit hsc_env) (moduleNodeInfoModule mni)
    
    1669 1669
         in mkModuleEnv . (:[]) . (mod_name,) <$> newIORef emptyTypeEnv
    
    1670 1670
     
    
    1671 1671
     rehydrateAfter :: HscEnv
    

  • compiler/GHC/Driver/Pipeline/Execute.hs
    ... ... @@ -373,7 +373,7 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
    373 373
       let dflags    = hsc_dflags hsc_env
    
    374 374
       let logger    = hsc_logger hsc_env
    
    375 375
       let unit_env  = hsc_unit_env hsc_env
    
    376
    -  let home_unit = hsc_home_unit_maybe hsc_env
    
    376
    +  let home_unit = hsc_home_unit hsc_env
    
    377 377
       let tmpfs     = hsc_tmpfs hsc_env
    
    378 378
       let tmpdir    = tmpDir dflags
    
    379 379
       let platform  = ue_platform unit_env
    
    ... ... @@ -473,12 +473,11 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
    473 473
               -- These symbols are imported into the stub.c file via RtsAPI.h, and the
    
    474 474
               -- way we do the import depends on whether we're currently compiling
    
    475 475
               -- the base package or not.
    
    476
    -                 ++ (case home_unit of
    
    477
    -                        Just hu
    
    478
    -                          | isHomeUnitId hu ghcInternalUnitId
    
    479
    -                          , platformOS platform == OSMinGW32
    
    480
    -                          -> ["-DCOMPILING_GHC_INTERNAL_PACKAGE"]
    
    481
    -                        _ -> [])
    
    476
    +                 ++ (if
    
    477
    +                      | isHomeUnitId home_unit ghcInternalUnitId
    
    478
    +                      , platformOS platform == OSMinGW32
    
    479
    +                      -> ["-DCOMPILING_GHC_INTERNAL_PACKAGE"]
    
    480
    +                      | otherwise -> [])
    
    482 481
     
    
    483 482
                      -- GCC 4.6+ doesn't like -Wimplicit when compiling C++.
    
    484 483
                      ++ (if (cc_phase /= Ccxx && cc_phase /= Cobjcxx)
    

  • compiler/GHC/Driver/Session/Units.hs
    ... ... @@ -17,6 +17,7 @@ import GHC.Driver.Config.Diagnostic
    17 17
     
    
    18 18
     import GHC.Unit.Env
    
    19 19
     import GHC.Unit (UnitId)
    
    20
    +import GHC.Unit.Home (GenHomeUnit(..))
    
    20 21
     import GHC.Unit.Home.PackageTable
    
    21 22
     import qualified GHC.Unit.Home.Graph as HUG
    
    22 23
     import GHC.Unit.State  ( emptyUnitState )
    
    ... ... @@ -139,7 +140,7 @@ initMulti unitArgsFiles lintDynFlagsAndSrcs = do
    139 140
           { homeUnitEnv_units = unit_state
    
    140 141
           , homeUnitEnv_dflags = updated_dflags
    
    141 142
           , homeUnitEnv_hpt = emptyHpt
    
    142
    -      , homeUnitEnv_home_unit = Just home_unit
    
    143
    +      , homeUnitEnv_home_unit = home_unit
    
    143 144
           }
    
    144 145
     
    
    145 146
       checkUnitCycles initial_dflags home_unit_graph
    
    ... ... @@ -237,9 +238,7 @@ createUnitEnvFromFlags unitDflags = do
    237 238
       unitEnvList <- forM unitDflags $ \dflags -> do
    
    238 239
         emptyHpt <- emptyHomePackageTable
    
    239 240
         let newInternalUnitEnv =
    
    240
    -          HUG.mkHomeUnitEnv emptyUnitState dflags emptyHpt Nothing
    
    241
    +          HUG.mkHomeUnitEnv emptyUnitState dflags emptyHpt (DefiniteHomeUnit (homeUnitId_ dflags) Nothing)
    
    241 242
         return (homeUnitId_ dflags, newInternalUnitEnv)
    
    242 243
       let activeUnit = fst $ NE.head unitEnvList
    
    243 244
       return (HUG.hugFromList (NE.toList unitEnvList), activeUnit)
    244
    -
    
    245
    -

  • compiler/GHC/HsToCore/Usage.hs
    ... ... @@ -82,7 +82,7 @@ mkUsageInfo uc plugins fc unit_env
    82 82
       = do
    
    83 83
         file_hashes <- liftIO $ mapM getFileHash dependent_files
    
    84 84
         dirs_hashes <- liftIO $ mapM getDirHash dependent_dirs
    
    85
    -    let hu = ue_unsafeHomeUnit unit_env
    
    85
    +    let hu = ue_homeUnit unit_env
    
    86 86
         -- Dependencies on object files due to TH and plugins
    
    87 87
         object_usages <- liftIO $ mkObjectUsage plugins fc needed_links needed_pkgs
    
    88 88
         let all_home_ids = HUG.allUnits (ue_home_unit_graph unit_env)
    

  • compiler/GHC/Iface/Errors.hs
    ... ... @@ -27,7 +27,7 @@ badIfaceFile file err
    27 27
       = vcat [text "Bad interface file:" <+> text file,
    
    28 28
               nest 4 err]
    
    29 29
     
    
    30
    -cannotFindInterface :: UnitState -> Maybe HomeUnit -> Profile
    
    30
    +cannotFindInterface :: UnitState -> HomeUnit -> Profile
    
    31 31
                         -> ModuleName -> InstalledFindResult -> MissingInterfaceError
    
    32 32
     cannotFindInterface us mhu p mn ifr =
    
    33 33
       CantFindErr us FindingInterface $
    
    ... ... @@ -35,12 +35,12 @@ cannotFindInterface us mhu p mn ifr =
    35 35
     
    
    36 36
     cantFindInstalledErr
    
    37 37
         :: UnitState
    
    38
    -    -> Maybe HomeUnit
    
    38
    +    -> HomeUnit
    
    39 39
         -> Profile
    
    40 40
         -> ModuleName
    
    41 41
         -> InstalledFindResult
    
    42 42
         -> CantFindInstalled
    
    43
    -cantFindInstalledErr unit_state mhome_unit profile mod_name find_result
    
    43
    +cantFindInstalledErr unit_state home_unit profile mod_name find_result
    
    44 44
       = CantFindInstalled mod_name more_info
    
    45 45
       where
    
    46 46
         build_tag  = waysBuildTag (profileWays profile)
    
    ... ... @@ -52,7 +52,7 @@ cantFindInstalledErr unit_state mhome_unit profile mod_name find_result
    52 52
     
    
    53 53
                 InstalledNotFound files mb_pkg
    
    54 54
                     | Just pkg <- mb_pkg
    
    55
    -                , notHomeUnitId mhome_unit pkg
    
    55
    +                , not (isHomeUnitId home_unit pkg)
    
    56 56
                     -> not_found_in_package pkg $ fmap unsafeDecodeUtf files
    
    57 57
     
    
    58 58
                     | null files
    
    ... ... @@ -102,7 +102,7 @@ cantFindErr _ _ mod_name (FoundMultiple mods)
    102 102
     cantFindErr unit_env profile mod_name find_result
    
    103 103
       = CantFindInstalled mod_name more_info
    
    104 104
       where
    
    105
    -    mhome_unit = ue_homeUnit unit_env
    
    105
    +    home_unit = ue_homeUnit unit_env
    
    106 106
         more_info
    
    107 107
           = case find_result of
    
    108 108
                 NoPackage pkg
    
    ... ... @@ -111,12 +111,7 @@ cantFindErr unit_env profile mod_name find_result
    111 111
                          , fr_mods_hidden = mod_hiddens, fr_pkgs_hidden = pkg_hiddens
    
    112 112
                          , fr_unusables = unusables, fr_suggestions = suggest }
    
    113 113
                     | Just pkg <- mb_pkg
    
    114
    -                , Nothing <- mhome_unit           -- no home-unit
    
    115
    -                -> not_found_in_package (toUnitId pkg) files
    
    116
    -
    
    117
    -                | Just pkg <- mb_pkg
    
    118
    -                , Just home_unit <- mhome_unit    -- there is a home-unit but the
    
    119
    -                , not (isHomeUnit home_unit pkg)  -- module isn't from it
    
    114
    +                , not (isHomeUnit home_unit pkg)  -- module isn't from this home unit
    
    120 115
                     -> not_found_in_package (toUnitId pkg) files
    
    121 116
     
    
    122 117
                     | not (null suggest)
    

  • compiler/GHC/Iface/Load.hs
    ... ... @@ -446,14 +446,14 @@ loadInterface doc_str mod from
    446 446
     
    
    447 447
                     -- Check whether we have the interface already
    
    448 448
             ; hsc_env <- getTopEnv
    
    449
    -        ; let mhome_unit = ue_homeUnit (hsc_unit_env hsc_env)
    
    449
    +        ; let home_unit = ue_homeUnit (hsc_unit_env hsc_env)
    
    450 450
             ; liftIO (lookupIfaceByModule hug (eps_PIT eps) mod) >>= \case {
    
    451 451
                 Just iface
    
    452 452
                     -> return (Succeeded iface) ;   -- Already loaded
    
    453 453
                 _ -> do {
    
    454 454
     
    
    455 455
             -- READ THE MODULE IN
    
    456
    -        ; read_result <- case wantHiBootFile mhome_unit eps mod from of
    
    456
    +        ; read_result <- case wantHiBootFile home_unit eps mod from of
    
    457 457
                                Failed err             -> return (Failed err)
    
    458 458
                                Succeeded hi_boot_file -> do
    
    459 459
                                  hsc_env <- getTopEnv
    
    ... ... @@ -549,7 +549,7 @@ loadInterface doc_str mod from
    549 549
     
    
    550 550
             ; warnPprTrace bad_boot "loadInterface" (ppr mod) $
    
    551 551
               updateEps_  $ \ eps ->
    
    552
    -           if elemModuleEnv mod (eps_PIT eps) || is_external_sig mhome_unit iface
    
    552
    +           if elemModuleEnv mod (eps_PIT eps) || is_external_sig home_unit iface
    
    553 553
                     then eps
    
    554 554
                else if bad_boot
    
    555 555
                     -- See Note [Loading your own hi-boot file]
    
    ... ... @@ -714,12 +714,12 @@ dontLeakTheHUG thing_inside = do
    714 714
     -- | Returns @True@ if a 'ModIface' comes from an external package.
    
    715 715
     -- In this case, we should NOT load it into the EPS; the entities
    
    716 716
     -- should instead come from the local merged signature interface.
    
    717
    -is_external_sig :: Maybe HomeUnit -> ModIface -> Bool
    
    718
    -is_external_sig mhome_unit iface =
    
    717
    +is_external_sig :: HomeUnit -> ModIface -> Bool
    
    718
    +is_external_sig home_unit iface =
    
    719 719
         -- It's a signature iface...
    
    720 720
         mi_semantic_module iface /= mi_module iface &&
    
    721 721
         -- and it's not from the local package
    
    722
    -    notHomeModuleMaybe mhome_unit (mi_module iface)
    
    722
    +    notHomeModule home_unit (mi_module iface)
    
    723 723
     
    
    724 724
     -- | This is an improved version of 'findAndReadIface' which can also
    
    725 725
     -- handle the case when a user requests @p[A=<B>]:M@ but we only
    
    ... ... @@ -743,13 +743,12 @@ computeInterface
    743 743
       -> IO (MaybeErr MissingInterfaceError (ModIface, ModLocation))
    
    744 744
     computeInterface hsc_env doc_str hi_boot_file mod0 = do
    
    745 745
       massert (not (isHoleModule mod0))
    
    746
    -  let mhome_unit  = hsc_home_unit_maybe hsc_env
    
    746
    +  let home_unit  = hsc_home_unit hsc_env
    
    747 747
       let find_iface m = findAndReadIface hsc_env doc_str
    
    748 748
                                           m mod0 hi_boot_file
    
    749 749
       case getModuleInstantiation mod0 of
    
    750 750
           (imod, Just indef)
    
    751
    -        | Just home_unit <- mhome_unit
    
    752
    -        , isHomeUnitIndefinite home_unit ->
    
    751
    +        | isHomeUnitIndefinite home_unit ->
    
    753 752
               find_iface imod >>= \case
    
    754 753
                 Succeeded (iface0, path) ->
    
    755 754
                   rnModIface hsc_env (instUnitInsts (moduleUnit indef)) Nothing iface0 >>= \case
    
    ... ... @@ -806,13 +805,13 @@ moduleFreeHolesPrecise doc_str mod
    806 805
                     return (Succeeded (renameFreeHoles ifhs insts))
    
    807 806
                 Failed err -> return (Failed err)
    
    808 807
     
    
    809
    -wantHiBootFile :: Maybe HomeUnit -> ExternalPackageState -> Module -> WhereFrom
    
    808
    +wantHiBootFile :: HomeUnit -> ExternalPackageState -> Module -> WhereFrom
    
    810 809
                    -> MaybeErr MissingInterfaceError IsBootInterface
    
    811 810
     -- Figure out whether we want Foo.hi or Foo.hi-boot
    
    812
    -wantHiBootFile mhome_unit eps mod from
    
    811
    +wantHiBootFile home_unit eps mod from
    
    813 812
       = case from of
    
    814 813
            ImportByUser usr_boot
    
    815
    -          | usr_boot == IsBoot && notHomeModuleMaybe mhome_unit mod
    
    814
    +          | usr_boot == IsBoot && notHomeModule home_unit mod
    
    816 815
               -> Failed (BadSourceImport mod)
    
    817 816
               | otherwise -> Succeeded usr_boot
    
    818 817
     
    
    ... ... @@ -820,7 +819,7 @@ wantHiBootFile mhome_unit eps mod from
    820 819
               -> Succeeded NotBoot
    
    821 820
     
    
    822 821
            ImportBySystem
    
    823
    -          | notHomeModuleMaybe mhome_unit mod
    
    822
    +          | notHomeModule home_unit mod
    
    824 823
               -> Succeeded NotBoot
    
    825 824
                  -- If the module to be imported is not from this package
    
    826 825
                  -- don't look it up in eps_is_boot, because that is keyed
    
    ... ... @@ -894,7 +893,7 @@ findAndReadIface hsc_env doc_str mod wanted_mod hi_boot_file = do
    894 893
       let profile = targetProfile dflags
    
    895 894
           unit_state = hsc_units hsc_env
    
    896 895
           name_cache = hsc_NC hsc_env
    
    897
    -      mhome_unit  = hsc_home_unit_maybe hsc_env
    
    896
    +      home_unit  = hsc_home_unit hsc_env
    
    898 897
           dflags     = hsc_dflags hsc_env
    
    899 898
           logger     = hsc_logger hsc_env
    
    900 899
           hooks      = hsc_hooks hsc_env
    
    ... ... @@ -933,7 +932,7 @@ findAndReadIface hsc_env doc_str mod wanted_mod hi_boot_file = do
    933 932
               trace_if logger (text "...not found")
    
    934 933
               return $ Failed $ cannotFindInterface
    
    935 934
                                   unit_state
    
    936
    -                              mhome_unit
    
    935
    +                              home_unit
    
    937 936
                                   profile
    
    938 937
                                   (moduleName mod)
    
    939 938
                                   err
    

  • compiler/GHC/Linker/Deps.hs
    ... ... @@ -160,22 +160,18 @@ get_link_deps opts pls maybe_normal_osuf span mods = do
    160 160
           = HUG.lookupHugByModule mod (ue_home_unit_graph unit_env) >>= \case
    
    161 161
               Just mod_info -> adjust_linkable (expectJust (homeModLinkable mod_info))
    
    162 162
               Nothing -> do
    
    163
    -           -- It's not in the HPT because we are in one shot mode,
    
    164
    -           -- so use the Finder to get a ModLocation...
    
    165
    -           case ue_homeUnit unit_env of
    
    166
    -            Nothing -> no_obj mod
    
    167
    -            Just home_unit -> do
    
    168
    -
    
    169
    -              let fc = ldFinderCache opts
    
    170
    -              let fopts = ldFinderOpts opts
    
    171
    -              mb_stuff <- findHomeModule fc fopts home_unit (moduleName mod)
    
    172
    -              case mb_stuff of
    
    173
    -                Found loc _ -> do
    
    174
    -                  from_bc <- ldLoadByteCode opts mod loc
    
    175
    -                  maybe (fallback_no_bytecode home_unit mod) pure from_bc
    
    176
    -                _ -> fallback_no_bytecode home_unit mod
    
    163
    +            -- It's not in the HPT because we are in one shot mode,
    
    164
    +            -- so use the Finder to get a ModLocation...
    
    165
    +            let fc = ldFinderCache opts
    
    166
    +            let fopts = ldFinderOpts opts
    
    167
    +            mb_stuff <- findHomeModule fc fopts home_unit (moduleName mod)
    
    168
    +            case mb_stuff of
    
    169
    +              Found loc _ -> do
    
    170
    +                from_bc <- ldLoadByteCode opts mod loc
    
    171
    +                maybe (fallback_no_bytecode home_unit mod) pure from_bc
    
    172
    +              _ -> fallback_no_bytecode home_unit mod
    
    177 173
             where
    
    178
    -
    
    174
    +            home_unit = ue_homeUnit unit_env
    
    179 175
                 fallback_no_bytecode home_unit mod = do
    
    180 176
                   let fc = ldFinderCache opts
    
    181 177
                   let fopts = ldFinderOpts opts
    

  • compiler/GHC/Rename/Names.hs
    ... ... @@ -452,7 +452,7 @@ renamePkgQual :: UnitEnv -> ModuleName -> Maybe FastString -> PkgQual
    452 452
     renamePkgQual unit_env mn mb_pkg = case mb_pkg of
    
    453 453
       Nothing -> NoPkgQual
    
    454 454
       Just pkg_fs
    
    455
    -    | Just uid <- homeUnitId <$> ue_homeUnit unit_env
    
    455
    +    | uid <- homeUnitId (ue_homeUnit unit_env)
    
    456 456
         , pkg_fs == fsLit "this"
    
    457 457
         -> ThisPkg uid
    
    458 458
     
    

  • compiler/GHC/StgToJS/Linker/Linker.hs
    ... ... @@ -485,17 +485,15 @@ computeLinkDependencies cfg unit_env link_spec finder_opts finder_cache ar_cache
    485 485
       let load_info mod = do
    
    486 486
             -- Adapted from the tangled code in GHC.Linker.Loader.getLinkDeps.
    
    487 487
             linkable <- HUG.lookupHugByModule mod (ue_home_unit_graph unit_env) >>= \case
    
    488
    -          Nothing ->
    
    488
    +          Nothing -> do
    
    489 489
                     -- It's not in the HPT because we are in one shot mode,
    
    490 490
                     -- so use the Finder to get a ModLocation...
    
    491
    -              case ue_homeUnit unit_env of
    
    492
    -                Nothing -> pprPanic "getDeps: No home-unit: " (pprModule mod)
    
    493
    -                Just home_unit -> do
    
    494
    -                    mb_stuff <- findHomeModule finder_cache finder_opts home_unit (moduleName mod)
    
    495
    -                    case mb_stuff of
    
    496
    -                      Found loc mod -> found loc mod
    
    497
    -                      _ -> pprPanic "getDeps: Couldn't find home-module: " (pprModule mod)
    
    491
    +                mb_stuff <- findHomeModule finder_cache finder_opts home_unit (moduleName mod)
    
    492
    +                case mb_stuff of
    
    493
    +                  Found loc mod -> found loc mod
    
    494
    +                  _ -> pprPanic "getDeps: Couldn't find home-module: " (pprModule mod)
    
    498 495
                     where
    
    496
    +                    home_unit = ue_homeUnit unit_env
    
    499 497
                         found loc mod = do {
    
    500 498
                           mb_lnk <- findObjectLinkableMaybe mod loc ;
    
    501 499
                           case mb_lnk of {
    

  • compiler/GHC/Tc/Utils/Backpack.hs
    ... ... @@ -285,11 +285,11 @@ implicitRequirements hsc_env normal_imports
    285 285
         forM normal_imports $ \(mb_pkg, L _ imp) -> do
    
    286 286
             found <- findImportedModule hsc_env imp mb_pkg
    
    287 287
             case found of
    
    288
    -            Found _ mod | notHomeModuleMaybe mhome_unit mod ->
    
    288
    +            Found _ mod | notHomeModule home_unit mod ->
    
    289 289
                     return (uniqDSetToList (moduleFreeHoles mod))
    
    290 290
                 _ -> return []
    
    291 291
       where
    
    292
    -    mhome_unit = hsc_home_unit_maybe hsc_env
    
    292
    +    home_unit = hsc_home_unit hsc_env
    
    293 293
     
    
    294 294
     -- | Like @implicitRequirements'@, but returns either the module name, if it is
    
    295 295
     -- a free hole, or the instantiated unit the imported module is from, so that
    
    ... ... @@ -301,13 +301,13 @@ implicitRequirementsShallow
    301 301
       -> IO ([ModuleName], [InstantiatedUnit])
    
    302 302
     implicitRequirementsShallow hsc_env normal_imports = go ([], []) normal_imports
    
    303 303
      where
    
    304
    -  mhome_unit = hsc_home_unit_maybe hsc_env
    
    304
    +  home_unit = hsc_home_unit hsc_env
    
    305 305
     
    
    306 306
       go acc [] = pure acc
    
    307 307
       go (accL, accR) ((_stage, mb_pkg, L _ imp):imports) = do
    
    308 308
         found <- findImportedModule hsc_env imp mb_pkg
    
    309 309
         let acc' = case found of
    
    310
    -          Found _ mod | notHomeModuleMaybe mhome_unit mod ->
    
    310
    +          Found _ mod | notHomeModule home_unit mod ->
    
    311 311
                   case moduleUnit mod of
    
    312 312
                       HoleUnit -> (moduleName mod : accL, accR)
    
    313 313
                       RealUnit _ -> (accL, accR)
    

  • compiler/GHC/Tc/Utils/Env.hs
    ... ... @@ -173,8 +173,8 @@ lookupGlobal_maybe :: HscEnv -> Name -> IO (MaybeErr (Either Name IfaceMessage)
    173 173
     lookupGlobal_maybe hsc_env name
    
    174 174
       = do  {    -- Try local envt
    
    175 175
               let mod = icInteractiveModule (hsc_IC hsc_env)
    
    176
    -              mhome_unit = hsc_home_unit_maybe hsc_env
    
    177
    -              tcg_semantic_mod = homeModuleInstantiation mhome_unit mod
    
    176
    +              home_unit = hsc_home_unit hsc_env
    
    177
    +              tcg_semantic_mod = homeModuleInstantiation home_unit mod
    
    178 178
     
    
    179 179
             ; if nameIsLocalOrFrom tcg_semantic_mod name
    
    180 180
               then return $ Failed $ Left name
    

  • compiler/GHC/Tc/Utils/Monad.hs
    ... ... @@ -370,7 +370,7 @@ initTcGblEnv hsc_env hsc_src keep_rn_syntax mod loc =
    370 370
          ; let
    
    371 371
             -- bangs to avoid leaking the env (#19356)
    
    372 372
             !dflags = hsc_dflags hsc_env
    
    373
    -        !mhome_unit = hsc_home_unit_maybe hsc_env
    
    373
    +        !home_unit = hsc_home_unit hsc_env
    
    374 374
             !logger = hsc_logger hsc_env
    
    375 375
     
    
    376 376
             maybe_rn_syntax :: forall a. a -> Maybe a ;
    
    ... ... @@ -398,7 +398,7 @@ initTcGblEnv hsc_env hsc_src keep_rn_syntax mod loc =
    398 398
               , tcg_th_docs            = th_docs_var
    
    399 399
     
    
    400 400
               , tcg_mod                = mod
    
    401
    -          , tcg_semantic_mod       = homeModuleInstantiation mhome_unit mod
    
    401
    +          , tcg_semantic_mod       = homeModuleInstantiation home_unit mod
    
    402 402
               , tcg_src                = hsc_src
    
    403 403
               , tcg_rdr_env            = emptyGlobalRdrEnv
    
    404 404
               , tcg_fix_env            = emptyNameEnv
    
    ... ... @@ -2578,11 +2578,11 @@ initIfaceTcRn thing_inside
    2578 2578
       = do  { tcg_env <- getGblEnv
    
    2579 2579
             ; hsc_env <- getTopEnv
    
    2580 2580
               -- bangs to avoid leaking the envs (#19356)
    
    2581
    -        ; let !mhome_unit = hsc_home_unit_maybe hsc_env
    
    2581
    +        ; let !home_unit = hsc_home_unit hsc_env
    
    2582 2582
                   !knot_vars = tcg_type_env_var tcg_env
    
    2583 2583
                   -- When we are instantiating a signature, we DEFINITELY
    
    2584 2584
                   -- do not want to knot tie.
    
    2585
    -              is_instantiate = fromMaybe False (isHomeUnitInstantiating <$> mhome_unit)
    
    2585
    +              is_instantiate = isHomeUnitInstantiating home_unit
    
    2586 2586
             ; let { if_env = IfGblEnv {
    
    2587 2587
                                 if_doc = text "initIfaceTcRn",
    
    2588 2588
                                 if_rec_types =
    

  • compiler/GHC/Unit/Env.hs
    ... ... @@ -53,7 +53,6 @@ module GHC.Unit.Env
    53 53
         , ue_unitHomeUnit_maybe
    
    54 54
         , ue_updateHomeUnitEnv
    
    55 55
         , ue_all_home_unit_ids
    
    56
    -    , ue_unsafeHomeUnit
    
    57 56
     
    
    58 57
         -- * HUG Re-export
    
    59 58
         , HomeUnitGraph
    
    ... ... @@ -235,14 +234,13 @@ preloadUnitsInfo' unit_env ids0 = all_infos
    235 234
       where
    
    236 235
         unit_state = HUG.homeUnitEnv_units (ue_currentHomeUnitEnv unit_env)
    
    237 236
         ids      = ids0 ++ inst_ids
    
    238
    -    inst_ids = case ue_homeUnit unit_env of
    
    239
    -      Nothing -> []
    
    240
    -      Just home_unit
    
    241
    -       -- An indefinite package will have insts to HOLE,
    
    242
    -       -- which is not a real package. Don't look it up.
    
    243
    -       -- Fixes #14525
    
    244
    -       | isHomeUnitIndefinite home_unit -> []
    
    245
    -       | otherwise -> map (toUnitId . moduleUnit . snd) (homeUnitInstantiations home_unit)
    
    237
    +    home_unit = ue_homeUnit unit_env
    
    238
    +    inst_ids
    
    239
    +      -- An indefinite package will have insts to HOLE,
    
    240
    +      -- which is not a real package. Don't look it up.
    
    241
    +      -- Fixes #14525
    
    242
    +      | isHomeUnitIndefinite home_unit = []
    
    243
    +      | otherwise = map (toUnitId . moduleUnit . snd) (homeUnitInstantiations home_unit)
    
    246 244
         pkg_map = unitInfoMap unit_state
    
    247 245
         preload = preloadUnits unit_state
    
    248 246
     
    
    ... ... @@ -320,20 +318,15 @@ ue_setFlags dflags env =
    320 318
     -- Query and modify home units in HomeUnitEnv
    
    321 319
     -- -------------------------------------------------------
    
    322 320
     
    
    323
    -ue_homeUnit :: UnitEnv -> Maybe HomeUnit
    
    321
    +ue_homeUnit :: UnitEnv -> HomeUnit
    
    324 322
     ue_homeUnit = HUG.homeUnitEnv_home_unit . ue_currentHomeUnitEnv
    
    325 323
     
    
    326
    -ue_unsafeHomeUnit :: UnitEnv -> HomeUnit
    
    327
    -ue_unsafeHomeUnit ue = case ue_homeUnit ue of
    
    328
    -  Nothing -> panic "ue_unsafeHomeUnit: No home unit"
    
    329
    -  Just h  -> h
    
    330
    -
    
    331 324
     ue_unitHomeUnit :: UnitId -> UnitEnv -> HomeUnit
    
    332 325
     ue_unitHomeUnit uid = expectJust . ue_unitHomeUnit_maybe uid
    
    333 326
     
    
    334 327
     ue_unitHomeUnit_maybe :: UnitId -> UnitEnv -> Maybe HomeUnit
    
    335 328
     ue_unitHomeUnit_maybe uid ue_env =
    
    336
    -  HUG.homeUnitEnv_home_unit =<< HUG.lookupHugUnitId uid (ue_home_unit_graph ue_env)
    
    329
    +  HUG.homeUnitEnv_home_unit <$> HUG.lookupHugUnitId uid (ue_home_unit_graph ue_env)
    
    337 330
     
    
    338 331
     -- -------------------------------------------------------
    
    339 332
     -- Query and modify the currently active unit
    

  • compiler/GHC/Unit/Finder.hs
    ... ... @@ -5,6 +5,7 @@
    5 5
     
    
    6 6
     
    
    7 7
     {-# LANGUAGE RecordWildCards  #-}
    
    8
    +{-# LANGUAGE MultiWayIf #-}
    
    8 9
     
    
    9 10
     -- | Module finder
    
    10 11
     module GHC.Unit.Finder (
    
    ... ... @@ -184,7 +185,7 @@ getDirHash dir = do
    184 185
     findImportedModule :: HscEnv -> ModuleName -> PkgQual -> IO FindResult
    
    185 186
     findImportedModule hsc_env mod pkg_qual =
    
    186 187
       let fc           = hsc_FC hsc_env
    
    187
    -      mb_home_unit = hsc_home_unit_maybe hsc_env
    
    188
    +      mb_home_unit = hsc_home_unit hsc_env
    
    188 189
           dflags       = hsc_dflags hsc_env
    
    189 190
           fopts        = initFinderOpts dflags
    
    190 191
       in do
    
    ... ... @@ -203,32 +204,29 @@ findImportedModuleNoHsc
    203 204
       -> FinderOpts
    
    204 205
       -> UnitEnv
    
    205 206
       -> HomeModuleNameProvidersMap
    
    206
    -  -> Maybe HomeUnit
    
    207
    +  -> HomeUnit
    
    207 208
       -> ModuleName
    
    208 209
       -> PkgQual
    
    209 210
       -> IO FindResult
    
    210
    -findImportedModuleNoHsc fc fopts ue home_module_name_providers_map mb_home_unit mod_name mb_pkg =
    
    211
    +findImportedModuleNoHsc fc fopts ue home_module_name_providers_map home_unit mod_name mb_pkg =
    
    211 212
       case mb_pkg of
    
    212 213
         NoPkgQual  -> unqual_import
    
    213
    -    ThisPkg uid | (homeUnitId <$> mb_home_unit) == Just uid -> home_import
    
    214
    +    ThisPkg uid | homeUnitId home_unit == uid -> home_import
    
    214 215
                     | Just os <- lookup uid other_fopts -> home_pkg_import (uid, os)
    
    215
    -                | otherwise -> pprPanic "findImportModule" (ppr mod_name $$ ppr mb_pkg $$ ppr (homeUnitId <$> mb_home_unit) $$ ppr uid $$ ppr (map fst all_opts))
    
    216
    +                | otherwise -> pprPanic "findImportModule" (ppr mod_name $$ ppr mb_pkg $$ ppr home_unit_id $$ ppr uid $$ ppr (map fst all_opts))
    
    216 217
         OtherPkg _ -> pkg_import
    
    217 218
       where
    
    218 219
     
    
    219
    -    mb_home_unit_id :: Maybe UnitId
    
    220
    -    mb_home_unit_id = homeUnitId <$> mb_home_unit
    
    220
    +    home_unit_id :: UnitId
    
    221
    +    home_unit_id = homeUnitId home_unit
    
    221 222
     
    
    222 223
         all_opts :: [(UnitId, FinderOpts)]
    
    223
    -    all_opts = case mb_home_unit_id of
    
    224
    -        Nothing           -> other_fopts
    
    225
    -        Just home_unit_id -> (home_unit_id, fopts) : other_fopts
    
    224
    +    all_opts =
    
    225
    +      (home_unit_id, fopts) : other_fopts
    
    226 226
     
    
    227 227
         home_import :: IO FindResult
    
    228
    -    home_import = case mb_home_unit of
    
    229
    -        Just home_unit -> findHomeModule fc fopts home_unit mod_name
    
    230
    -        Nothing        -> pure $
    
    231
    -                          NoPackage (panic "findImportedModule: no home-unit")
    
    228
    +    home_import =
    
    229
    +      findHomeModule fc fopts home_unit mod_name
    
    232 230
     
    
    233 231
         home_pkg_import :: (UnitId, FinderOpts) -> IO FindResult
    
    234 232
         home_pkg_import = findHomeUnitDepModule fc ue home_module_name_providers_map mod_name
    
    ... ... @@ -238,13 +236,11 @@ findImportedModuleNoHsc fc fopts ue home_module_name_providers_map mb_home_unit
    238 236
     
    
    239 237
         unqual_import :: IO FindResult
    
    240 238
         unqual_import = findHomeOrRegularPackageModule fc fopts ue
    
    241
    -                        home_module_name_providers_map mb_home_unit mod_name
    
    239
    +                        home_module_name_providers_map home_unit mod_name
    
    242 240
     
    
    243 241
         unit_state :: UnitState
    
    244
    -    unit_state = case mb_home_unit_id of
    
    245
    -        Nothing           -> ue_homeUnitState ue
    
    246
    -        Just home_unit_id -> HUG.homeUnitEnv_units $
    
    247
    -                             ue_findHomeUnitEnv home_unit_id ue
    
    242
    +    unit_state = HUG.homeUnitEnv_units $
    
    243
    +      ue_findHomeUnitEnv home_unit_id ue
    
    248 244
     
    
    249 245
         other_fopts :: [(UnitId, FinderOpts)]
    
    250 246
         other_fopts = homeUnitDepsFinderOpts ue home_module_name_providers_map
    
    ... ... @@ -259,24 +255,22 @@ findPluginModuleNoHsc
    259 255
       -> FinderOpts
    
    260 256
       -> UnitEnv
    
    261 257
       -> HomeModuleNameProvidersMap
    
    262
    -  -> Maybe HomeUnit
    
    258
    +  -> HomeUnit
    
    263 259
       -> ModuleName
    
    264 260
       -> IO FindResult
    
    265
    -findPluginModuleNoHsc fc fopts ue home_module_name_providers_map mb_home_unit@(Just home_unit) mod_name =
    
    261
    +findPluginModuleNoHsc fc fopts ue home_module_name_providers_map home_unit mod_name =
    
    266 262
         findHomeModuleAmongDeps fc fopts ue home_module_name_providers_map
    
    267
    -                            mb_home_unit mod_name
    
    263
    +                            home_unit mod_name
    
    268 264
         `orIfNotFound`
    
    269 265
         findExposedPluginPackageModule fc fopts unit_state mod_name
    
    270 266
       where
    
    271 267
         unit_state = HUG.homeUnitEnv_units $
    
    272 268
                      ue_findHomeUnitEnv (homeUnitId home_unit) ue
    
    273
    -findPluginModuleNoHsc fc fopts ue _ Nothing mod_name =
    
    274
    -  findExposedPluginPackageModule fc fopts (ue_homeUnitState ue) mod_name
    
    275 269
     
    
    276 270
     findPluginModule :: HscEnv -> ModuleName -> IO FindResult
    
    277 271
     findPluginModule hsc_env mod_name = do
    
    278 272
       let fc           = hsc_FC hsc_env
    
    279
    -      mb_home_unit = hsc_home_unit_maybe hsc_env
    
    273
    +      mb_home_unit = hsc_home_unit hsc_env
    
    280 274
           home_module_name_providers_map =
    
    281 275
             mgHomeModuleNameProvidersMap (hsc_mod_graph hsc_env)
    
    282 276
       findPluginModuleNoHsc fc (initFinderOpts (hsc_dflags hsc_env))
    
    ... ... @@ -351,7 +345,7 @@ findHomeUnitDepModule fc ue home_module_name_providers_map mod_name (uid, opts)
    351 345
         | Just real_mod_name
    
    352 346
               <- lookupUniqMap (finder_reexportedModules opts) mod_name
    
    353 347
             = findHomeOrRegularPackageModule fc opts ue home_module_name_providers_map
    
    354
    -              (Just $ DefiniteHomeUnit uid Nothing)
    
    348
    +              (DefiniteHomeUnit uid Nothing)
    
    355 349
                   real_mod_name
    
    356 350
         | elementOfUniqSet mod_name (finder_hiddenModules opts)
    
    357 351
             = return (mkHomeHidden uid)
    
    ... ... @@ -367,26 +361,21 @@ findHomeModuleAmongDeps
    367 361
       -> FinderOpts
    
    368 362
       -> UnitEnv
    
    369 363
       -> HomeModuleNameProvidersMap
    
    370
    -  -> Maybe HomeUnit
    
    364
    +  -> HomeUnit
    
    371 365
       -> ModuleName
    
    372 366
       -> IO FindResult
    
    373
    -findHomeModuleAmongDeps fc fopts ue home_module_name_providers_map mb_home_unit mod_name =
    
    367
    +findHomeModuleAmongDeps fc fopts ue home_module_name_providers_map home_unit mod_name =
    
    374 368
         foldr1 orIfNotFound (home_import :| map home_pkg_import other_fopts)
    
    375 369
         -- Do not try to be smart and change this to `foldr orIfNotFound home_import
    
    376 370
         -- (map home_pkg_import other_fopts)`, as that would not be the same.
    
    377 371
         -- `home_import` is first because we need to first look within the current
    
    378 372
         -- unit before looking at the other units in order.
    
    379 373
       where
    
    380
    -    home_import = case mb_home_unit of
    
    381
    -        Just home_unit -> findHomeModule fc fopts home_unit mod_name
    
    382
    -        Nothing        -> pure $
    
    383
    -                          NoPackage (panic "findHomeModuleAmongDeps: no home-unit")
    
    374
    +    home_import = findHomeModule fc fopts home_unit mod_name
    
    375
    +
    
    384 376
         home_pkg_import = findHomeUnitDepModule fc ue home_module_name_providers_map mod_name
    
    385 377
     
    
    386
    -    unit_state = case homeUnitId <$> mb_home_unit of
    
    387
    -        Nothing           -> ue_homeUnitState ue
    
    388
    -        Just home_unit_id -> HUG.homeUnitEnv_units $
    
    389
    -                             ue_findHomeUnitEnv home_unit_id ue
    
    378
    +    unit_state = HUG.homeUnitEnv_units $ ue_findHomeUnitEnv (homeUnitId home_unit) ue
    
    390 379
         other_fopts = homeUnitDepsFinderOpts ue home_module_name_providers_map
    
    391 380
                                              unit_state mod_name
    
    392 381
     
    
    ... ... @@ -397,32 +386,29 @@ findHomeOrRegularPackageModule
    397 386
       -> FinderOpts
    
    398 387
       -> UnitEnv
    
    399 388
       -> HomeModuleNameProvidersMap
    
    400
    -  -> Maybe HomeUnit
    
    389
    +  -> HomeUnit
    
    401 390
       -> ModuleName
    
    402 391
       -> IO FindResult
    
    403
    -findHomeOrRegularPackageModule fc fopts ue home_module_name_providers_map mb_home_unit mod_name =
    
    392
    +findHomeOrRegularPackageModule fc fopts ue home_module_name_providers_map home_unit mod_name =
    
    404 393
         findHomeModuleAmongDeps fc fopts ue home_module_name_providers_map
    
    405
    -                            mb_home_unit mod_name
    
    394
    +                            home_unit mod_name
    
    406 395
         `orIfNotFound`
    
    407 396
         findExposedPackageModule fc fopts unit_state mod_name NoPkgQual
    
    408 397
       where
    
    409
    -    unit_state = case homeUnitId <$> mb_home_unit of
    
    410
    -        Nothing           -> ue_homeUnitState ue
    
    411
    -        Just home_unit_id -> HUG.homeUnitEnv_units $
    
    412
    -                             ue_findHomeUnitEnv home_unit_id ue
    
    398
    +    unit_state = HUG.homeUnitEnv_units $ ue_findHomeUnitEnv (homeUnitId home_unit) ue
    
    413 399
     
    
    414 400
     
    
    415 401
     -- | A version of findExactModule which takes the exact parts of the HscEnv it needs
    
    416 402
     -- directly.
    
    417
    -findExactModuleNoHsc :: FinderCache -> FinderOpts -> UnitEnvGraph FinderOpts -> UnitState -> Maybe HomeUnit -> InstalledModule -> IsBootInterface -> IO InstalledFindResult
    
    418
    -findExactModuleNoHsc fc fopts other_fopts unit_state mb_home_unit mod is_boot = do
    
    419
    -  res <- case mb_home_unit of
    
    420
    -    Just home_unit
    
    403
    +findExactModuleNoHsc :: FinderCache -> FinderOpts -> UnitEnvGraph FinderOpts -> UnitState -> HomeUnit -> InstalledModule -> IsBootInterface -> IO InstalledFindResult
    
    404
    +findExactModuleNoHsc fc fopts other_fopts unit_state home_unit mod is_boot = do
    
    405
    +  res <-
    
    406
    +    if
    
    421 407
          | isHomeInstalledModule home_unit mod
    
    422 408
             -> findInstalledHomeModule fc fopts (homeUnitId home_unit) (moduleName mod)
    
    423 409
          | Just home_fopts <- HUG.unitEnv_lookup_maybe (moduleUnit mod) other_fopts
    
    424 410
             -> findInstalledHomeModule fc home_fopts (moduleUnit mod) (moduleName mod)
    
    425
    -    _ -> findPackageModule fc unit_state fopts mod
    
    411
    +     | otherwise -> findPackageModule fc unit_state fopts mod
    
    426 412
       case (res, is_boot) of
    
    427 413
         (InstalledFound loc, IsBoot) -> return (InstalledFound (addBootSuffixLocn loc))
    
    428 414
         _ -> return res
    
    ... ... @@ -438,7 +424,7 @@ findExactModule hsc_env mod is_boot = do
    438 424
       let dflags = hsc_dflags hsc_env
    
    439 425
       let fc = hsc_FC hsc_env
    
    440 426
       let unit_state = hsc_units hsc_env
    
    441
    -  let home_unit = hsc_home_unit_maybe hsc_env
    
    427
    +  let home_unit = hsc_home_unit hsc_env
    
    442 428
       let other_fopts = initFinderOpts . homeUnitEnv_dflags <$> (hsc_HUG hsc_env)
    
    443 429
       findExactModuleNoHsc fc (initFinderOpts dflags) other_fopts unit_state home_unit mod is_boot
    
    444 430
     
    

  • compiler/GHC/Unit/Home.hs
    ... ... @@ -211,9 +211,8 @@ homeModuleNameInstantiation hu mod_name =
    211 211
     --       the instantiating module of @r:A@ in @p[A=q[]:B]@ is @r:A@.
    
    212 212
     --       the instantiating module of @p:A@ in @p@ is @p:A@.
    
    213 213
     --       the instantiating module of @r:A@ in @p@ is @r:A@.
    
    214
    -homeModuleInstantiation :: Maybe HomeUnit -> Module -> Module
    
    215
    -homeModuleInstantiation mhu mod
    
    216
    -   | Just hu <- mhu
    
    217
    -   , isHomeModule hu mod = homeModuleNameInstantiation hu (moduleName mod)
    
    214
    +homeModuleInstantiation :: HomeUnit -> Module -> Module
    
    215
    +homeModuleInstantiation hu mod
    
    216
    +   | isHomeModule hu mod = homeModuleNameInstantiation hu (moduleName mod)
    
    218 217
        | otherwise           = mod
    
    219 218
     

  • compiler/GHC/Unit/Home/Graph.hs
    ... ... @@ -150,11 +150,11 @@ data HomeUnitEnv = HomeUnitEnv
    150 150
         --
    
    151 151
         -- (This changes a previous invariant: changed Jan 05.)
    
    152 152
     
    
    153
    -  , homeUnitEnv_home_unit :: !(Maybe HomeUnit)
    
    153
    +  , homeUnitEnv_home_unit :: !HomeUnit
    
    154 154
         -- ^ Home-unit
    
    155 155
       }
    
    156 156
     
    
    157
    -mkHomeUnitEnv :: UnitState -> DynFlags -> HomePackageTable -> Maybe HomeUnit -> HomeUnitEnv
    
    157
    +mkHomeUnitEnv :: UnitState -> DynFlags -> HomePackageTable -> HomeUnit -> HomeUnitEnv
    
    158 158
     mkHomeUnitEnv us dflags hpt home_unit = HomeUnitEnv
    
    159 159
       { homeUnitEnv_units = us
    
    160 160
       , homeUnitEnv_dflags = dflags
    
    ... ... @@ -372,6 +372,6 @@ pprHomeUnitEnv :: UnitId -> HomeUnitEnv -> IO SDoc
    372 372
     pprHomeUnitEnv uid env = do
    
    373 373
       hptDoc <- pprHPT $ homeUnitEnv_hpt env
    
    374 374
       return $
    
    375
    -    ppr uid <+> text "(flags:" <+> ppr (homeUnitId_ $ homeUnitEnv_dflags env) <> text "," <+> ppr (fmap homeUnitId $ homeUnitEnv_home_unit env) <> text ")" <+> text "->"
    
    375
    +    ppr uid <+> text "(flags:" <+> ppr (homeUnitId_ $ homeUnitEnv_dflags env) <> text "," <+> ppr (homeUnitId $ homeUnitEnv_home_unit env) <> text ")" <+> text "->"
    
    376 376
         $$ nest 4 hptDoc
    
    377 377
     

  • ghc/GHCi/UI.hs
    ... ... @@ -859,7 +859,7 @@ installInteractiveHomeUnits dflags = do
    859 859
           (unit_state,home_unit,_mconstants) <-
    
    860 860
             liftIO $ initUnits logger dflags unit_index all_home_units
    
    861 861
           hpt <- liftIO emptyHomePackageTable
    
    862
    -      pure (HUG.mkHomeUnitEnv unit_state dflags hpt (Just home_unit))
    
    862
    +      pure (HUG.mkHomeUnitEnv unit_state dflags hpt home_unit)
    
    863 863
     
    
    864 864
         concatPackageDbStacksUsingLongestCommonPrefix :: [[PackageDBFlag]] -> [PackageDBFlag]
    
    865 865
         concatPackageDbStacksUsingLongestCommonPrefix stacks =