Make the expanded expression in expr_ext not optional
This commit is contained in:
parent
7cef1b3a0f
commit
c1e6f5328c
5 changed files with 9 additions and 11 deletions
|
@ -185,7 +185,7 @@ tag expr_ {
|
|||
expr_field(@expr, ident, ann);
|
||||
expr_index(@expr, @expr, ann);
|
||||
expr_path(path, option.t[def], ann);
|
||||
expr_ext(path, vec[@expr], option.t[@expr], option.t[@expr], ann);
|
||||
expr_ext(path, vec[@expr], option.t[@expr], @expr, ann);
|
||||
expr_fail;
|
||||
expr_ret(option.t[@expr]);
|
||||
expr_put(option.t[@expr]);
|
||||
|
|
|
@ -755,7 +755,7 @@ impure fn expand_syntax_ext(parser p, ast.span sp,
|
|||
if (_str.eq(extname, "fmt")) {
|
||||
auto expanded = extfmt.expand_syntax_ext(args, body);
|
||||
auto newexpr = ast.expr_ext(path, args, body,
|
||||
some[@ast.expr](expanded),
|
||||
expanded,
|
||||
ast.ann_none);
|
||||
|
||||
ret newexpr;
|
||||
|
|
|
@ -157,7 +157,7 @@ type ast_fold[ENV] =
|
|||
(fn(&ENV e, &span sp,
|
||||
&path p, vec[@expr] args,
|
||||
option.t[@expr] body,
|
||||
option.t[@expr] expanded,
|
||||
@expr expanded,
|
||||
ann a) -> @expr) fold_expr_ext,
|
||||
|
||||
(fn(&ENV e, &span sp) -> @expr) fold_expr_fail,
|
||||
|
@ -653,10 +653,9 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
|
|||
case (ast.expr_ext(?p, ?args, ?body, ?expanded, ?t)) {
|
||||
// Only fold the expanded expression, not the
|
||||
// expressions involved in syntax extension
|
||||
auto exp = option.get[@expr](expanded);
|
||||
auto exp_ = fold_expr(env_, fld, exp);
|
||||
auto exp = fold_expr(env_, fld, expanded);
|
||||
ret fld.fold_expr_ext(env_, e.span, p, args, body,
|
||||
some[@ast.expr](exp_), t);
|
||||
exp, t);
|
||||
}
|
||||
|
||||
case (ast.expr_fail) {
|
||||
|
@ -1184,7 +1183,7 @@ fn identity_fold_expr_path[ENV](&ENV env, &span sp,
|
|||
fn identity_fold_expr_ext[ENV](&ENV env, &span sp,
|
||||
&path p, vec[@expr] args,
|
||||
option.t[@expr] body,
|
||||
option.t[@expr] expanded,
|
||||
@expr expanded,
|
||||
ann a) -> @expr {
|
||||
ret @respan(sp, ast.expr_ext(p, args, body, expanded, a));
|
||||
}
|
||||
|
|
|
@ -3694,7 +3694,7 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
|
|||
}
|
||||
|
||||
case (ast.expr_ext(_, _, _, ?expanded, _)) {
|
||||
ret trans_expr(cx, option.get[@ast.expr](expanded));
|
||||
ret trans_expr(cx, expanded);
|
||||
}
|
||||
|
||||
case (ast.expr_fail) {
|
||||
|
|
|
@ -1514,11 +1514,10 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
}
|
||||
|
||||
case (ast.expr_ext(?p, ?args, ?body, ?expanded, _)) {
|
||||
auto exp_ = check_expr(fcx, option.get[@ast.expr](expanded));
|
||||
auto exp_ = check_expr(fcx, expanded);
|
||||
auto t = expr_ty(exp_);
|
||||
ret @fold.respan[ast.expr_](expr.span,
|
||||
ast.expr_ext(p, args, body,
|
||||
some[@ast.expr](exp_),
|
||||
ast.expr_ext(p, args, body, exp_,
|
||||
ast.ann_type(t)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue