Skip to content

Commit ad59278

Browse files
committed
Add a macro invocation to the type AST
Reapplied the changes from https://github.com/freebroccolo/rust/commit/dc64b731d7f66c2b43d5e5e8c721be7bd3b59540 to a clean branch of master
1 parent 6afb8f5 commit ad59278

File tree

6 files changed

+17
-0
lines changed

6 files changed

+17
-0
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,9 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
16621662
// handled specially and will not descend into this routine.
16631663
this.ty_infer(None, None, None, ast_ty.span)
16641664
}
1665+
ast::TyMac(_) => {
1666+
tcx.sess.span_bug(m.span, "unexpanded type macro found conversion")
1667+
}
16651668
};
16661669

16671670
tcx.ast_ty_to_ty_cache.borrow_mut().insert(ast_ty.id, typ);

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,9 @@ impl Clean<Type> for ast::Ty {
16111611
TyTypeof(..) => {
16121612
panic!("Unimplemented type {:?}", self.node)
16131613
},
1614+
TyMac(..) => {
1615+
cx.tcx().sess.span_bug(m.span, "unexpanded type macro found during cleaning")
1616+
}
16141617
}
16151618
}
16161619
}

src/libsyntax/ast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,8 @@ pub enum Ty_ {
14711471
/// TyInfer means the type should be inferred instead of it having been
14721472
/// specified. This can appear anywhere in a type.
14731473
TyInfer,
1474+
// A macro in the type position.
1475+
TyMac(Mac)
14741476
}
14751477

14761478
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]

src/libsyntax/fold.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
429429
TyPolyTraitRef(bounds) => {
430430
TyPolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
431431
}
432+
TyMac(mac) => {
433+
TyMac(fld.fold_mac(mac))
434+
}
432435
},
433436
span: fld.new_span(span)
434437
})

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,9 @@ impl<'a> State<'a> {
734734
ast::TyInfer => {
735735
try!(word(&mut self.s, "_"));
736736
}
737+
ast::TyMac(ref m) => {
738+
try!(self.print_mac(m, token::Paren));
739+
}
737740
}
738741
self.end()
739742
}

src/libsyntax/visit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
405405
visitor.visit_expr(&**expression)
406406
}
407407
TyInfer => {}
408+
TyMac(ref mac) => {
409+
visitor.visit_mac(mac)
410+
}
408411
}
409412
}
410413

0 commit comments

Comments
 (0)