diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index c434087dd2b..2f096346c9b 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -85,6 +85,7 @@ fn try_inline_def(cx: &core::DocContext, _ => return None, }; let fqn = csearch::get_item_path(tcx, did); + cx.inlined.borrow_mut().get_mut_ref().insert(did); ret.push(clean::Item { source: clean::Span::empty(), name: Some(fqn.last().unwrap().to_str().to_string()), diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7bc4693215a..27e39e1235c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -41,6 +41,7 @@ pub struct DocContext { pub external_paths: ExternalPaths, pub external_traits: RefCell>>, pub external_typarams: RefCell>>, + pub inlined: RefCell>>, } impl DocContext { @@ -58,6 +59,7 @@ pub struct CrateAnalysis { pub external_paths: ExternalPaths, pub external_traits: RefCell>>, pub external_typarams: RefCell>>, + pub inlined: RefCell>>, } /// Parses, resolves, and typechecks the given crate @@ -111,12 +113,14 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet, cfgs: Vec) external_traits: RefCell::new(Some(HashMap::new())), external_typarams: RefCell::new(Some(HashMap::new())), external_paths: RefCell::new(Some(HashMap::new())), + inlined: RefCell::new(Some(HashSet::new())), }, CrateAnalysis { exported_items: exported_items, public_items: public_items, external_paths: RefCell::new(None), external_traits: RefCell::new(None), external_typarams: RefCell::new(None), + inlined: RefCell::new(None), }) } @@ -138,5 +142,7 @@ pub fn run_core(libs: HashSet, cfgs: Vec, path: &Path) *analysis.external_traits.borrow_mut() = map; let map = ctxt.external_typarams.borrow_mut().take(); *analysis.external_typarams.borrow_mut() = map; + let map = ctxt.inlined.borrow_mut().take(); + *analysis.inlined.borrow_mut() = map; (krate, analysis) } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index c1b5b8af07a..e3221177afe 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -150,7 +150,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path, print_all: bool) -> fmt::Result { path(w, p, print_all, |cache, loc| { - if ast_util::is_local(did) || cache.paths.contains_key(&did) { + if ast_util::is_local(did) || cache.inlined.contains(&did) { Some(("../".repeat(loc.len())).to_string()) } else { match *cache.extern_locations.get(&did.krate) { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index a23aefe03e8..f5c7352b9c2 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -159,6 +159,9 @@ pub struct Cache { /// Cache of where external crate documentation can be found. pub extern_locations: HashMap, + /// Set of definitions which have been inlined from external crates. + pub inlined: HashSet, + // Private fields only used when initially crawling a crate to build a cache stack: Vec, @@ -287,6 +290,9 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> { typarams: analysis.as_ref().map(|a| { a.external_typarams.borrow_mut().take_unwrap() }).unwrap_or(HashMap::new()), + inlined: analysis.as_ref().map(|a| { + a.inlined.borrow_mut().take_unwrap() + }).unwrap_or(HashSet::new()), }; cache.stack.push(krate.name.clone()); krate = cache.fold_crate(krate); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 4023010537e..a7abbe0360f 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -78,6 +78,7 @@ pub fn run(input: &str, external_paths: RefCell::new(Some(HashMap::new())), external_traits: RefCell::new(None), external_typarams: RefCell::new(None), + inlined: RefCell::new(None), }; super::ctxtkey.replace(Some(ctx));