From 799690bea0dbcf427bf7a9a813fec163eedf217d Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 7 Dec 2011 13:12:05 -0800 Subject: [PATCH] Remove stmt_crate_directive, it's vestigial and confusing. --- src/comp/middle/alias.rs | 3 --- src/comp/middle/tstate/auxiliary.rs | 4 ---- src/comp/middle/ty.rs | 4 ---- src/comp/syntax/ast.rs | 3 --- src/comp/syntax/fold.rs | 5 +---- src/comp/syntax/parse/parser.rs | 19 +------------------ src/comp/syntax/visit.rs | 1 - 7 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index eb9122bfa7dc..909e90fd0c6d 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -154,9 +154,6 @@ fn visit_block(cx: @ctx, b: ast::blk, sc: scope, v: vt) { ast::stmt_expr(ex, _) { v.visit_expr(ex, sc, v); } - ast::stmt_crate_directive(cd) { - visit::visit_crate_directive(cd, sc, v); - } } } visit::visit_expr_opt(b.node.expr, sc, v); diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index b910dce220f7..315eac891471 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -319,10 +319,6 @@ fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { alt s.node { stmt_decl(_, id) { ret node_id_to_ts_ann(ccx, id); } stmt_expr(_, id) { ret node_id_to_ts_ann(ccx, id); } - stmt_crate_directive(_) { - log_err "expecting an annotated statement here"; - fail; - } } } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 9c2ddedc56b8..00699238b7f8 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1659,10 +1659,6 @@ fn stmt_node_id(s: @ast::stmt) -> ast::node_id { alt s.node { ast::stmt_decl(_, id) { ret id; } ast::stmt_expr(_, id) { ret id; } - ast::stmt_crate_directive(_) { - log_err "ty::stmt_node_id(): crate directive found"; - fail; - } } } diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index e0fd6617708a..a501d083aae5 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -145,9 +145,6 @@ type stmt = spanned; tag stmt_ { stmt_decl(@decl, node_id); stmt_expr(@expr, node_id); - - // These only exist in crate-level blocks. - stmt_crate_directive(@crate_directive); } tag init_op { init_assign; init_move; } diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index 4f26667800b9..0e76e9a15d16 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -258,10 +258,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { ret alt s { stmt_decl(d, nid) { stmt_decl(fld.fold_decl(d), nid) } stmt_expr(e, nid) { stmt_expr(fld.fold_expr(e), nid) } - stmt_crate_directive(cd) { - stmt_crate_directive(fld.fold_crate_directive(cd)) - } - }; + }; } fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 23ed2485f690..2bf7865bf81c 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1525,18 +1525,6 @@ fn parse_let(p: parser) -> @ast::decl { } fn parse_stmt(p: parser) -> @ast::stmt { - if p.get_file_type() == SOURCE_FILE { - ret parse_source_stmt(p); - } else { ret parse_crate_stmt(p); } -} - -fn parse_crate_stmt(p: parser) -> @ast::stmt { - let cdir = parse_crate_directive(p, []); - ret @spanned(cdir.span.lo, cdir.span.hi, - ast::stmt_crate_directive(@cdir)); -} - -fn parse_source_stmt(p: parser) -> @ast::stmt { let lo = p.get_lo_pos(); if eat_word(p, "let") { let decl = parse_let(p); @@ -1642,10 +1630,6 @@ fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { ast::stmt_expr(e, _) { ret expr_has_value(e); } - // We should not be calling this on a cdir. - ast::stmt_crate_directive(cdir) { - fail; - } } } @@ -1707,8 +1691,7 @@ fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk { // Not an expression statement. stmts += [stmt]; - if p.get_file_type() == SOURCE_FILE && - stmt_ends_with_semi(*stmt) { + if stmt_ends_with_semi(*stmt) { expect(p, token::SEMI); } } diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index a4052cec2a01..be4dbef294b3 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -196,7 +196,6 @@ fn visit_stmt(s: @stmt, e: E, v: vt) { alt s.node { stmt_decl(d, _) { v.visit_decl(d, e, v); } stmt_expr(ex, _) { v.visit_expr(ex, e, v); } - stmt_crate_directive(cd) { visit_crate_directive(cd, e, v); } } }