Skip to content

Commit d8fe0d7

Browse files
committed
Remove the concept of crate directive expressions. Issue #604
1 parent bca4572 commit d8fe0d7

File tree

4 files changed

+1
-66
lines changed

4 files changed

+1
-66
lines changed

src/comp/front/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ type crate_ = rec(vec[@crate_directive] directives,
8888
crate_cfg config);
8989

9090
tag crate_directive_ {
91-
cdir_expr(@expr);
92-
9391
// FIXME: cdir_let should be eliminated
9492
// and redirected to the use of const stmt_decls inside
9593
// crate directive blocks.

src/comp/front/eval.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -196,63 +196,6 @@ fn eval_crate_directive_block(ctx cx, &ast::block blk, str prefix,
196196
}
197197
}
198198

199-
fn eval_crate_directive_expr(ctx cx, @ast::expr x, str prefix,
200-
&mutable vec[@ast::view_item] view_items,
201-
&mutable vec[@ast::item] items) {
202-
alt (x.node) {
203-
case (ast::expr_if(?cond, ?thn, ?elopt)) {
204-
auto cv = eval_expr(cx, cond);
205-
if (!val_is_bool(cv)) {
206-
cx.sess.span_fatal(x.span, "bad cond type in 'if'");
207-
}
208-
if (val_as_bool(cv)) {
209-
ret eval_crate_directive_block(cx, thn, prefix, view_items,
210-
items);
211-
}
212-
alt (elopt) {
213-
case (some(?els)) {
214-
ret eval_crate_directive_expr(cx, els, prefix,
215-
view_items, items);
216-
}
217-
case (_) {
218-
// Absent-else is ok.
219-
220-
}
221-
}
222-
}
223-
case (ast::expr_alt(?v, ?arms)) {
224-
auto vv = eval_expr(cx, v);
225-
for (ast::arm arm in arms) {
226-
alt (arm.pat.node) {
227-
case (ast::pat_lit(?lit, _)) {
228-
auto pv = eval_lit(cx, arm.pat.span, lit);
229-
if (val_eq(cx.sess, arm.pat.span, vv, pv)) {
230-
ret eval_crate_directive_block(cx, arm.block,
231-
prefix, view_items,
232-
items);
233-
}
234-
}
235-
case (ast::pat_wild(_)) {
236-
ret eval_crate_directive_block(cx, arm.block,
237-
prefix, view_items,
238-
items);
239-
}
240-
case (_) {
241-
cx.sess.span_fatal(arm.pat.span,
242-
"bad pattern type in 'alt'");
243-
}
244-
}
245-
}
246-
cx.sess.span_fatal(x.span, "no cases matched in 'alt'");
247-
}
248-
case (ast::expr_block(?block)) {
249-
ret eval_crate_directive_block(cx, block, prefix, view_items,
250-
items);
251-
}
252-
case (_) { cx.sess.span_fatal(x.span, "unsupported expr type"); }
253-
}
254-
}
255-
256199
fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
257200
&mutable vec[@ast::view_item] view_items,
258201
&mutable vec[@ast::item] items) {
@@ -261,9 +204,6 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
261204
auto v = eval_expr(cx, x);
262205
eval_crate_directives(cx, cdirs, prefix, view_items, items);
263206
}
264-
case (ast::cdir_expr(?x)) {
265-
eval_crate_directive_expr(cx, x, prefix, view_items, items);
266-
}
267207
case (ast::cdir_src_mod(?id, ?file_opt, ?attrs)) {
268208
auto file_path = id + ".rs";
269209
alt (file_opt) {

src/comp/front/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ {
139139
fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld)
140140
-> crate_directive_ {
141141
ret alt(cd) {
142-
case(cdir_expr(?e)) { cdir_expr(fld.fold_expr(e)) }
143142
case(cdir_let(?id, ?e, ?cds)) {
144143
cdir_let(fld.fold_ident(id), fld.fold_expr(e),
145144
map(fld.fold_crate_directive, cds))

src/comp/front/parser.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,10 +2412,8 @@ fn parse_crate_directive(&parser p, vec[ast::attribute] first_outer_attr)
24122412
auto vi = parse_view_item(p);
24132413
ret spanned(lo, vi.span.hi, ast::cdir_view_item(vi));
24142414
} else {
2415-
auto x = parse_expr(p);
2416-
ret spanned(lo, x.span.hi, ast::cdir_expr(x));
2415+
ret p.fatal("expected crate directive");
24172416
}
2418-
fail;
24192417
}
24202418

24212419
fn parse_crate_directives(&parser p, token::token term,

0 commit comments

Comments
 (0)