Correctly handle super
and ::
This commit is contained in:
parent
6b56e8e1cf
commit
9fb6548905
3 changed files with 33 additions and 1 deletions
|
@ -1514,9 +1514,18 @@ fn first_non_private(
|
|||
(cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident)
|
||||
}
|
||||
// Crate paths are not. We start from the crate root.
|
||||
[parent, leaf] if parent.ident.name == kw::Crate => {
|
||||
[parent, leaf] if matches!(parent.ident.name, kw::Crate | kw::PathRoot) => {
|
||||
(LOCAL_CRATE.as_def_id().as_local()?, leaf.ident)
|
||||
}
|
||||
[parent, leaf] if parent.ident.name == kw::Super => {
|
||||
let parent_mod = cx.tcx.parent_module(hir_id);
|
||||
if let Some(super_parent) = cx.tcx.opt_local_parent(parent_mod) {
|
||||
(super_parent, leaf.ident)
|
||||
} else {
|
||||
// If we can't find the parent of the parent, then the parent is already the crate.
|
||||
(LOCAL_CRATE.as_def_id().as_local()?, leaf.ident)
|
||||
}
|
||||
}
|
||||
// Absolute paths are not. We start from the parent of the item.
|
||||
[.., parent, leaf] => (parent.res.opt_def_id()?.as_local()?, leaf.ident),
|
||||
};
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// edition:2015
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
use external::Public as Private;
|
||||
|
||||
pub mod external {
|
||||
pub struct Public;
|
||||
|
||||
// @has 'foo/external/fn.make.html'
|
||||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public'
|
||||
pub fn make() -> ::Private { super::Private }
|
||||
}
|
|
@ -112,3 +112,13 @@ pub fn bar14() -> nested::nested2::Whatever3 {
|
|||
pub fn bar15() -> nested::nested2::Whatever4 {
|
||||
Whatever
|
||||
}
|
||||
|
||||
use external::Public as Private;
|
||||
|
||||
pub mod external {
|
||||
pub struct Public;
|
||||
|
||||
// @has 'foo/external/fn.make.html'
|
||||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public'
|
||||
pub fn make() -> super::Private { super::Private }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue