type variant_arg = {ty: @ty, id: node_id};
-type variant_ = {name: ident, args: [variant_arg], id: node_id,
- disr_expr: option::t<@expr>};
+type variant_ = {name: ident, attrs: [attribute], args: [variant_arg],
+ id: node_id, disr_expr: option::t<@expr>};
type variant = spanned<variant_>;
}
let fold_variant_arg = bind fold_variant_arg_(_, fld);
let args = vec::map(v.args, fold_variant_arg);
+
+ let fold_meta_item = bind fold_meta_item_(_, fld);
+ let fold_attribute = bind fold_attribute_(_, fold_meta_item);
+ let attrs = vec::map(v.attrs, fold_attribute);
+
let de = alt v.disr_expr {
some(e) {some(fld.fold_expr(e))}
none {none}
};
- ret {name: v.name, args: args, id: v.id,
+ ret {name: v.name,
+ attrs: attrs,
+ args: args, id: v.id,
disr_expr: de};
}
let variant =
spanned(ty.span.lo, ty.span.hi,
{name: id,
+ attrs: [],
args: [{ty: ty, id: p.get_id()}],
id: p.get_id(),
disr_expr: none});
ast::item_enum([variant], ty_params), attrs);
}
expect(p, token::LBRACE);
+
let all_nullary = true, have_disr = false;
while p.token != token::RBRACE {
+ let variant_attrs = parse_outer_attributes(p);
let vlo = p.span.lo;
let ident = parse_value_ident(p);
let args = [], disr_expr = none;
disr_expr = some(parse_expr(p));
}
- let vr = {name: ident, args: args, id: p.get_id(),
+ let vr = {name: ident, attrs: variant_attrs,
+ args: args, id: p.get_id(),
disr_expr: disr_expr};
variants += [spanned(vlo, p.last_span.hi, vr)];
for v: ast::variant in variants {
space_if_not_bol(s);
maybe_print_comment(s, v.span.lo);
+ print_outer_attributes(s, v.node.attrs);
ibox(s, indent_unit);
word(s.s, v.node.name);
if vec::len(v.node.args) > 0u {
--- /dev/null
+// pp-exact - Make sure we actually print the attributes
+
+enum crew_of_enterprise_d {
+
+ #[captain]
+ jean_luc_picard,
+
+ #[commander]
+ william_t_riker,
+
+ #[chief_medical_officer]
+ beverly_crusher,
+
+ #[ships_councellor]
+ deanna_troi,
+
+ #[lieutenant_commander]
+ data,
+
+ #[chief_of_security]
+ worf,
+
+ #[chief_engineer]
+ geordi_la_forge,
+}
+
+fn boldly_go(_crew_member: crew_of_enterprise_d, _where: str) { }
+
+fn main() { boldly_go(worf, "where no one has gone before"); }