From a235508f0cfd7c99a21b170bdc9914f8888d340a Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 31 Jul 2015 22:20:25 -0700 Subject: [PATCH] rustc: rename multiple imports in a list --- clean/mod.rs | 9 ++++++--- html/format.rs | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/clean/mod.rs b/clean/mod.rs index 11a0e0e..6431e68 100644 --- a/clean/mod.rs +++ b/clean/mod.rs @@ -2362,7 +2362,7 @@ impl Clean> for doctree::Import { let remaining = if !denied { let mut remaining = vec![]; for path in list { - match inline::try_inline(cx, path.node.id(), None) { + match inline::try_inline(cx, path.node.id(), path.node.rename()) { Some(items) => { ret.extend(items); } @@ -2424,18 +2424,21 @@ pub struct ImportSource { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct ViewListIdent { pub name: String, + pub rename: Option, pub source: Option, } impl Clean for ast::PathListItem { fn clean(&self, cx: &DocContext) -> ViewListIdent { match self.node { - ast::PathListIdent { id, name } => ViewListIdent { + ast::PathListIdent { id, name, rename } => ViewListIdent { name: name.clean(cx), + rename: rename.map(|r| r.clean(cx)), source: resolve_def(cx, id) }, - ast::PathListMod { id } => ViewListIdent { + ast::PathListMod { id, rename } => ViewListIdent { name: "self".to_string(), + rename: rename.map(|r| r.clean(cx)), source: resolve_def(cx, id) } } diff --git a/html/format.rs b/html/format.rs index 2255a2e..7d86a54 100644 --- a/html/format.rs +++ b/html/format.rs @@ -687,10 +687,15 @@ impl fmt::Display for clean::ViewListIdent { match self.source { Some(did) => { let path = clean::Path::singleton(self.name.clone()); - resolved_path(f, did, &path, false) + try!(resolved_path(f, did, &path, false)); } - _ => write!(f, "{}", self.name), + _ => try!(write!(f, "{}", self.name)), + } + + if let Some(ref name) = self.rename { + try!(write!(f, " as {}", name)); } + Ok(()) } }