///
/// The returned value is `None` if the `id` could not be inlined, and `Some`
/// of a vector of items if it was successfully expanded.
-pub fn try_inline(id: ast::NodeId) -> Option<Vec<clean::Item>> {
+pub fn try_inline(id: ast::NodeId, into: Option<ast::Ident>)
+ -> Option<Vec<clean::Item>> {
let cx = ::ctxtkey.get().unwrap();
let tcx = match cx.maybe_typed {
core::Typed(ref tycx) => tycx,
};
let did = def.def_id();
if ast_util::is_local(did) { return None }
- try_inline_def(&**cx, tcx, def)
+ try_inline_def(&**cx, tcx, def).map(|vec| {
+ vec.move_iter().map(|mut item| {
+ match into {
+ Some(into) if item.name.is_some() => {
+ item.name = Some(into.clean());
+ }
+ _ => {}
+ }
+ item
+ }).collect()
+ })
}
fn try_inline_def(cx: &core::DocContext,
// to keep any non-inlineable reexports so they can be
// listed in the documentation.
let remaining = list.iter().filter(|path| {
- match inline::try_inline(path.node.id()) {
+ match inline::try_inline(path.node.id(), None) {
Some(items) => {
ret.extend(items.move_iter()); false
}
ret.push(convert(&ast::ViewItemUse(box(GC) path)));
}
}
- ast::ViewPathSimple(_, _, id) => {
- match inline::try_inline(id) {
+ ast::ViewPathSimple(ident, _, id) => {
+ match inline::try_inline(id, Some(ident)) {
Some(items) => ret.extend(items.move_iter()),
None => ret.push(convert(&self.node)),
}
om: &mut Module,
please_inline: bool) -> Option<Gc<ast::ViewPath>> {
match path.node {
- ast::ViewPathSimple(_, _, id) => {
- if self.resolve_id(id, false, om, please_inline) { return None }
+ ast::ViewPathSimple(dst, _, id) => {
+ if self.resolve_id(id, Some(dst), false, om, please_inline) {
+ return None
+ }
}
ast::ViewPathList(ref p, ref paths, ref b) => {
let mut mine = Vec::new();
for path in paths.iter() {
- if !self.resolve_id(path.node.id(), false, om, please_inline) {
+ if !self.resolve_id(path.node.id(), None, false, om,
+ please_inline) {
mine.push(path.clone());
}
}
// these are feature gated anyway
ast::ViewPathGlob(_, id) => {
- if self.resolve_id(id, true, om, please_inline) { return None }
+ if self.resolve_id(id, None, true, om, please_inline) {
+ return None
+ }
}
}
return Some(path);
}
- fn resolve_id(&mut self, id: ast::NodeId, glob: bool,
- om: &mut Module, please_inline: bool) -> bool {
+ fn resolve_id(&mut self, id: ast::NodeId, renamed: Option<ast::Ident>,
+ glob: bool, om: &mut Module, please_inline: bool) -> bool {
let tcx = match self.cx.maybe_typed {
core::Typed(ref tcx) => tcx,
core::NotTyped(_) => return false
match tcx.map.get(def.node) {
ast_map::NodeItem(it) => {
+ let it = match renamed {
+ Some(ident) => {
+ box(GC) ast::Item {
+ ident: ident,
+ ..(*it).clone()
+ }
+ }
+ None => it,
+ };
if glob {
match it.node {
ast::ItemMod(ref m) => {