diff --git a/src/doc/rust.md b/src/doc/rust.md index 21c2e5eefecb..bae8f562af52 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1969,13 +1969,14 @@ impl Eq for Foo { Supported traits for `deriving` are: * Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`. -* Serialization: `Encodable`, `Decodable`. These require `extra`. +* Serialization: `Encodable`, `Decodable`. These require `serialize`. * `Clone` and `DeepClone`, to perform (deep) copies. * `IterBytes`, to iterate over the bytes in a data type. * `Rand`, to create a random instance of a data type. * `Default`, to create an empty instance of a data type. * `Zero`, to create an zero instance of a numeric data type. -* `FromPrimitive`, to create an instance from a numeric primitve. +* `FromPrimitive`, to create an instance from a numeric primitive. +* `Show`, to format a value using the `{}` formatter. ### Stability One can indicate the stability of an API using the following attributes: diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 5d60b90a8f36..a5426c20619e 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2523,7 +2523,7 @@ enum ABC { A, B, C } The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`, -`IterBytes`, `Rand`, `Default`, `Zero`, and `ToStr`. +`IterBytes`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`. # Crates and the module system diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index a3f057c04b0a..7acaa761bb21 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -118,7 +118,8 @@ traits = { for (trait, supers, errs) in [('Rand', [], 1), ('Clone', [], 1), ('DeepClone', ['Clone'], 1), ('Eq', [], 2), ('Ord', [], 8), - ('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1)]: + ('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1), + ('Show', [], 1)]: traits[trait] = (ALL, supers, errs) for (trait, (types, super_traits, error_count)) in traits.items(): diff --git a/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs new file mode 100644 index 000000000000..582c95b746b7 --- /dev/null +++ b/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' + +#[feature(struct_variant)]; +extern mod extra; + + +struct Error; + +#[deriving(Show)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/compile-fail/deriving-span-Show-enum.rs b/src/test/compile-fail/deriving-span-Show-enum.rs new file mode 100644 index 000000000000..92efe01fa386 --- /dev/null +++ b/src/test/compile-fail/deriving-span-Show-enum.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' + +#[feature(struct_variant)]; +extern mod extra; + + +struct Error; + +#[deriving(Show)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/compile-fail/deriving-span-Show-struct.rs b/src/test/compile-fail/deriving-span-Show-struct.rs new file mode 100644 index 000000000000..7eff82f9d13f --- /dev/null +++ b/src/test/compile-fail/deriving-span-Show-struct.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' + +#[feature(struct_variant)]; +extern mod extra; + + +struct Error; + +#[deriving(Show)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/compile-fail/deriving-span-Show-tuple-struct.rs b/src/test/compile-fail/deriving-span-Show-tuple-struct.rs new file mode 100644 index 000000000000..600a0400350d --- /dev/null +++ b/src/test/compile-fail/deriving-span-Show-tuple-struct.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' + +#[feature(struct_variant)]; +extern mod extra; + + +struct Error; + +#[deriving(Show)] +struct Struct( + Error //~ ERROR +); + +fn main() {}