Skip to content

Commit 31ff64c

Browse files
committed
Annotate FIXMEs in parser
Also, get rid of two FIXMEs by refactoring some code, and moving the call_expr check for be expressions into typeck, where it seems to make more sense.
1 parent cdc8722 commit 31ff64c

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

src/librustsyntax/parse/parser.rs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export parse_stmt;
2626
export parse_ty;
2727

2828
// FIXME: #ast expects to find this here but it's actually defined in `parse`
29+
// Fixing this will be easier when we have export decls on individual items --
30+
// then parse can export this publicly, and everything else crate-visibly.
31+
// (See #1893)
2932
import parse_from_source_str;
3033
export parse_from_source_str;
3134

@@ -224,8 +227,10 @@ fn parse_ty_fn(p: parser) -> ast::fn_decl {
224227
let inputs =
225228
parse_seq(token::LPAREN, token::RPAREN, seq_sep(token::COMMA),
226229
parse_fn_input_ty, p);
227-
// FIXME: there's no syntax for this right now anyway
228-
// auto constrs = parse_constrs(~[], p);
230+
// FIXME: constrs is empty because right now, higher-order functions
231+
// can't have constrained types.
232+
// Not sure whether that would be desirable anyway. See #34 for the
233+
// story on constrained types.
229234
let constrs: [@ast::constr] = [];
230235
let (ret_style, ret_ty) = parse_ret_ty(p);
231236
ret {inputs: inputs.node, output: ret_ty,
@@ -400,9 +405,9 @@ fn parse_ret_ty(p: parser) -> (ast::ret_style, @ast::ty) {
400405
fn region_from_name(p: parser, s: option<str>) -> ast::region {
401406
let r = alt s {
402407
some (string) {
403-
// FIXME: To be consistent with our type resolution the
408+
// FIXME: To be consistent with our type resolution, the
404409
// static region should probably be resolved during type
405-
// checking, not in the parser.
410+
// checking, not in the parser. (Issue #2256)
406411
if string == "static" {
407412
ast::re_static
408413
} else {
@@ -973,12 +978,8 @@ fn parse_bottom_expr(p: parser) -> pexpr {
973978
hi = p.span.hi;
974979
} else if eat_word(p, "be") {
975980
let e = parse_expr(p);
976-
977-
// FIXME: Is this the right place for this check?
978-
if /*check*/ast_util::is_call_expr(e) {
979-
hi = e.span.hi;
980-
ex = ast::expr_be(e);
981-
} else { p.fatal("non-call expression in tail call"); }
981+
hi = e.span.hi;
982+
ex = ast::expr_be(e);
982983
} else if eat_word(p, "copy") {
983984
let e = parse_expr(p);
984985
ex = ast::expr_copy(e);
@@ -2070,6 +2071,19 @@ fn parse_item_class(p: parser, attrs: [ast::attribute]) -> @ast::item {
20702071
}
20712072
}
20722073

2074+
fn parse_single_class_item(p: parser, privcy: ast::privacy)
2075+
-> @ast::class_member {
2076+
if eat_word(p, "let") {
2077+
let a_var = parse_instance_var(p, privcy);
2078+
expect(p, token::SEMI);
2079+
ret a_var;
2080+
}
2081+
else {
2082+
let m = parse_method(p, privcy);
2083+
ret @{node: ast::class_method(m), span: m.span};
2084+
}
2085+
}
2086+
20732087
// lets us identify the constructor declaration at
20742088
// parse time
20752089
enum class_contents { ctor_decl(ast::fn_decl, ast::blk, codemap::span),
@@ -2089,35 +2103,18 @@ fn parse_class_item(p:parser, class_name_with_tps:@ast::path)
20892103
let body = parse_block(p);
20902104
ret ctor_decl(decl, body, ast_util::mk_sp(lo, p.last_span.hi));
20912105
}
2092-
// FIXME: refactor
20932106
else if eat_word(p, "priv") {
20942107
expect(p, token::LBRACE);
20952108
let mut results = [];
20962109
while p.token != token::RBRACE {
2097-
if eat_word(p, "let") {
2098-
let a_var = parse_instance_var(p, ast::priv);
2099-
expect(p, token::SEMI);
2100-
results += [a_var];
2101-
}
2102-
else {
2103-
let m = parse_method(p, ast::priv);
2104-
results += [@{node: ast::class_method(m), span: m.span}];
2105-
}
2110+
results += [parse_single_class_item(p, ast::priv)];
21062111
}
21072112
p.bump();
21082113
ret members(results);
21092114
}
21102115
else {
21112116
// Probably need to parse attrs
2112-
ret if eat_word(p, "let") {
2113-
let ivar = parse_instance_var(p, ast::pub);
2114-
expect(p, token::SEMI);
2115-
members([ivar])
2116-
}
2117-
else {
2118-
let m = parse_method(p, ast::pub);
2119-
members([@{node: ast::class_method(m), span: m.span}])
2120-
}
2117+
ret members([parse_single_class_item(p, ast::pub)]);
21212118
}
21222119
}
21232120

src/rustc/middle/typeck.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,8 +3160,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
31603160
fcx.write_bot(id);
31613161
}
31623162
ast::expr_be(e) {
3163-
// FIXME: prove instead of assert
3164-
assert (ast_util::is_call_expr(e));
3163+
if !ast_util::is_call_expr(e) {
3164+
tcx.sess.span_err(expr.span,
3165+
"non-call expression in tail call");
3166+
}
31653167
check_expr_with(fcx, e, fcx.ret_ty);
31663168
bot = true;
31673169
fcx.write_nil(id);

0 commit comments

Comments
 (0)