Skip to content

Commit 1adc26d

Browse files
committed
Annotate FIXMEs in syntax::ast and syntax::ast_util
The main non-comment change was to change simple_path to path, as per a FIXME in ast.
1 parent 16eb06c commit 1adc26d

File tree

7 files changed

+53
-53
lines changed

7 files changed

+53
-53
lines changed

src/librustsyntax/ast.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import std::serialization::{serializer,
1818
serialize_bool,
1919
deserialize_bool};
2020

21+
/* Note #1972 -- spans are serialized but not deserialized */
2122
fn serialize_span<S>(_s: S, _v: span) {
22-
// FIXME-- serialize some span info
2323
}
2424

2525
fn deserialize_span<D>(_d: D) -> span {
@@ -171,7 +171,10 @@ enum proto {
171171

172172
#[auto_serialize]
173173
enum vstore {
174-
vstore_fixed(option<uint>), // [1,2,3,4]/_ or 4 FIXME: uint -> @expr
174+
/* FIXME: Change uint to @expr (actually only constant exprs,
175+
as per #2112)
176+
*/
177+
vstore_fixed(option<uint>), // [1,2,3,4]/_ or 4
175178
vstore_uniq, // [1,2,3,4]/~
176179
vstore_box, // [1,2,3,4]/@
177180
vstore_slice(region) // [1,2,3,4]/&(foo)?
@@ -250,7 +253,9 @@ enum init_op { init_assign, init_move, }
250253
type initializer = {op: init_op, expr: @expr};
251254

252255
#[auto_serialize]
253-
type local_ = // FIXME: should really be a refinement on pat
256+
type local_ = /* FIXME: should really be a refinement on pat
257+
(pending discussion of #1697, #2178...)
258+
*/
254259
{is_mutbl: bool, ty: @ty, pat: @pat,
255260
init: option<initializer>, id: node_id};
256261

@@ -289,7 +294,7 @@ enum expr_ {
289294
expr_vstore(@expr, vstore),
290295
expr_vec([@expr], mutability),
291296
expr_rec([field], option<@expr>),
292-
expr_call(@expr, [@expr], bool),
297+
expr_call(@expr, [@expr], bool), // True iff last argument is a block
293298
expr_tup([@expr]),
294299
expr_bind(@expr, [option<@expr>]),
295300
expr_binary(binop, @expr, @expr),
@@ -315,6 +320,7 @@ enum expr_ {
315320
/*
316321
* FIXME: many of these @exprs should be constrained with
317322
* is_lval once we have constrained types working.
323+
* (See #34)
318324
*/
319325
expr_copy(@expr),
320326
expr_move(@expr, @expr),
@@ -341,9 +347,6 @@ enum expr_ {
341347

342348
/* preds that typestate is aware of */
343349
expr_check(expr_check_mode, @expr),
344-
345-
/* FIXME Would be nice if expr_check desugared
346-
to expr_if_check. */
347350
expr_if_check(@expr, blk, option<@expr>),
348351
expr_mac(mac),
349352
}
@@ -587,11 +590,6 @@ type variant_ = {name: ident, attrs: [attribute], args: [variant_arg],
587590
#[auto_serialize]
588591
type variant = spanned<variant_>;
589592

590-
// FIXME: May want to just use path here, which would allow things like
591-
// 'import ::foo'
592-
#[auto_serialize]
593-
type simple_path = [ident];
594-
595593
#[auto_serialize]
596594
type path_list_ident_ = {name: ident, id: node_id};
597595

@@ -609,13 +607,13 @@ enum view_path_ {
609607
// or just
610608
//
611609
// foo::bar::baz (with 'baz =' implicitly on the left)
612-
view_path_simple(ident, @simple_path, node_id),
610+
view_path_simple(ident, @path, node_id),
613611

614612
// foo::bar::*
615-
view_path_glob(@simple_path, node_id),
613+
view_path_glob(@path, node_id),
616614

617615
// foo::bar::{a,b,c}
618-
view_path_list(@simple_path, [path_list_ident], node_id)
616+
view_path_list(@path, [path_list_ident], node_id)
619617
}
620618

621619
#[auto_serialize]
@@ -676,9 +674,6 @@ type class_member = spanned<class_member_>;
676674
enum class_member_ {
677675
instance_var(ident, @ty, class_mutability, node_id, privacy),
678676
class_method(@method)
679-
// without constrained types, have to duplicate some stuff. or factor out
680-
// item to separate out things with type params?
681-
// (FIXME) where do we enforce that type params is empty?
682677
}
683678

684679
#[auto_serialize]

src/librustsyntax/ast_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ fn is_exported(i: ident, m: _mod) -> bool {
175175
}
176176

177177
ast::view_path_list(path, ids, _) {
178-
if vec::len(*path) == 1u {
179-
if i == path[0] { ret true; }
178+
if vec::len(path.node.idents) == 1u {
179+
if i == path.node.idents[0] { ret true; }
180180
for ids.each {|id|
181181
if id.node.name == i { ret true; }
182182
}
@@ -185,7 +185,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
185185
}
186186
}
187187

188-
// FIXME: glob-exports aren't supported yet.
188+
// FIXME: glob-exports aren't supported yet. (#2006)
189189
_ {}
190190
}
191191
}

src/librustsyntax/parse/parser.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,7 +2624,10 @@ fn parse_view_path(p: parser) -> @ast::view_path {
26242624
let mut hi = p.span.hi;
26252625
ret @spanned(lo, hi,
26262626
ast::view_path_simple(first_ident,
2627-
@path, p.get_id()));
2627+
@spanned(lo, hi,
2628+
{global: false, idents: path,
2629+
types: []}),
2630+
p.get_id()));
26282631
}
26292632

26302633
token::MOD_SEP {
@@ -2647,17 +2650,23 @@ fn parse_view_path(p: parser) -> @ast::view_path {
26472650
parse_path_list_ident, p).node;
26482651
let mut hi = p.span.hi;
26492652
ret @spanned(lo, hi,
2650-
ast::view_path_list(@path, idents,
2651-
p.get_id()));
2653+
ast::view_path_list(@spanned(lo, hi,
2654+
{global: false,
2655+
idents: path,
2656+
types: []}), idents,
2657+
p.get_id()));
26522658
}
26532659

26542660
// foo::bar::*
26552661
token::BINOP(token::STAR) {
26562662
p.bump();
26572663
let mut hi = p.span.hi;
26582664
ret @spanned(lo, hi,
2659-
ast::view_path_glob(@path,
2660-
p.get_id()));
2665+
ast::view_path_glob(@spanned(lo, hi,
2666+
{global: false,
2667+
idents: path,
2668+
types: []}),
2669+
p.get_id()));
26612670
}
26622671

26632672
_ { break; }
@@ -2669,7 +2678,10 @@ fn parse_view_path(p: parser) -> @ast::view_path {
26692678
let mut hi = p.span.hi;
26702679
let last = path[vec::len(path) - 1u];
26712680
ret @spanned(lo, hi,
2672-
ast::view_path_simple(last, @path,
2681+
ast::view_path_simple(last, @spanned(lo, hi,
2682+
{global: false,
2683+
idents: path,
2684+
types: []}),
26732685
p.get_id()));
26742686
}
26752687

src/librustsyntax/print/pprust.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,31 +1426,23 @@ fn print_meta_item(s: ps, &&item: @ast::meta_item) {
14261426
end(s);
14271427
}
14281428

1429-
fn print_simple_path(s: ps, path: ast::simple_path) {
1430-
let mut first = true;
1431-
for path.each {|id|
1432-
if first { first = false; } else { word(s.s, "::"); }
1433-
word(s.s, id);
1434-
}
1435-
}
1436-
14371429
fn print_view_path(s: ps, &&vp: @ast::view_path) {
14381430
alt vp.node {
14391431
ast::view_path_simple(ident, path, _) {
1440-
if path[vec::len(*path)-1u] != ident {
1432+
if path.node.idents[vec::len(path.node.idents)-1u] != ident {
14411433
word_space(s, ident);
14421434
word_space(s, "=");
14431435
}
1444-
print_simple_path(s, *path);
1436+
print_path(s, path, false);
14451437
}
14461438

14471439
ast::view_path_glob(path, _) {
1448-
print_simple_path(s, *path);
1440+
print_path(s, path, false);
14491441
word(s.s, "::*");
14501442
}
14511443

14521444
ast::view_path_list(path, idents, _) {
1453-
print_simple_path(s, *path);
1445+
print_path(s, path, false);
14541446
word(s.s, "::{");
14551447
commasep(s, inconsistent, idents) {|s, w|
14561448
word(s.s, w.node.name)

src/rustc/front/core_inject.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import driver::session::session;
22
import syntax::codemap;
33
import syntax::ast;
4+
import syntax::ast_util::*;
45
import syntax::attr;
56

67
export maybe_inject_libcore_ref;
@@ -23,15 +24,15 @@ fn inject_libcore_ref(sess: session,
2324

2425
fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
2526
ret @{node: x,
26-
span: {lo: 0u, hi: 0u,
27-
expn_info: option::none}};
27+
span: dummy_sp()};
2828
}
2929

3030
let n1 = sess.next_node_id();
3131
let n2 = sess.next_node_id();
3232

3333
let vi1 = spanned(ast::view_item_use("core", [], n1));
34-
let vp = spanned(ast::view_path_glob(@["core"], n2));
34+
let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), "core"),
35+
n2));
3536
let vi2 = spanned(ast::view_item_import([vp]));
3637

3738
let vis = [vi1, vi2] + crate.node.module.view_items;

src/rustc/middle/ast_map.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import std::map::hashmap;
33
import syntax::ast::*;
44
import syntax::print::pprust;
55
import syntax::ast_util;
6+
import middle::pat_util::*;
67
import syntax::ast_util::inlined_item_methods;
78
import syntax::{visit, codemap};
89
import driver::session::session;
@@ -233,9 +234,7 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
233234
let (id, name) = alt vp.node {
234235
view_path_simple(nm, _, id) { (id, nm) }
235236
view_path_glob(pth, id) | view_path_list(pth, _, id) {
236-
// should be a constraint on the type
237-
assert (vec::is_not_empty(*pth));
238-
(id, vec::last(*pth))
237+
(id, path_to_ident(pth))
239238
}
240239
};
241240
cx.map.insert(id, node_export(vp, extend(cx, name)));

src/rustc/middle/resolve.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,16 @@ fn map_crate(e: @env, c: @ast::crate) {
236236
iter_effective_import_paths(*i) { |vp|
237237
alt vp.node {
238238
ast::view_path_simple(name, path, id) {
239-
e.imports.insert(id, todo(name, path, vp.span, sc));
239+
e.imports.insert(id, todo(name, @path.node.idents, vp.span,
240+
sc));
240241
}
241242
ast::view_path_glob(path, id) {
242-
e.imports.insert(id, is_glob(path, sc, vp.span));
243+
e.imports.insert(id, is_glob(@path.node.idents, sc, vp.span));
243244
}
244245
ast::view_path_list(mod_path, idents, _) {
245246
for idents.each {|ident|
246247
let t = todo(ident.node.name,
247-
@(*mod_path + [ident.node.name]),
248+
@(mod_path.node.idents + [ident.node.name]),
248249
ident.span, sc);
249250
e.imports.insert(ident.node.id, t);
250251
}
@@ -297,7 +298,7 @@ fn map_crate(e: @env, c: @ast::crate) {
297298
iter_effective_import_paths(*vi) { |vp|
298299
alt vp.node {
299300
ast::view_path_glob(path, _) {
300-
alt follow_import(*e, sc, *path, vp.span) {
301+
alt follow_import(*e, sc, path.node.idents, vp.span) {
301302
some(imp) {
302303
let glob = {def: imp, path: vp};
303304
alt list::head(sc) {
@@ -2083,8 +2084,8 @@ fn check_exports(e: @env) {
20832084
check_export(e, ident, _mod, id, vi);
20842085
}
20852086
ast::view_path_list(path, ids, node_id) {
2086-
let id = if vec::len(*path) == 1u {
2087-
path[0]
2087+
let id = if vec::len(path.node.idents) == 1u {
2088+
path.node.idents[0]
20882089
} else {
20892090
e.sess.span_fatal(vp.span, "bad export name-list")
20902091
};
@@ -2151,12 +2152,12 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
21512152
alt vp.node {
21522153
ast::view_path_simple(name, pt, id) {
21532154
let mut found = [];
2154-
if vec::len(*pt) == 1u {
2155+
if vec::len(pt.node.idents) == 1u {
21552156
option::iter(sc) {|sc|
21562157
list::iter(sc) {|level|
21572158
if vec::len(found) == 0u {
21582159
for vec::each(*level) {|imp|
2159-
if imp.ident == pt[0] {
2160+
if imp.ident == pt.node.idents[0] {
21602161
found += [@{ident: name with *imp}];
21612162
}
21622163
}

0 commit comments

Comments
 (0)