Remove #[derive(Show)]

This commit is contained in:
Vadim Petrochenkov 2015-10-18 19:03:42 +03:00
parent be91042913
commit 025cf75864
9 changed files with 19 additions and 17 deletions

View File

@ -9,18 +9,18 @@ applicable, common traits.
To see why, consider the following situation: To see why, consider the following situation:
* Crate `std` defines trait `Show`. * Crate `std` defines trait `Debug`.
* Crate `url` defines type `Url`, without implementing `Show`. * Crate `url` defines type `Url`, without implementing `Debug`.
* Crate `webapp` imports from both `std` and `url`, * Crate `webapp` imports from both `std` and `url`,
There is no way for `webapp` to add `Show` to `url`, since it defines neither. There is no way for `webapp` to add `Debug` to `url`, since it defines neither.
(Note: the newtype pattern can provide an efficient, but inconvenient (Note: the newtype pattern can provide an efficient, but inconvenient
workaround; see [newtype for views](../types/newtype.md)) workaround; see [newtype for views](../types/newtype.md))
The most important common traits to implement from `std` are: The most important common traits to implement from `std` are:
```rust ```rust
Clone, Show, Hash, Eq Clone, Debug, Hash, Eq
``` ```
#### When safe, derive or otherwise implement `Send` and `Share`. [FIXME] #### When safe, derive or otherwise implement `Send` and `Share`. [FIXME]

View File

@ -119,7 +119,7 @@ for (trait, supers, errs) in [('Clone', [], 1),
('PartialOrd', ['PartialEq'], 8), ('PartialOrd', ['PartialEq'], 8),
('Eq', ['PartialEq'], 1), ('Eq', ['PartialEq'], 1),
('Ord', ['Eq', 'PartialOrd', 'PartialEq'], 1), ('Ord', ['Eq', 'PartialOrd', 'PartialEq'], 1),
('Show', [], 1), ('Debug', [], 1),
('Hash', [], 1)]: ('Hash', [], 1)]:
traits[trait] = (ALL, supers, errs) traits[trait] = (ALL, supers, errs)

View File

@ -18,7 +18,7 @@ use ext::deriving::generic::ty::*;
use parse::token; use parse::token;
use ptr::P; use ptr::P;
pub fn expand_deriving_show(cx: &mut ExtCtxt, pub fn expand_deriving_debug(cx: &mut ExtCtxt,
span: Span, span: Span,
mitem: &MetaItem, mitem: &MetaItem,
item: &Annotatable, item: &Annotatable,

View File

@ -60,7 +60,7 @@ pub mod clone;
pub mod encodable; pub mod encodable;
pub mod decodable; pub mod decodable;
pub mod hash; pub mod hash;
pub mod show; pub mod debug;
pub mod default; pub mod default;
pub mod primitive; pub mod primitive;
@ -173,7 +173,7 @@ derive_traits! {
"PartialOrd" => partial_ord::expand_deriving_partial_ord, "PartialOrd" => partial_ord::expand_deriving_partial_ord,
"Ord" => ord::expand_deriving_ord, "Ord" => ord::expand_deriving_ord,
"Debug" => show::expand_deriving_show, "Debug" => debug::expand_deriving_debug,
"Default" => default::expand_deriving_default, "Default" => default::expand_deriving_default,
@ -184,7 +184,6 @@ derive_traits! {
"Copy" => bounds::expand_deriving_copy, "Copy" => bounds::expand_deriving_copy,
// deprecated // deprecated
"Show" => show::expand_deriving_show,
"Encodable" => encodable::expand_deriving_encodable, "Encodable" => encodable::expand_deriving_encodable,
"Decodable" => decodable::expand_deriving_decodable, "Decodable" => decodable::expand_deriving_decodable,
} }
@ -192,7 +191,6 @@ derive_traits! {
#[inline] // because `name` is a compile-time constant #[inline] // because `name` is a compile-time constant
fn warn_if_deprecated(ecx: &mut ExtCtxt, sp: Span, name: &str) { fn warn_if_deprecated(ecx: &mut ExtCtxt, sp: Span, name: &str) {
if let Some(replacement) = match name { if let Some(replacement) = match name {
"Show" => Some("Debug"),
"Encodable" => Some("RustcEncodable"), "Encodable" => Some("RustcEncodable"),
"Decodable" => Some("RustcDecodable"), "Decodable" => Some("RustcDecodable"),
_ => None, _ => None,

View File

@ -10,7 +10,7 @@
use std::cell::Cell; use std::cell::Cell;
#[derive(Show)] #[derive(Debug)]
struct B<'a> { struct B<'a> {
a: [Cell<Option<&'a B<'a>>>; 2] a: [Cell<Option<&'a B<'a>>>; 2]
} }

View File

@ -10,7 +10,7 @@
use std::mem; use std::mem;
#[derive(PartialEq, Show)] #[derive(PartialEq, Debug)]
enum Foo { enum Foo {
A(u32), A(u32),
Bar([u16; 4]), Bar([u16; 4]),

View File

@ -8,8 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[derive(Show)] #![feature(rustc_private)]
//~^ WARNING derive(Show) is deprecated
extern crate serialize;
#[derive(Encodable)]
//~^ WARNING derive(Encodable) is deprecated in favor of derive(RustcEncodable)
struct Test1; struct Test1;
fn main() { } fn main() { }

View File

@ -10,7 +10,7 @@
use std::cell::Cell; use std::cell::Cell;
#[derive(Show)] #[derive(Debug)]
struct C<'a> { struct C<'a> {
v: Vec<Cell<Option<&'a C<'a>>>>, v: Vec<Cell<Option<&'a C<'a>>>>,
} }

View File

@ -10,12 +10,12 @@
use std::cell::Cell; use std::cell::Cell;
#[derive(Show)] #[derive(Debug)]
struct Refs<'a> { struct Refs<'a> {
v: Vec<Cell<Option<&'a C<'a>>>>, v: Vec<Cell<Option<&'a C<'a>>>>,
} }
#[derive(Show)] #[derive(Debug)]
struct C<'a> { struct C<'a> {
refs: Refs<'a>, refs: Refs<'a>,
} }