diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index c120535d1d01..3e10233d5929 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -88,8 +88,6 @@ type crate_ = rec(vec[@crate_directive] directives, crate_cfg config); tag crate_directive_ { - cdir_expr(@expr); - // FIXME: cdir_let should be eliminated // and redirected to the use of const stmt_decls inside // crate directive blocks. diff --git a/src/comp/front/eval.rs b/src/comp/front/eval.rs index df7949923116..92e03e129d04 100644 --- a/src/comp/front/eval.rs +++ b/src/comp/front/eval.rs @@ -196,63 +196,6 @@ fn eval_crate_directive_block(ctx cx, &ast::block blk, str prefix, } } -fn eval_crate_directive_expr(ctx cx, @ast::expr x, str prefix, - &mutable vec[@ast::view_item] view_items, - &mutable vec[@ast::item] items) { - alt (x.node) { - case (ast::expr_if(?cond, ?thn, ?elopt)) { - auto cv = eval_expr(cx, cond); - if (!val_is_bool(cv)) { - cx.sess.span_fatal(x.span, "bad cond type in 'if'"); - } - if (val_as_bool(cv)) { - ret eval_crate_directive_block(cx, thn, prefix, view_items, - items); - } - alt (elopt) { - case (some(?els)) { - ret eval_crate_directive_expr(cx, els, prefix, - view_items, items); - } - case (_) { - // Absent-else is ok. - - } - } - } - case (ast::expr_alt(?v, ?arms)) { - auto vv = eval_expr(cx, v); - for (ast::arm arm in arms) { - alt (arm.pat.node) { - case (ast::pat_lit(?lit, _)) { - auto pv = eval_lit(cx, arm.pat.span, lit); - if (val_eq(cx.sess, arm.pat.span, vv, pv)) { - ret eval_crate_directive_block(cx, arm.block, - prefix, view_items, - items); - } - } - case (ast::pat_wild(_)) { - ret eval_crate_directive_block(cx, arm.block, - prefix, view_items, - items); - } - case (_) { - cx.sess.span_fatal(arm.pat.span, - "bad pattern type in 'alt'"); - } - } - } - cx.sess.span_fatal(x.span, "no cases matched in 'alt'"); - } - case (ast::expr_block(?block)) { - ret eval_crate_directive_block(cx, block, prefix, view_items, - items); - } - case (_) { cx.sess.span_fatal(x.span, "unsupported expr type"); } - } -} - fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix, &mutable vec[@ast::view_item] view_items, &mutable vec[@ast::item] items) { @@ -261,9 +204,6 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix, auto v = eval_expr(cx, x); eval_crate_directives(cx, cdirs, prefix, view_items, items); } - case (ast::cdir_expr(?x)) { - eval_crate_directive_expr(cx, x, prefix, view_items, items); - } case (ast::cdir_src_mod(?id, ?file_opt, ?attrs)) { auto file_path = id + ".rs"; alt (file_opt) { diff --git a/src/comp/front/fold.rs b/src/comp/front/fold.rs index 340793b9f237..57f6d5ad16a6 100644 --- a/src/comp/front/fold.rs +++ b/src/comp/front/fold.rs @@ -139,7 +139,6 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ { fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld) -> crate_directive_ { ret alt(cd) { - case(cdir_expr(?e)) { cdir_expr(fld.fold_expr(e)) } case(cdir_let(?id, ?e, ?cds)) { cdir_let(fld.fold_ident(id), fld.fold_expr(e), map(fld.fold_crate_directive, cds)) diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 0d86d5d949ed..d574122b36f6 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -2412,10 +2412,8 @@ fn parse_crate_directive(&parser p, vec[ast::attribute] first_outer_attr) auto vi = parse_view_item(p); ret spanned(lo, vi.span.hi, ast::cdir_view_item(vi)); } else { - auto x = parse_expr(p); - ret spanned(lo, x.span.hi, ast::cdir_expr(x)); + ret p.fatal("expected crate directive"); } - fail; } fn parse_crate_directives(&parser p, token::token term,