Well, the only bit of the DefId that is used here is its NodeId, on the next line, so instead I just invoke this function with def_id.node as the argument (in csearch).