use super::write_shared::write_shared;
use super::{print_sidebar, settings, AllTypes, NameDoc, StylePath, BASIC_KEYWORDS};
-use crate::clean::{self, AttributesExt};
+use crate::clean::{self, ExternalCrate};
use crate::config::RenderOptions;
use crate::docfs::{DocFS, PathError};
use crate::error::Error;
/// may happen, for example, with externally inlined items where the source
/// of their crate documentation isn't known.
pub(super) fn src_href(&self, item: &clean::Item) -> Option<String> {
- if item.span.is_dummy() {
+ if item.span(self.tcx()).is_dummy() {
return None;
}
let mut root = self.root_path();
let mut path = String::new();
- let cnum = item.span.cnum(self.sess());
+ let cnum = item.span(self.tcx()).cnum(self.sess());
// We can safely ignore synthetic `SourceFile`s.
- let file = match item.span.filename(self.sess()) {
- FileName::Real(ref path) => path.local_path().to_path_buf(),
+ let file = match item.span(self.tcx()).filename(self.sess()) {
+ FileName::Real(ref path) => path.local_path_if_available().to_path_buf(),
_ => return None,
};
let file = &file;
}
} else {
let (krate, src_root) = match *self.cache.extern_locations.get(&cnum)? {
- (name, ref src, ExternalLocation::Local) => (name, src),
- (name, ref src, ExternalLocation::Remote(ref s)) => {
+ ExternalLocation::Local => {
+ let e = ExternalCrate { crate_num: cnum };
+ (e.name(self.tcx()), e.src_root(self.tcx()))
+ }
+ ExternalLocation::Remote(ref s) => {
root = s.to_string();
- (name, src)
+ let e = ExternalCrate { crate_num: cnum };
+ (e.name(self.tcx()), e.src_root(self.tcx()))
}
- (_, _, ExternalLocation::Unknown) => return None,
+ ExternalLocation::Unknown => return None,
};
sources::clean_path(&src_root, file, false, |component| {
(&*symbol, &path)
};
- let loline = item.span.lo(self.sess()).line;
- let hiline = item.span.hi(self.sess()).line;
+ let loline = item.span(self.tcx()).lo(self.sess()).line;
+ let hiline = item.span(self.tcx()).hi(self.sess()).line;
let lines =
if loline == hiline { loline.to_string() } else { format!("{}-{}", loline, hiline) };
Some(format!(
} = options;
let src_root = match krate.src {
- FileName::Real(ref p) => match p.local_path().parent() {
+ FileName::Real(ref p) => match p.local_path_if_available().parent() {
Some(p) => p.to_path_buf(),
None => PathBuf::new(),
},