Navigation Menu

Skip to content

Commit

Permalink
librustdoc: use #[deriving(Copy)]
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Dec 19, 2014
1 parent fa0383f commit 4c00756
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
12 changes: 3 additions & 9 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -1188,7 +1188,7 @@ pub enum Type {
PolyTraitRef(Vec<TyParamBound>),
}

#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)]
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash)]
pub enum PrimitiveType {
Int, I8, I16, I32, I64,
Uint, U8, U16, U32, U64,
Expand All @@ -1200,9 +1200,7 @@ pub enum PrimitiveType {
PrimitiveTuple,
}

impl Copy for PrimitiveType {}

#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, Copy, Encodable, Decodable)]
pub enum TypeKind {
TypeEnum,
TypeFunction,
Expand All @@ -1215,8 +1213,6 @@ pub enum TypeKind {
TypeTypedef,
}

impl Copy for TypeKind {}

impl PrimitiveType {
fn from_str(s: &str) -> Option<PrimitiveType> {
match s.as_slice() {
Expand Down Expand Up @@ -1873,14 +1869,12 @@ impl Clean<Item> for doctree::Constant {
}
}

#[deriving(Show, Clone, Encodable, Decodable, PartialEq)]
#[deriving(Copy, Show, Clone, Encodable, Decodable, PartialEq)]
pub enum Mutability {
Mutable,
Immutable,
}

impl Copy for Mutability {}

impl Clean<Mutability> for ast::Mutability {
fn clean(&self, _: &DocContext) -> Mutability {
match self {
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/doctree.rs
Expand Up @@ -70,7 +70,7 @@ impl Module {
}
}

#[deriving(Show, Clone, Encodable, Decodable)]
#[deriving(Copy, Show, Clone, Encodable, Decodable)]
pub enum StructType {
/// A normal struct
Plain,
Expand All @@ -82,8 +82,6 @@ pub enum StructType {
Unit
}

impl Copy for StructType {}

pub enum TypeBound {
RegionBound,
TraitBound(ast::TraitRef)
Expand Down
9 changes: 4 additions & 5 deletions src/librustdoc/html/format.rs
Expand Up @@ -29,15 +29,19 @@ use html::render::{cache, CURRENT_LOCATION_KEY};

/// Helper to render an optional visibility with a space after it (if the
/// visibility is preset)
#[deriving(Copy)]
pub struct VisSpace(pub Option<ast::Visibility>);
/// Similarly to VisSpace, this structure is used to render a function style with a
/// space after it.
#[deriving(Copy)]
pub struct UnsafetySpace(pub ast::Unsafety);
/// Wrapper struct for properly emitting a method declaration.
pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
/// Similar to VisSpace, but used for mutability
#[deriving(Copy)]
pub struct MutableSpace(pub clean::Mutability);
/// Similar to VisSpace, but used for mutability
#[deriving(Copy)]
pub struct RawMutableSpace(pub clean::Mutability);
/// Wrapper struct for properly emitting the stability level.
pub struct Stability<'a>(pub &'a Option<clean::Stability>);
Expand All @@ -48,11 +52,6 @@ pub struct WhereClause<'a>(pub &'a clean::Generics);
/// Wrapper struct for emitting type parameter bounds.
pub struct TyParamBounds<'a>(pub &'a [clean::TyParamBound]);

impl Copy for VisSpace {}
impl Copy for UnsafetySpace {}
impl Copy for MutableSpace {}
impl Copy for RawMutableSpace {}

impl VisSpace {
pub fn get(&self) -> Option<ast::Visibility> {
let VisSpace(v) = *self; v
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/html/item_type.rs
Expand Up @@ -19,7 +19,7 @@ use clean;
/// discriminants. JavaScript then is used to decode them into the original value.
/// Consequently, every change to this type should be synchronized to
/// the `itemTypes` mapping table in `static/main.js`.
#[deriving(PartialEq, Clone)]
#[deriving(Copy, PartialEq, Clone)]
pub enum ItemType {
Module = 0,
Struct = 1,
Expand All @@ -41,8 +41,6 @@ pub enum ItemType {
Constant = 18,
}

impl Copy for ItemType {}

impl ItemType {
pub fn from_item(item: &clean::Item) -> ItemType {
match item.inner {
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/html/render.rs
Expand Up @@ -225,13 +225,12 @@ struct Source<'a>(&'a str);
// Helper structs for rendering items/sidebars and carrying along contextual
// information

#[deriving(Copy)]
struct Item<'a> {
cx: &'a Context,
item: &'a clean::Item,
}

impl<'a> Copy for Item<'a> {}

struct Sidebar<'a> { cx: &'a Context, item: &'a clean::Item, }

/// Struct representing one entry in the JS search index. These are all emitted
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/stability_summary.rs
Expand Up @@ -27,6 +27,7 @@ use html::render::cache;

#[deriving(Zero, Encodable, Decodable, PartialEq, Eq)]
/// The counts for each stability level.
#[deriving(Copy)]
pub struct Counts {
pub deprecated: uint,
pub experimental: uint,
Expand All @@ -39,8 +40,6 @@ pub struct Counts {
pub unmarked: uint,
}

impl Copy for Counts {}

impl Add<Counts, Counts> for Counts {
fn add(self, other: Counts) -> Counts {
Counts {
Expand Down

0 comments on commit 4c00756

Please sign in to comment.