Skip to content

Commit

Permalink
Add a macro invocation to the type AST
Browse files Browse the repository at this point in the history
  • Loading branch information
jroesch committed Aug 4, 2015
1 parent 6afb8f5 commit ad59278
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -1662,6 +1662,9 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
// handled specially and will not descend into this routine.
this.ty_infer(None, None, None, ast_ty.span)
}
ast::TyMac(_) => {
tcx.sess.span_bug(m.span, "unexpanded type macro found conversion")
}
};

tcx.ast_ty_to_ty_cache.borrow_mut().insert(ast_ty.id, typ);
Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -1611,6 +1611,9 @@ impl Clean<Type> for ast::Ty {
TyTypeof(..) => {
panic!("Unimplemented type {:?}", self.node)
},
TyMac(..) => {
cx.tcx().sess.span_bug(m.span, "unexpanded type macro found during cleaning")
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/ast.rs
Expand Up @@ -1471,6 +1471,8 @@ pub enum Ty_ {
/// TyInfer means the type should be inferred instead of it having been
/// specified. This can appear anywhere in a type.
TyInfer,
// A macro in the type position.
TyMac(Mac)
}

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/fold.rs
Expand Up @@ -429,6 +429,9 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
TyPolyTraitRef(bounds) => {
TyPolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
}
TyMac(mac) => {
TyMac(fld.fold_mac(mac))
}
},
span: fld.new_span(span)
})
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/print/pprust.rs
Expand Up @@ -734,6 +734,9 @@ impl<'a> State<'a> {
ast::TyInfer => {
try!(word(&mut self.s, "_"));
}
ast::TyMac(ref m) => {
try!(self.print_mac(m, token::Paren));
}
}
self.end()
}
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/visit.rs
Expand Up @@ -405,6 +405,9 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
visitor.visit_expr(&**expression)
}
TyInfer => {}
TyMac(ref mac) => {
visitor.visit_mac(mac)
}
}
}

Expand Down

0 comments on commit ad59278

Please sign in to comment.