libsyntax: use #[deriving(Copy)]
This commit is contained in:
parent
a77e8a63d5
commit
86f8c127dd
19 changed files with 77 additions and 216 deletions
|
@ -31,19 +31,15 @@ pub trait Pos {
|
|||
|
||||
/// A byte offset. Keep this small (currently 32-bits), as AST contains
|
||||
/// a lot of them.
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, PartialOrd, Show)]
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Show)]
|
||||
pub struct BytePos(pub u32);
|
||||
|
||||
impl Copy for BytePos {}
|
||||
|
||||
/// A character offset. Because of multibyte utf8 characters, a byte offset
|
||||
/// is not equivalent to a character offset. The CodeMap will convert BytePos
|
||||
/// values to CharPos values as necessary.
|
||||
#[deriving(PartialEq, Hash, PartialOrd, Show)]
|
||||
#[deriving(Copy, PartialEq, Hash, PartialOrd, Show)]
|
||||
pub struct CharPos(pub uint);
|
||||
|
||||
impl Copy for CharPos {}
|
||||
|
||||
// FIXME: Lots of boilerplate in these impls, but so far my attempts to fix
|
||||
// have been unsuccessful
|
||||
|
||||
|
@ -121,7 +117,7 @@ impl Sub<CharPos, CharPos> for CharPos {
|
|||
/// are *absolute* positions from the beginning of the codemap, not positions
|
||||
/// relative to FileMaps. Methods on the CodeMap can be used to relate spans back
|
||||
/// to the original source.
|
||||
#[deriving(Clone, Show, Hash)]
|
||||
#[deriving(Clone, Copy, Show, Hash)]
|
||||
pub struct Span {
|
||||
pub lo: BytePos,
|
||||
pub hi: BytePos,
|
||||
|
@ -130,18 +126,14 @@ pub struct Span {
|
|||
pub expn_id: ExpnId
|
||||
}
|
||||
|
||||
impl Copy for Span {}
|
||||
|
||||
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
|
||||
pub struct Spanned<T> {
|
||||
pub node: T,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl<T:Copy> Copy for Spanned<T> {}
|
||||
|
||||
impl PartialEq for Span {
|
||||
fn eq(&self, other: &Span) -> bool {
|
||||
return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
|
||||
|
@ -219,7 +211,7 @@ pub struct FileMapAndLine { pub fm: Rc<FileMap>, pub line: uint }
|
|||
pub struct FileMapAndBytePos { pub fm: Rc<FileMap>, pub pos: BytePos }
|
||||
|
||||
/// The syntax with which a macro was invoked.
|
||||
#[deriving(Clone, Hash, Show)]
|
||||
#[deriving(Clone, Copy, Hash, Show)]
|
||||
pub enum MacroFormat {
|
||||
/// e.g. #[deriving(...)] <item>
|
||||
MacroAttribute,
|
||||
|
@ -227,8 +219,6 @@ pub enum MacroFormat {
|
|||
MacroBang
|
||||
}
|
||||
|
||||
impl Copy for MacroFormat {}
|
||||
|
||||
#[deriving(Clone, Hash, Show)]
|
||||
pub struct NameAndSpan {
|
||||
/// The name of the macro that was invoked to create the thing
|
||||
|
@ -264,11 +254,9 @@ pub struct ExpnInfo {
|
|||
pub callee: NameAndSpan
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)]
|
||||
#[deriving(Copy, PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)]
|
||||
pub struct ExpnId(u32);
|
||||
|
||||
impl Copy for ExpnId {}
|
||||
|
||||
pub const NO_EXPANSION: ExpnId = ExpnId(-1);
|
||||
|
||||
impl ExpnId {
|
||||
|
@ -290,6 +278,7 @@ pub struct FileLines {
|
|||
}
|
||||
|
||||
/// Identifies an offset of a multi-byte character in a FileMap
|
||||
#[deriving(Copy)]
|
||||
pub struct MultiByteChar {
|
||||
/// The absolute offset of the character in the CodeMap
|
||||
pub pos: BytePos,
|
||||
|
@ -297,8 +286,6 @@ pub struct MultiByteChar {
|
|||
pub bytes: uint,
|
||||
}
|
||||
|
||||
impl Copy for MultiByteChar {}
|
||||
|
||||
/// A single source in the CodeMap
|
||||
pub struct FileMap {
|
||||
/// The name of the file that the source came from, source that doesn't
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue