+ (id, rhs) = expectJust (showSDoc (text "chooseExternalIds: " <>
+ ppr idocc)) $
+ lookupVarEnv bind_env idocc
+ -- NB. idocc might be an *occurrence* of an Id, whereas we want
+ -- the Id from the binding site, because only the latter is
+ -- guaranteed to have the unfolding attached. This is why we
+ -- keep binding site Ids in the bind_env.