Skip to content

Commit 594c70f

Browse files
committed
rustc: Add an item_ann() accessor function
1 parent f77c5ba commit 594c70f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/comp/middle/ty.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,26 @@ fn pat_ty(&ctxt cx, &node_type_table ntt, &@ast::pat pat) -> t {
16651665
fail; // not reached
16661666
}
16671667

1668+
fn item_ann(&@ast::item it) -> ast::ann {
1669+
alt (it.node) {
1670+
case (ast::item_const(_,_,_,_,?a)) { ret a; }
1671+
case (ast::item_fn(_,_,_,_,?a)) { ret a; }
1672+
case (ast::item_mod(_,_,_)) {
1673+
log_err "a module was passed to item_ann(), " +
1674+
"but modules haven't annotations";
1675+
fail;
1676+
}
1677+
case (ast::item_native_mod(_,_,_)) {
1678+
log_err "a native module was passed to item_ann(), " +
1679+
"but native modules haven't annotations";
1680+
fail;
1681+
}
1682+
case (ast::item_ty(_,_,_,_,?a)) { ret a; }
1683+
case (ast::item_tag(_,_,_,_,?a)) { ret a; }
1684+
case (ast::item_obj(_,_,_,_,?a)) { ret a; }
1685+
}
1686+
}
1687+
16681688
fn expr_ann(&@ast::expr e) -> ast::ann {
16691689
alt (e.node) {
16701690
case (ast::expr_vec(_,_,?a)) { ret a; }

0 commit comments

Comments
 (0)