diff options
| author | bors <bors@rust-lang.org> | 2013-07-30 01:37:17 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-30 01:37:17 -0700 |
| commit | d75ab4a5d798164c37e04a0794f2e28acdb76dd4 (patch) | |
| tree | b0a4b6cc159150e5d0c593d9683aafa9fc342b71 /src/libsyntax | |
| parent | 8695bc74a0dcedcdce3f9bb9c312347511a88ce5 (diff) | |
| parent | 8a329770b6d0bc526e5873c143a5db1b551d42c1 (diff) | |
| download | rust-d75ab4a5d798164c37e04a0794f2e28acdb76dd4.tar.gz rust-d75ab4a5d798164c37e04a0794f2e28acdb76dd4.zip | |
auto merge of #8107 : michaelwoerister/rust/end_of_spanned, r=cmr
Contiunation of naming cleanup in `libsyntax::ast`: ```rust ast::node_id => ast::NodeId ast::local_crate => ast::LOCAL_CRATE ast::crate_node_id => ast::CRATE_NODE_ID ast::blk_check_mode => ast::BlockCheckMode ast::ty_field => ast::TypeField ast::ty_method => ast::TypeMethod ``` Also moved span field directly into `TypeField` struct and cleaned up overlooked `ast::CrateConfig` renamings from last pull request. Cheers, Michael
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 115 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 42 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/parse/classify.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 50 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 40 |
11 files changed, 153 insertions, 158 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 51c47acff0e..97e69cd6918 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -94,7 +94,7 @@ pub type fn_ident = Option<ident>; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct Lifetime { - id: node_id, + id: NodeId, span: span, ident: ident } @@ -119,16 +119,16 @@ pub struct Path { pub type CrateNum = int; -pub type node_id = int; +pub type NodeId = int; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct def_id { crate: CrateNum, - node: node_id, + node: NodeId, } -pub static local_crate: CrateNum = 0; -pub static crate_node_id: node_id = 0; +pub static LOCAL_CRATE: CrateNum = 0; +pub static CRATE_NODE_ID: NodeId = 0; // The AST represents all type param bounds as types. // typeck::collect::compute_bounds matches these against @@ -143,7 +143,7 @@ pub enum TyParamBound { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct TyParam { ident: ident, - id: node_id, + id: NodeId, bounds: OptVec<TyParamBound> } @@ -171,28 +171,28 @@ pub enum def { def_static_method(/* method */ def_id, /* trait */ Option<def_id>, purity), - def_self(node_id, bool /* is_implicit */), - def_self_ty(/* trait id */ node_id), + def_self(NodeId, bool /* is_implicit */), + def_self_ty(/* trait id */ NodeId), def_mod(def_id), def_foreign_mod(def_id), def_static(def_id, bool /* is_mutbl */), - def_arg(node_id, bool /* is_mutbl */), - def_local(node_id, bool /* is_mutbl */), + def_arg(NodeId, bool /* is_mutbl */), + def_local(NodeId, bool /* is_mutbl */), def_variant(def_id /* enum */, def_id /* variant */), def_ty(def_id), def_trait(def_id), def_prim_ty(prim_ty), def_ty_param(def_id, uint), - def_binding(node_id, binding_mode), + def_binding(NodeId, binding_mode), def_use(def_id), - def_upvar(node_id, // id of closed over var + def_upvar(NodeId, // id of closed over var @def, // closed over def - node_id, // expr node that creates the closure - node_id), // id for the block/body of the closure expr + NodeId, // expr node that creates the closure + NodeId), // id for the block/body of the closure expr def_struct(def_id), - def_typaram_binder(node_id), /* struct, impl or trait with ty params */ - def_region(node_id), - def_label(node_id), + def_typaram_binder(NodeId), /* struct, impl or trait with ty params */ + def_region(NodeId), + def_label(NodeId), def_method(def_id /* method */, Option<def_id> /* trait */), } @@ -248,14 +248,14 @@ pub struct Block { view_items: ~[view_item], stmts: ~[@stmt], expr: Option<@expr>, - id: node_id, - rules: blk_check_mode, + id: NodeId, + rules: BlockCheckMode, span: span, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct pat { - id: node_id, + id: NodeId, node: pat_, span: span, } @@ -280,7 +280,7 @@ pub enum pat_ { // is None). // In the nullary enum case, the parser can't determine // which it is. The resolver determines this, and - // records this pattern's node_id in an auxiliary + // records this pattern's NodeId in an auxiliary // set (of "pat_idents that refer to nullary enums") pat_ident(binding_mode, Path, Option<@pat>), pat_enum(Path, Option<~[@pat]>), /* "none" means a * pattern where @@ -371,13 +371,13 @@ pub type stmt = spanned<stmt_>; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum stmt_ { // could be an item or a local (let) binding: - stmt_decl(@decl, node_id), + stmt_decl(@decl, NodeId), // expr without trailing semi-colon (must have unit type): - stmt_expr(@expr, node_id), + stmt_expr(@expr, NodeId), // expr with trailing semi-colon (may have any type): - stmt_semi(@expr, node_id), + stmt_semi(@expr, NodeId), // bool: is there a trailing sem-colon? stmt_mac(mac, bool), @@ -391,7 +391,7 @@ pub struct Local { ty: Ty, pat: @pat, init: Option<@expr>, - id: node_id, + id: NodeId, span: span, } @@ -420,20 +420,20 @@ pub struct Field { } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum blk_check_mode { - default_blk, - unsafe_blk, +pub enum BlockCheckMode { + DefaultBlock, + UnsafeBlock, } #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct expr { - id: node_id, + id: NodeId, node: expr_, span: span, } impl expr { - pub fn get_callee_id(&self) -> Option<node_id> { + pub fn get_callee_id(&self) -> Option<NodeId> { match self.node { expr_method_call(callee_id, _, _, _, _, _) | expr_index(callee_id, _, _) | @@ -457,10 +457,10 @@ pub enum expr_ { expr_vstore(@expr, expr_vstore), expr_vec(~[@expr], mutability), expr_call(@expr, ~[@expr], CallSugar), - expr_method_call(node_id, @expr, ident, ~[Ty], ~[@expr], CallSugar), + expr_method_call(NodeId, @expr, ident, ~[Ty], ~[@expr], CallSugar), expr_tup(~[@expr]), - expr_binary(node_id, binop, @expr, @expr), - expr_unary(node_id, unop, @expr), + expr_binary(NodeId, binop, @expr, @expr), + expr_unary(NodeId, unop, @expr), expr_lit(@lit), expr_cast(@expr, Ty), expr_if(@expr, Block, Option<@expr>), @@ -480,9 +480,9 @@ pub enum expr_ { expr_block(Block), expr_assign(@expr, @expr), - expr_assign_op(node_id, binop, @expr, @expr), + expr_assign_op(NodeId, binop, @expr, @expr), expr_field(@expr, ident, ~[Ty]), - expr_index(node_id, @expr, @expr), + expr_index(NodeId, @expr, @expr), expr_path(Path), /// The special identifier `self`. @@ -636,22 +636,21 @@ pub struct mt { } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct ty_field_ { +pub struct TypeField { ident: ident, mt: mt, + span: span, } -pub type ty_field = spanned<ty_field_>; - #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct ty_method { +pub struct TypeMethod { ident: ident, attrs: ~[Attribute], purity: purity, decl: fn_decl, generics: Generics, explicit_self: explicit_self, - id: node_id, + id: NodeId, span: span, } @@ -660,7 +659,7 @@ pub struct ty_method { // implementation). #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum trait_method { - required(ty_method), + required(TypeMethod), provided(@method), } @@ -711,7 +710,7 @@ impl ToStr for float_ty { // NB Eq method appears below. #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] pub struct Ty { - id: node_id, + id: NodeId, node: ty_, span: span, } @@ -778,7 +777,7 @@ pub enum ty_ { ty_closure(@TyClosure), ty_bare_fn(@TyBareFn), ty_tup(~[Ty]), - ty_path(Path, Option<OptVec<TyParamBound>>, node_id), // for #7264; see above + ty_path(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above ty_mac(mac), // ty_infer means the type should be inferred instead of it having been // specified. This should only appear at the "top level" of a type and not @@ -808,7 +807,7 @@ pub struct arg { is_mutbl: bool, ty: Ty, pat: @pat, - id: node_id, + id: NodeId, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -863,9 +862,9 @@ pub struct method { purity: purity, decl: fn_decl, body: Block, - id: node_id, + id: NodeId, span: span, - self_id: node_id, + self_id: NodeId, vis: visibility, } @@ -893,7 +892,7 @@ pub struct foreign_mod { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct variant_arg { ty: Ty, - id: node_id, + id: NodeId, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -912,7 +911,7 @@ pub struct variant_ { name: ident, attrs: ~[Attribute], kind: variant_kind, - id: node_id, + id: NodeId, disr_expr: Option<@expr>, vis: visibility, } @@ -922,7 +921,7 @@ pub type variant = spanned<variant_>; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct path_list_ident_ { name: ident, - id: node_id, + id: NodeId, } pub type path_list_ident = spanned<path_list_ident_>; @@ -937,13 +936,13 @@ pub enum view_path_ { // or just // // foo::bar::baz (with 'baz =' implicitly on the left) - view_path_simple(ident, Path, node_id), + view_path_simple(ident, Path, NodeId), // foo::bar::* - view_path_glob(Path, node_id), + view_path_glob(Path, NodeId), // foo::bar::{a,b,c} - view_path_list(Path, ~[path_list_ident], node_id) + view_path_list(Path, ~[path_list_ident], NodeId) } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -956,7 +955,7 @@ pub struct view_item { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum view_item_ { - view_item_extern_mod(ident, ~[@MetaItem], node_id), + view_item_extern_mod(ident, ~[@MetaItem], NodeId), view_item_use(~[@view_path]), } @@ -990,7 +989,7 @@ pub struct Attribute_ { #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] pub struct trait_ref { path: Path, - ref_id: node_id, + ref_id: NodeId, } #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] @@ -1012,7 +1011,7 @@ impl visibility { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct struct_field_ { kind: struct_field_kind, - id: node_id, + id: NodeId, ty: Ty, attrs: ~[Attribute], } @@ -1030,7 +1029,7 @@ pub struct struct_def { fields: ~[@struct_field], /* fields, not including ctor */ /* ID of the constructor. This is only used for tuple- or enum-like * structs. */ - ctor_id: Option<node_id> + ctor_id: Option<NodeId> } /* @@ -1041,7 +1040,7 @@ pub struct struct_def { pub struct item { ident: ident, attrs: ~[Attribute], - id: node_id, + id: NodeId, node: item_, vis: visibility, span: span, @@ -1070,7 +1069,7 @@ pub struct foreign_item { ident: ident, attrs: ~[Attribute], node: foreign_item_, - id: node_id, + id: NodeId, span: span, vis: visibility, } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 2981336466e..7e70817a68e 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -78,7 +78,7 @@ pub enum ast_node { node_callee_scope(@expr) } -pub type map = @mut HashMap<node_id, ast_node>; +pub type map = @mut HashMap<NodeId, ast_node>; pub struct Ctx { map: map, @@ -159,7 +159,7 @@ pub fn map_fn( decl: &fn_decl, body: &Block, sp: codemap::span, - id: node_id, + id: NodeId, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>) ) { @@ -313,7 +313,7 @@ pub fn map_stmt(stmt: @stmt, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) { visit::visit_stmt(stmt, (cx, v)); } -pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { +pub fn node_id_to_str(map: map, id: NodeId, itr: @ident_interner) -> ~str { match map.find(&id) { None => { fmt!("unknown node (id=%d)", id) @@ -376,7 +376,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { } } -pub fn node_item_query<Result>(items: map, id: node_id, +pub fn node_item_query<Result>(items: map, id: NodeId, query: &fn(@item) -> Result, error_msg: ~str) -> Result { match items.find(&id) { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 37112a533c8..5ad325fed56 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -31,13 +31,13 @@ pub fn path_to_ident(p: &Path) -> ident { *p.idents.last() } -pub fn local_def(id: node_id) -> def_id { - ast::def_id { crate: local_crate, node: id } +pub fn local_def(id: NodeId) -> def_id { + ast::def_id { crate: LOCAL_CRATE, node: id } } -pub fn is_local(did: ast::def_id) -> bool { did.crate == local_crate } +pub fn is_local(did: ast::def_id) -> bool { did.crate == LOCAL_CRATE } -pub fn stmt_id(s: &stmt) -> node_id { +pub fn stmt_id(s: &stmt) -> NodeId { match s.node { stmt_decl(_, id) => id, stmt_expr(_, id) => id, @@ -204,14 +204,14 @@ pub fn block_from_expr(e: @expr) -> Block { pub fn default_block( stmts1: ~[@stmt], expr1: Option<@expr>, - id1: node_id + id1: NodeId ) -> Block { ast::Block { view_items: ~[], stmts: stmts1, expr: expr1, id: id1, - rules: default_blk, + rules: DefaultBlock, span: dummy_sp(), } } @@ -224,7 +224,7 @@ pub fn ident_to_path(s: span, i: ident) -> Path { types: ~[] } } -pub fn ident_to_pat(id: node_id, s: span, i: ident) -> @pat { +pub fn ident_to_pat(id: NodeId, s: span, i: ident) -> @pat { @ast::pat { id: id, node: pat_ident(bind_infer, ident_to_path(s, i), None), span: s } @@ -254,13 +254,13 @@ pub fn public_methods(ms: ~[@method]) -> ~[@method] { }.collect() } -// extract a ty_method from a trait_method. if the trait_method is -// a default, pull out the useful fields to make a ty_method -pub fn trait_method_to_ty_method(method: &trait_method) -> ty_method { +// extract a TypeMethod from a trait_method. if the trait_method is +// a default, pull out the useful fields to make a TypeMethod +pub fn trait_method_to_ty_method(method: &trait_method) -> TypeMethod { match *method { required(ref m) => (*m).clone(), provided(ref m) => { - ty_method { + TypeMethod { ident: m.ident, attrs: m.attrs.clone(), purity: m.purity, @@ -275,7 +275,7 @@ pub fn trait_method_to_ty_method(method: &trait_method) -> ty_method { } pub fn split_trait_methods(trait_methods: &[trait_method]) - -> (~[ty_method], ~[@method]) { + -> (~[TypeMethod], ~[@method]) { let mut reqd = ~[]; let mut provd = ~[]; for trait_methods.iter().advance |trt_method| { @@ -296,7 +296,7 @@ pub fn struct_field_visibility(field: ast::struct_field) -> visibility { pub trait inlined_item_utils { fn ident(&self) -> ident; - fn id(&self) -> ast::node_id; + fn id(&self) -> ast::NodeId; fn accept<E: Clone>(&self, e: E, v: visit::vt<E>); } @@ -309,7 +309,7 @@ impl inlined_item_utils for inlined_item { } } - fn id(&self) -> ast::node_id { + fn id(&self) -> ast::NodeId { match *self { ii_item(i) => i.id, ii_foreign(i) => i.id, @@ -367,8 +367,8 @@ pub fn empty_generics() -> Generics { #[deriving(Encodable, Decodable)] pub struct id_range { - min: node_id, - max: node_id, + min: NodeId, + max: NodeId, } impl id_range { @@ -383,13 +383,13 @@ impl id_range { self.min >= self.max } - pub fn add(&mut self, id: node_id) { + pub fn add(&mut self, id: NodeId) { self.min = num::min(self.min, id); self.max = num::max(self.max, id + 1); } } -pub fn id_visitor<T: Clone>(vfn: @fn(node_id, T)) -> visit::vt<T> { +pub fn id_visitor<T: Clone>(vfn: @fn(NodeId, T)) -> visit::vt<T> { let visit_generics: @fn(&Generics, T) = |generics, t| { for generics.ty_params.iter().advance |p| { vfn(p.id, t.clone()); @@ -515,11 +515,11 @@ pub fn id_visitor<T: Clone>(vfn: @fn(node_id, T)) -> visit::vt<T> { }) } -pub fn visit_ids_for_inlined_item(item: &inlined_item, vfn: @fn(node_id)) { +pub fn visit_ids_for_inlined_item(item: &inlined_item, vfn: @fn(NodeId)) { item.accept((), id_visitor(|id, ()| vfn(id))); } -pub fn compute_id_range(visit_ids_fn: &fn(@fn(node_id))) -> id_range { +pub fn compute_id_range(visit_ids_fn: &fn(@fn(NodeId))) -> id_range { let result = @mut id_range::max(); do visit_ids_fn |id| { result.add(id); @@ -581,7 +581,7 @@ impl EachViewItem for ast::Crate { } } -pub fn view_path_id(p: &view_path) -> node_id { +pub fn view_path_id(p: &view_path) -> NodeId { match p.node { view_path_simple(_, _, id) | view_path_glob(_, id) | diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a5c8f2a235e..ea87646e60b 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -294,7 +294,7 @@ impl ExtCtxt { self.print_backtrace(); self.parse_sess.span_diagnostic.handler().bug(msg); } - pub fn next_id(&self) -> ast::node_id { + pub fn next_id(&self) -> ast::NodeId { parse::next_node_id(self.parse_sess) } pub fn trace_macros(&self) -> bool { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index b3d65dfa9e2..7e017838496 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -62,7 +62,7 @@ pub trait AstBuilder { fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty]; fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty]; - fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::ty_field; + fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::TypeField; fn strip_bounds(&self, bounds: &Generics) -> Generics; fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam; @@ -306,12 +306,12 @@ impl AstBuilder for @ExtCtxt { ~[ ty ]), None) } - fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::ty_field { - respan(span, - ast::ty_field_ { - ident: name, - mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, - }) + fn ty_field_imm(&self, span: span, name: ident, ty: ast::Ty) -> ast::TypeField { + ast::TypeField { + ident: name, + mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, + span: span, + } } fn ty_infer(&self, span: span) -> ast::Ty { @@ -404,7 +404,7 @@ impl AstBuilder for @ExtCtxt { stmts: stmts, expr: expr, id: self.next_id(), - rules: ast::default_blk, + rules: ast::DefaultBlock, span: span, } } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index f27e68641e3..51475528174 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -36,7 +36,7 @@ pub trait ast_fold { fn fold_path(@self, &Path) -> Path; fn fold_local(@self, @Local) -> @Local; fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr]; - fn new_id(@self, node_id) -> node_id; + fn new_id(@self, NodeId) -> NodeId; fn new_span(@self, span) -> span; } @@ -65,7 +65,7 @@ pub struct AstFoldFns { fold_path: @fn(&Path, @ast_fold) -> Path, fold_local: @fn(@Local, @ast_fold) -> @Local, map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], - new_id: @fn(node_id) -> node_id, + new_id: @fn(NodeId) -> NodeId, new_span: @fn(span) -> span } @@ -646,12 +646,10 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { mutbl: mt.mutbl, } } - fn fold_field(f: ty_field, fld: @ast_fold) -> ty_field { - spanned { - node: ast::ty_field_ { - ident: fld.fold_ident(f.node.ident), - mt: fold_mt(&f.node.mt, fld), - }, + fn fold_field(f: TypeField, fld: @ast_fold) -> TypeField { + ast::TypeField { + ident: fld.fold_ident(f.ident), + mt: fold_mt(&f.mt, fld), span: fld.new_span(f.span), } } @@ -787,7 +785,7 @@ fn noop_map_exprs(f: @fn(@expr) -> @expr, es: &[@expr]) -> ~[@expr] { es.map(|x| f(*x)) } -fn noop_id(i: node_id) -> node_id { return i; } +fn noop_id(i: NodeId) -> NodeId { return i; } fn noop_span(sp: span) -> span { return sp; } @@ -924,7 +922,7 @@ impl ast_fold for AstFoldFns { -> ~[@expr] { (self.map_exprs)(f, e) } - fn new_id(@self, node_id: ast::node_id) -> node_id { + fn new_id(@self, node_id: ast::NodeId) -> NodeId { (self.new_id)(node_id) } fn new_span(@self, span: span) -> span { diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index e31b0ccff80..c7c556c9728 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -39,7 +39,7 @@ pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { pub fn expr_is_simple_block(e: @ast::expr) -> bool { match e.node { ast::expr_block( - ast::Block { rules: ast::default_blk, _ } + ast::Block { rules: ast::DefaultBlock, _ } ) => true, _ => false } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 5cdf0ec1acc..1731a587a8e 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -11,7 +11,7 @@ //! The main parser interface -use ast::node_id; +use ast::NodeId; use ast; use codemap::{span, CodeMap, FileMap, FileSubstr}; use codemap; @@ -42,7 +42,7 @@ pub mod obsolete; // info about a parsing session. pub struct ParseSess { cm: @codemap::CodeMap, // better be the same as the one in the reader! - next_id: node_id, + next_id: NodeId, span_diagnostic: @span_handler, // better be the same as the one in the reader! /// Used to determine and report recursive mod inclusions included_mod_stack: ~[Path], @@ -202,7 +202,7 @@ pub fn parse_from_source_str<T>( } // return the next unused node id. -pub fn next_node_id(sess: @mut ParseSess) -> node_id { +pub fn next_node_id(sess: @mut ParseSess) -> NodeId { let rv = sess.next_id; sess.next_id += 1; // ID 0 is reserved for the crate and doesn't actually exist in the AST @@ -506,7 +506,7 @@ mod test { // check the contents of the tt manually: #[test] fn parse_fundecl () { // this test depends on the intern order of "fn" and "int", and on the - // assignment order of the node_ids. + // assignment order of the NodeIds. assert_eq!(string_to_item(@"fn a (b : int) { b; }"), Some( @ast::item{ident:str_to_ident("a"), @@ -566,7 +566,7 @@ mod test { span: sp(17,18)}], expr: None, id: 8, // fixme - rules: ast::default_blk, // no idea + rules: ast::DefaultBlock, // no idea span: sp(15,21), }), vis: ast::inherited, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index dc42b4bdb80..61dc6f47549 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -17,9 +17,9 @@ use ast::{RegionTyParamBound, TraitTyParamBound}; use ast::{provided, public, purity}; use ast::{_mod, add, arg, arm, Attribute, bind_by_ref, bind_infer}; use ast::{bitand, bitor, bitxor, Block}; -use ast::{blk_check_mode, box}; +use ast::{BlockCheckMode, box}; use ast::{Crate, CrateConfig, decl, decl_item}; -use ast::{decl_local, default_blk, deref, div, enum_def, explicit_self}; +use ast::{decl_local, DefaultBlock, deref, div, enum_def, explicit_self}; use ast::{expr, expr_, expr_addr_of, expr_match, expr_again}; use ast::{expr_assign, expr_assign_op, expr_binary, expr_block}; use ast::{expr_break, expr_call, expr_cast, expr_do_body}; @@ -39,7 +39,7 @@ use ast::{lit_bool, lit_float, lit_float_unsuffixed, lit_int}; use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, Local, m_const}; use ast::{m_imm, m_mutbl, mac_, mac_invoc_tt, matcher, match_nonterminal}; use ast::{match_seq, match_tok, method, mt, mul, mutability}; -use ast::{named_field, neg, node_id, noreturn, not, pat, pat_box, pat_enum}; +use ast::{named_field, neg, NodeId, noreturn, not, pat, pat_box, pat_enum}; use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct}; use ast::{pat_tup, pat_uniq, pat_wild, private}; use ast::{rem, required}; @@ -49,11 +49,11 @@ use ast::{struct_variant_kind, subtract}; use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value}; use ast::{token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok}; use ast::{tt_nonterminal, tuple_variant_kind, Ty, ty_, ty_bot, ty_box}; -use ast::{ty_field, ty_fixed_length_vec, ty_closure, ty_bare_fn}; -use ast::{ty_infer, ty_method}; +use ast::{TypeField, ty_fixed_length_vec, ty_closure, ty_bare_fn}; +use ast::{ty_infer, TypeMethod}; use ast::{ty_nil, TyParam, TyParamBound, ty_path, ty_ptr, ty_rptr}; use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, uniq}; -use ast::{unnamed_field, unsafe_blk, unsafe_fn, view_item}; +use ast::{unnamed_field, UnsafeBlock, unsafe_fn, view_item}; use ast::{view_item_, view_item_extern_mod, view_item_use}; use ast::{view_path, view_path_glob, view_path_list, view_path_simple}; use ast::visibility; @@ -645,7 +645,7 @@ impl Parser { pub fn abort_if_errors(&self) { self.sess.span_diagnostic.handler().abort_if_errors(); } - pub fn get_id(&self) -> node_id { next_node_id(self.sess) } + pub fn get_id(&self) -> NodeId { next_node_id(self.sess) } pub fn id_to_str(&self, id: ident) -> @str { get_ident_interner().get(id.name) @@ -837,7 +837,7 @@ impl Parser { debug!("parse_trait_methods(): parsing required method"); // NB: at the moment, visibility annotations on required // methods are ignored; this could change. - required(ty_method { + required(TypeMethod { ident: ident, attrs: attrs, purity: pur, @@ -889,20 +889,18 @@ impl Parser { // parse [mut/const/imm] ID : TY // now used only by obsolete record syntax parser... - pub fn parse_ty_field(&self) -> ty_field { + pub fn parse_ty_field(&self) -> TypeField { let lo = self.span.lo; let mutbl = self.parse_mutability(); let id = self.parse_ident(); self.expect(&token::COLON); let ty = ~self.parse_ty(false); - spanned( - lo, - ty.span.hi, - ast::ty_field_ { - ident: id, - mt: ast::mt { ty: ty, mutbl: mutbl }, - } - ) + let hi = ty.span.hi; + ast::TypeField { + ident: id, + mt: ast::mt { ty: ty, mutbl: mutbl }, + span: mk_sp(lo, hi), + } } // parse optional return type [ -> TY ] in function decl @@ -1614,7 +1612,7 @@ impl Parser { } } else if *self.token == token::LBRACE { self.bump(); - let blk = self.parse_block_tail(lo, default_blk); + let blk = self.parse_block_tail(lo, DefaultBlock); return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); } else if token::is_bar(&*self.token) { @@ -1643,7 +1641,7 @@ impl Parser { } else if self.eat_keyword(keywords::Match) { return self.parse_match_expr(); } else if self.eat_keyword(keywords::Unsafe) { - return self.parse_block_expr(lo, unsafe_blk); + return self.parse_block_expr(lo, UnsafeBlock); } else if *self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); @@ -1779,7 +1777,7 @@ impl Parser { } // parse a block or unsafe block - pub fn parse_block_expr(&self, lo: BytePos, blk_mode: blk_check_mode) + pub fn parse_block_expr(&self, lo: BytePos, blk_mode: BlockCheckMode) -> @expr { self.expect(&token::LBRACE); let blk = self.parse_block_tail(lo, blk_mode); @@ -2308,7 +2306,7 @@ impl Parser { stmts: ~[], expr: Some(body), id: self.get_id(), - rules: default_blk, + rules: DefaultBlock, span: body.span, }; @@ -2474,7 +2472,7 @@ impl Parser { stmts: ~[], expr: Some(expr), id: self.get_id(), - rules: default_blk, + rules: DefaultBlock, span: expr.span, }; @@ -3093,7 +3091,7 @@ impl Parser { } self.expect(&token::LBRACE); - return self.parse_block_tail_(lo, default_blk, ~[]); + return self.parse_block_tail_(lo, DefaultBlock, ~[]); } // parse a block. Inner attrs are allowed. @@ -3109,19 +3107,19 @@ impl Parser { self.expect(&token::LBRACE); let (inner, next) = self.parse_inner_attrs_and_next(); - (inner, self.parse_block_tail_(lo, default_blk, next)) + (inner, self.parse_block_tail_(lo, DefaultBlock, next)) } // Precondition: already parsed the '{' or '#{' // I guess that also means "already parsed the 'impure'" if // necessary, and this should take a qualifier. // some blocks start with "#{"... - fn parse_block_tail(&self, lo: BytePos, s: blk_check_mode) -> Block { + fn parse_block_tail(&self, lo: BytePos, s: BlockCheckMode) -> Block { self.parse_block_tail_(lo, s, ~[]) } // parse the rest of a block expression or function body - fn parse_block_tail_(&self, lo: BytePos, s: blk_check_mode, + fn parse_block_tail_(&self, lo: BytePos, s: BlockCheckMode, first_item_attrs: ~[Attribute]) -> Block { let mut stmts = ~[]; let mut expr = None; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8e2c24cacfe..7083d6655f1 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -807,7 +807,7 @@ pub fn print_variant(s: @ps, v: &ast::variant) { } } -pub fn print_ty_method(s: @ps, m: &ast::ty_method) { +pub fn print_ty_method(s: @ps, m: &ast::TypeMethod) { hardbreak_if_not_bol(s); maybe_print_comment(s, m.span.lo); print_outer_attributes(s, m.attrs); @@ -948,8 +948,8 @@ pub fn print_possibly_embedded_block_(s: @ps, attrs: &[ast::Attribute], close_box: bool) { match blk.rules { - ast::unsafe_blk => word_space(s, "unsafe"), - ast::default_blk => () + ast::UnsafeBlock => word_space(s, "unsafe"), + ast::DefaultBlock => () } maybe_print_comment(s, blk.span.lo); let ann_node = node_block(s, blk); @@ -1272,7 +1272,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { // in the case of foo => expr if arm.body.view_items.is_empty() && arm.body.stmts.is_empty() && - arm.body.rules == ast::default_blk && + arm.body.rules == ast::DefaultBlock && arm.body.expr.is_some() { match arm.body.expr { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 7e86adfcb63..1d264bcc20e 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -71,7 +71,7 @@ pub fn generics_of_fn(fk: &fn_kind) -> Generics { } pub struct Visitor<E> { - visit_mod: @fn(&_mod, span, node_id, (E, vt<E>)), + visit_mod: @fn(&_mod, span, NodeId, (E, vt<E>)), visit_view_item: @fn(&view_item, (E, vt<E>)), visit_foreign_item: @fn(@foreign_item, (E, vt<E>)), visit_item: @fn(@item, (E, vt<E>)), @@ -85,10 +85,10 @@ pub struct Visitor<E> { visit_expr_post: @fn(@expr, (E, vt<E>)), visit_ty: @fn(&Ty, (E, vt<E>)), visit_generics: @fn(&Generics, (E, vt<E>)), - visit_fn: @fn(&fn_kind, &fn_decl, &Block, span, node_id, (E, vt<E>)), - visit_ty_method: @fn(&ty_method, (E, vt<E>)), + visit_fn: @fn(&fn_kind, &fn_decl, &Block, span, NodeId, (E, vt<E>)), + visit_ty_method: @fn(&TypeMethod, (E, vt<E>)), visit_trait_method: @fn(&trait_method, (E, vt<E>)), - visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, (E, vt<E>)), + visit_struct_def: @fn(@struct_def, ident, &Generics, NodeId, (E, vt<E>)), visit_struct_field: @fn(@struct_field, (E, vt<E>)), } @@ -119,12 +119,12 @@ pub fn default_visitor<E:Clone>() -> visitor<E> { } pub fn visit_crate<E:Clone>(c: &Crate, (e, v): (E, vt<E>)) { - (v.visit_mod)(&c.module, c.span, crate_node_id, (e, v)); + (v.visit_mod)(&c.module, c.span, CRATE_NODE_ID, (e, v)); } pub fn visit_mod<E:Clone>(m: &_mod, _sp: span, - _id: node_id, + _id: NodeId, (e, v): (E, vt<E>)) { for m.view_items.iter().advance |vi| { (v.visit_view_item)(vi, (e.clone(), v)); @@ -387,14 +387,14 @@ pub fn visit_method_helper<E:Clone>(m: &method, (e, v): (E, vt<E>)) { } pub fn visit_fn<E:Clone>(fk: &fn_kind, decl: &fn_decl, body: &Block, _sp: span, - _id: node_id, (e, v): (E, vt<E>)) { + _id: NodeId, (e, v): (E, vt<E>)) { visit_fn_decl(decl, (e.clone(), v)); let generics = generics_of_fn(fk); (v.visit_generics)(&generics, (e.clone(), v)); (v.visit_block)(body, (e, v)); } -pub fn visit_ty_method<E:Clone>(m: &ty_method, (e, v): (E, vt<E>)) { +pub fn visit_ty_method<E:Clone>(m: &TypeMethod, (e, v): (E, vt<E>)) { for m.decl.inputs.iter().advance |a| { (v.visit_ty)(&a.ty, (e.clone(), v)); } @@ -413,7 +413,7 @@ pub fn visit_struct_def<E:Clone>( sd: @struct_def, _nm: ast::ident, _generics: &Generics, - _id: node_id, + _id: NodeId, (e, v): (E, vt<E>) ) { for sd.fields.iter().advance |f| { @@ -579,7 +579,7 @@ pub fn visit_arm<E:Clone>(a: &arm, (e, v): (E, vt<E>)) { // calls the given functions on the nodes. pub struct SimpleVisitor { - visit_mod: @fn(&_mod, span, node_id), + visit_mod: @fn(&_mod, span, NodeId), visit_view_item: @fn(&view_item), visit_foreign_item: @fn(@foreign_item), visit_item: @fn(@item), @@ -593,10 +593,10 @@ pub struct SimpleVisitor { visit_expr_post: @fn(@expr), visit_ty: @fn(&Ty), visit_generics: @fn(&Generics), - visit_fn: @fn(&fn_kind, &fn_decl, &Block, span, node_id), - visit_ty_method: @fn(&ty_method), + visit_fn: @fn(&fn_kind, &fn_decl, &Block, span, NodeId), + visit_ty_method: @fn(&TypeMethod), visit_trait_method: @fn(&trait_method), - visit_struct_def: @fn(@struct_def, ident, &Generics, node_id), + visit_struct_def: @fn(@struct_def, ident, &Generics, NodeId), visit_struct_field: @fn(@struct_field), visit_struct_method: @fn(@method) } @@ -632,10 +632,10 @@ pub fn default_simple_visitor() -> @SimpleVisitor { pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { fn v_mod( - f: @fn(&_mod, span, node_id), + f: @fn(&_mod, span, NodeId), m: &_mod, sp: span, - id: node_id, + id: NodeId, (e, v): ((), vt<()>) ) { f(m, sp, id); @@ -688,7 +688,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(ty); visit_ty(ty, (e, v)); } - fn v_ty_method(f: @fn(&ty_method), ty: &ty_method, (e, v): ((), vt<()>)) { + fn v_ty_method(f: @fn(&TypeMethod), ty: &TypeMethod, (e, v): ((), vt<()>)) { f(ty); visit_ty_method(ty, (e, v)); } @@ -699,11 +699,11 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { visit_trait_method(m, (e, v)); } fn v_struct_def( - f: @fn(@struct_def, ident, &Generics, node_id), + f: @fn(@struct_def, ident, &Generics, NodeId), sd: @struct_def, nm: ident, generics: &Generics, - id: node_id, + id: NodeId, (e, v): ((), vt<()>) ) { f(sd, nm, generics, id); @@ -718,12 +718,12 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { visit_generics(ps, (e, v)); } fn v_fn( - f: @fn(&fn_kind, &fn_decl, &Block, span, node_id), + f: @fn(&fn_kind, &fn_decl, &Block, span, NodeId), fk: &fn_kind, decl: &fn_decl, body: &Block, sp: span, - id: node_id, + id: NodeId, (e, v): ((), vt<()>) ) { f(fk, decl, body, sp, id); |
