diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-08-16 06:31:58 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-08-24 05:34:58 -0400 |
| commit | afba69461a7a092753e1458b77fafcb30e016499 (patch) | |
| tree | 736c51dfc2fa63e6569437d028c702ab94978603 /src/libsyntax/ast.rs | |
| parent | 63ba780fd7ab506bfd0f92d34a39172b412cfbe1 (diff) | |
| download | rust-afba69461a7a092753e1458b77fafcb30e016499.tar.gz rust-afba69461a7a092753e1458b77fafcb30e016499.zip | |
move def-id to rustc crate
Diffstat (limited to 'src/libsyntax/ast.rs')
| -rw-r--r-- | src/libsyntax/ast.rs | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index cd0705f543b..66faa1227e6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -65,7 +65,6 @@ use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; use print::pprust; use ptr::P; -use std::cell::Cell; use std::fmt; use std::rc::Rc; use serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -371,37 +370,7 @@ pub type CrateNum = u32; pub type NodeId = u32; -#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable, - RustcDecodable, Hash, Copy)] -pub struct DefId { - pub krate: CrateNum, - pub node: NodeId, -} - -fn default_def_id_debug(_: DefId, _: &mut fmt::Formatter) -> fmt::Result { Ok(()) } - -thread_local!(pub static DEF_ID_DEBUG: Cell<fn(DefId, &mut fmt::Formatter) -> fmt::Result> = - Cell::new(default_def_id_debug)); - -impl fmt::Debug for DefId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "DefId {{ krate: {}, node: {} }}", - self.krate, self.node)); - DEF_ID_DEBUG.with(|def_id_debug| def_id_debug.get()(*self, f)) - } -} - -impl DefId { - /// Read the node id, asserting that this def-id is krate-local. - pub fn local_id(&self) -> NodeId { - assert_eq!(self.krate, LOCAL_CRATE); - self.node - } -} - -/// Item definitions in the currently-compiled crate would have the CrateNum -/// LOCAL_CRATE in their DefId. -pub const LOCAL_CRATE: CrateNum = 0; +/// Node id used to represent the root of the crate. pub const CRATE_NODE_ID: NodeId = 0; /// When parsing and doing expansions, we initially give all AST nodes this AST |
