Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco
rustc: Remove local variable IDs from `Export`s Local variables can never be exported.
This commit is contained in:
commit
bb5ca58d29
19 changed files with 71 additions and 68 deletions
|
|
@ -482,12 +482,13 @@ fn build_module(
|
|||
// visit each node at most once.
|
||||
for &item in cx.tcx.item_children(did).iter() {
|
||||
if item.vis == ty::Visibility::Public {
|
||||
if let Some(def_id) = item.res.mod_def_id() {
|
||||
let res = item.res.expect_non_local();
|
||||
if let Some(def_id) = res.mod_def_id() {
|
||||
if did == def_id || !visited.insert(def_id) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Res::PrimTy(p) = item.res {
|
||||
if let Res::PrimTy(p) = res {
|
||||
// Primitive types can't be inlined so generate an import instead.
|
||||
let prim_ty = clean::PrimitiveType::from(p);
|
||||
items.push(clean::Item {
|
||||
|
|
@ -500,7 +501,7 @@ fn build_module(
|
|||
clean::ImportSource {
|
||||
path: clean::Path {
|
||||
global: false,
|
||||
res: item.res,
|
||||
res,
|
||||
segments: vec![clean::PathSegment {
|
||||
name: prim_ty.as_sym(),
|
||||
args: clean::GenericArgs::AngleBracketed {
|
||||
|
|
@ -515,9 +516,7 @@ fn build_module(
|
|||
))),
|
||||
cfg: None,
|
||||
});
|
||||
} else if let Some(i) =
|
||||
try_inline(cx, did, None, item.res, item.ident.name, None, visited)
|
||||
{
|
||||
} else if let Some(i) = try_inline(cx, did, None, res, item.ident.name, None, visited) {
|
||||
items.extend(i)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ impl ExternalCrate {
|
|||
crate fn keywords(&self, tcx: TyCtxt<'_>) -> ThinVec<(DefId, Symbol)> {
|
||||
let root = self.def_id();
|
||||
|
||||
let as_keyword = |res: Res| {
|
||||
let as_keyword = |res: Res<!>| {
|
||||
if let Res::Def(DefKind::Mod, def_id) = res {
|
||||
let attrs = tcx.get_attrs(def_id);
|
||||
let mut keyword = None;
|
||||
|
|
@ -243,7 +243,8 @@ impl ExternalCrate {
|
|||
hir::ItemKind::Use(ref path, hir::UseKind::Single)
|
||||
if item.vis.node.is_pub() =>
|
||||
{
|
||||
as_keyword(path.res).map(|(_, prim)| (id.def_id.to_def_id(), prim))
|
||||
as_keyword(path.res.expect_non_local())
|
||||
.map(|(_, prim)| (id.def_id.to_def_id(), prim))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -274,7 +275,7 @@ impl ExternalCrate {
|
|||
// Also note that this does not attempt to deal with modules tagged
|
||||
// duplicately for the same primitive. This is handled later on when
|
||||
// rendering by delegating everything to a hash map.
|
||||
let as_primitive = |res: Res| {
|
||||
let as_primitive = |res: Res<!>| {
|
||||
if let Res::Def(DefKind::Mod, def_id) = res {
|
||||
let attrs = tcx.get_attrs(def_id);
|
||||
let mut prim = None;
|
||||
|
|
@ -309,7 +310,7 @@ impl ExternalCrate {
|
|||
hir::ItemKind::Use(ref path, hir::UseKind::Single)
|
||||
if item.vis.node.is_pub() =>
|
||||
{
|
||||
as_primitive(path.res).map(|(_, prim)| {
|
||||
as_primitive(path.res.expect_non_local()).map(|(_, prim)| {
|
||||
// Pretend the primitive is local.
|
||||
(id.def_id.to_def_id(), prim)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, res: Res) {
|
||||
fn visit_item(&mut self, res: Res<!>) {
|
||||
let def_id = res.def_id();
|
||||
let vis = self.tcx.visibility(def_id);
|
||||
let inherited_item_level = if vis == Visibility::Public { self.prev_level } else { None };
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
|
|||
}
|
||||
};
|
||||
}
|
||||
fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<&'tcx Export<HirId>> {
|
||||
fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<&'tcx Export> {
|
||||
tcx.item_children(def_id)
|
||||
.iter()
|
||||
.find(|item| item.ident.name.as_str() == name)
|
||||
|
|
@ -557,7 +557,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
|
|||
None
|
||||
}
|
||||
});
|
||||
try_res!(last).res
|
||||
try_res!(last).res.expect_non_local()
|
||||
}
|
||||
|
||||
/// Convenience function to get the `DefId` of a trait by path.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue