Add AST node for pattern macros
This commit is contained in:
parent
28a4ee5eeb
commit
5fdd0e4b05
@ -142,6 +142,10 @@ impl<'a> CFGBuilder<'a> {
|
||||
self.pats_all(post.iter().map(|p| *p), vec_exit);
|
||||
self.add_node(pat.id, [post_exit])
|
||||
}
|
||||
|
||||
ast::PatMac(_) => {
|
||||
self.tcx.sess.span_bug(pat.span, "unexpanded macro");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,6 +392,7 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
|
||||
None => Some(vec(before.len() + after.len()))
|
||||
}
|
||||
}
|
||||
PatMac(_) => cx.tcx.sess.bug("unexpanded macro"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -849,6 +850,10 @@ fn specialize(cx: &MatchCheckCtxt,
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
PatMac(_) => {
|
||||
cx.tcx.sess.span_err(pat_span, "unexpanded macro");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -947,6 +952,7 @@ fn find_refutable(cx: &MatchCheckCtxt, pat: &Pat, spans: &mut Vec<Span>) {
|
||||
}
|
||||
PatEnum(_,_) => {}
|
||||
PatVec(..) => { this_pattern!() }
|
||||
PatMac(_) => cx.tcx.sess.bug("unexpanded macro"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1088,6 +1088,10 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
|
||||
ast::PatLit(_) | ast::PatRange(_, _) => {
|
||||
/*always ok*/
|
||||
}
|
||||
|
||||
ast::PatMac(_) => {
|
||||
self.tcx().sess.span_bug(pat.span, "unexpanded macro");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -2282,6 +2282,9 @@ fn bind_irrefutable_pat<'a>(
|
||||
bcx.sess().span_bug(pat.span,
|
||||
"vector patterns are never irrefutable!");
|
||||
}
|
||||
ast::PatMac(..) => {
|
||||
bcx.sess().span_bug(pat.span, "unexpanded macro");
|
||||
}
|
||||
ast::PatWild | ast::PatWildMulti | ast::PatLit(_) | ast::PatRange(_, _) => ()
|
||||
}
|
||||
return bcx;
|
||||
|
@ -2664,6 +2664,11 @@ fn populate_scope_map(cx: &CrateContext,
|
||||
walk_pattern(cx, sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
ast::PatMac(_) => {
|
||||
cx.sess().span_bug(pat.span, "debuginfo::populate_scope_map() - \
|
||||
Found unexpanded macro.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,6 +722,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
||||
}
|
||||
fcx.write_ty(pat.id, expected);
|
||||
}
|
||||
|
||||
ast::PatMac(_) => tcx.sess.bug("unexpanded macro"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1731,7 +1731,12 @@ fn name_from_pat(p: &ast::Pat) -> String {
|
||||
PatRange(..) => fail!("tried to get argument name from PatRange, \
|
||||
which is not allowed in function arguments"),
|
||||
PatVec(..) => fail!("tried to get argument name from pat_vec, \
|
||||
which is not allowed in function arguments")
|
||||
which is not allowed in function arguments"),
|
||||
PatMac(..) => {
|
||||
warn!("can't document the name of a function argument \
|
||||
produced by a pattern macro");
|
||||
"(argument produced by macro)".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,8 @@ pub enum Pat_ {
|
||||
PatRange(@Expr, @Expr),
|
||||
// [a, b, ..i, y, z] is represented as
|
||||
// PatVec(~[a, b], Some(i), ~[y, z])
|
||||
PatVec(Vec<@Pat> , Option<@Pat>, Vec<@Pat> )
|
||||
PatVec(Vec<@Pat> , Option<@Pat>, Vec<@Pat> ),
|
||||
PatMac(Mac),
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash, Show)]
|
||||
|
@ -665,6 +665,7 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool {
|
||||
slice.iter().advance(|&p| walk_pat(p, |p| it(p))) &&
|
||||
after.iter().advance(|&p| walk_pat(p, |p| it(p)))
|
||||
}
|
||||
PatMac(_) => fail!("attempted to analyze unexpanded pattern"),
|
||||
PatWild | PatWildMulti | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |
|
||||
PatEnum(_, _) => {
|
||||
true
|
||||
|
@ -770,6 +770,7 @@ pub fn noop_fold_pat<T: Folder>(p: @Pat, folder: &mut T) -> @Pat {
|
||||
slice.map(|x| folder.fold_pat(x)),
|
||||
after.iter().map(|x| folder.fold_pat(*x)).collect())
|
||||
}
|
||||
PatMac(ref mac) => PatMac(folder.fold_mac(mac)),
|
||||
};
|
||||
|
||||
@Pat {
|
||||
|
@ -1757,6 +1757,7 @@ impl<'a> State<'a> {
|
||||
|s, &p| s.print_pat(p)));
|
||||
try!(word(&mut self.s, "]"));
|
||||
}
|
||||
ast::PatMac(ref m) => try!(self.print_mac(m)),
|
||||
}
|
||||
self.ann.post(self, NodePat(pat))
|
||||
}
|
||||
|
@ -457,6 +457,7 @@ pub fn walk_pat<E: Clone, V: Visitor<E>>(visitor: &mut V, pattern: &Pat, env: E)
|
||||
visitor.visit_pat(*postpattern, env.clone())
|
||||
}
|
||||
}
|
||||
PatMac(ref macro) => visitor.visit_mac(macro, env),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user