use std::io::{self, BufWriter, BufReader};
use std::iter::repeat;
use std::mem;
-use std::path::{PathBuf, Path};
+use std::path::{PathBuf, Path, Component};
use std::str;
use std::sync::Arc;
stack: Vec<String>,
parent_stack: Vec<DefId>,
+ parent_is_trait_impl: bool,
search_index: Vec<IndexItem>,
privmod: bool,
remove_priv: bool,
stack: Vec::new(),
parent_stack: Vec::new(),
search_index: Vec::new(),
+ parent_is_trait_impl: false,
extern_locations: HashMap::new(),
primitive_locations: HashMap::new(),
remove_priv: cx.passes.contains("strip-private"),
// make it relative, if possible
let p = p.strip_prefix(src_root).unwrap_or(p);
- let mut iter = p.iter().map(|x| x.to_str().unwrap()).peekable();
+ let mut iter = p.components().peekable();
+
while let Some(c) = iter.next() {
if !keep_filename && iter.peek().is_none() {
break;
}
- if ".." == c {
- f("up");
- } else {
- f(c)
+ match c {
+ Component::ParentDir => f("up"),
+ Component::Normal(c) => f(c.to_str().unwrap()),
+ _ => continue,
}
}
}
// entire crate. The other option is maintaining this mapping on a
// per-file basis, but that's probably not worth it...
self.cx
- .include_sources = match self.emit_source(&item.source .filename) {
+ .include_sources = match self.emit_source(&item.source.filename) {
Ok(()) => true,
Err(e) => {
println!("warning: source code was requested to be rendered, \
// Index this method for searching later on
if let Some(ref s) = item.name {
let (parent, is_method) = match item.inner {
+ clean::AssociatedConstItem(..) |
+ clean::TypedefItem(_, true) if self.parent_is_trait_impl => {
+ // skip associated items in trait impls
+ ((None, None), false)
+ }
clean::AssociatedTypeItem(..) |
clean::AssociatedConstItem(..) |
clean::TyMethodItem(..) |
((Some(*last), path), true)
}
}
- clean::TypedefItem(_, true) => {
- // skip associated types in impls
- ((None, None), false)
- }
_ => ((None, Some(&*self.stack)), false)
};
let hidden_field = match item.inner {
}
// Maintain the parent stack
+ let orig_parent_is_trait_impl = self.parent_is_trait_impl;
let parent_pushed = match item.inner {
clean::TraitItem(..) | clean::EnumItem(..) | clean::StructItem(..) => {
self.parent_stack.push(item.def_id);
+ self.parent_is_trait_impl = false;
true
}
clean::ImplItem(ref i) => {
+ self.parent_is_trait_impl = i.trait_.is_some();
match i.for_ {
clean::ResolvedPath{ did, .. } => {
self.parent_stack.push(did);
if pushed { self.stack.pop().unwrap(); }
if parent_pushed { self.parent_stack.pop().unwrap(); }
self.privmod = orig_privmod;
+ self.parent_is_trait_impl = orig_parent_is_trait_impl;
return ret;
}
}
true, |component| {
path.push(component.to_string());
});
+
// If the span points into an external macro the
// source-file will be bogus, i.e `<foo macros>`
- if Path::new(&self.item.source.filename).is_file() {
+ let filename = &self.item.source.filename;
+ if !(filename.starts_with("<") && filename.ends_with("macros>")) {
Some(format!("{root}src/{krate}/{path}.html#{href}",
root = self.cx.root_path,
krate = self.cx.layout.krate,
fn get_index_search_type(item: &clean::Item,
parent: Option<String>) -> Option<IndexItemFunctionType> {
- let decl = match item.inner {
- clean::FunctionItem(ref f) => &f.decl,
- clean::MethodItem(ref m) => &m.decl,
- clean::TyMethodItem(ref m) => &m.decl,
+ let (decl, selfty) = match item.inner {
+ clean::FunctionItem(ref f) => (&f.decl, None),
+ clean::MethodItem(ref m) => (&m.decl, Some(&m.self_)),
+ clean::TyMethodItem(ref m) => (&m.decl, Some(&m.self_)),
_ => return None
};
let mut inputs = Vec::new();
// Consider `self` an argument as well.
- if let Some(name) = parent {
- inputs.push(Type { name: Some(name.to_ascii_lowercase()) });
+ match parent.and_then(|p| selfty.map(|s| (p, s)) ) {
+ Some((_, &clean::SelfStatic)) | None => (),
+ Some((name, _)) => inputs.push(Type { name: Some(name.to_ascii_lowercase()) }),
}
inputs.extend(&mut decl.inputs.values.iter().map(|arg| {