From ca6636d6b689fe209a210b0eda51e368f01cdb0f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 28 Mar 2012 14:17:41 -0700 Subject: Allow references to "self" within classes Allow writing self.f within a class that has a field f. Currently, the compiler accepts either self.f or f. In a future commit I'll require writing self.f and not f. Not sure whether self.f() works if f is a method (making sure that works next). --- src/rustc/syntax/parse/parser.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/rustc/syntax/parse/parser.rs') diff --git a/src/rustc/syntax/parse/parser.rs b/src/rustc/syntax/parse/parser.rs index 3ca2e6a588b..61cc675c492 100644 --- a/src/rustc/syntax/parse/parser.rs +++ b/src/rustc/syntax/parse/parser.rs @@ -2092,10 +2092,12 @@ fn parse_item_class(p: parser, attrs: [ast::attribute]) -> @ast::item { } p.bump(); alt the_ctor { - some((ct_d, ct_b, ct_s)) { ret mk_item(p, lo, p.last_span.hi, + some((ct_d, ct_b, ct_s)) { + ret mk_item(p, lo, p.last_span.hi, class_name, ast::item_class(ty_params, items, {node: {id: ctor_id, + self_id: p.get_id(), dec: ct_d, body: ct_b}, span: ct_s}), attrs); } -- cgit 1.4.1-3-g733a5