Skip to content

Commit b89afe2

Browse files
committed
Update docs and tests for #[deriving(Show)].
1 parent 6a8b3ae commit b89afe2

7 files changed

+106
-4
lines changed

src/doc/rust.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,13 +1969,14 @@ impl<T: Eq> Eq for Foo<T> {
19691969
Supported traits for `deriving` are:
19701970

19711971
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
1972-
* Serialization: `Encodable`, `Decodable`. These require `extra`.
1972+
* Serialization: `Encodable`, `Decodable`. These require `serialize`.
19731973
* `Clone` and `DeepClone`, to perform (deep) copies.
19741974
* `IterBytes`, to iterate over the bytes in a data type.
19751975
* `Rand`, to create a random instance of a data type.
19761976
* `Default`, to create an empty instance of a data type.
19771977
* `Zero`, to create an zero instance of a numeric data type.
1978-
* `FromPrimitive`, to create an instance from a numeric primitve.
1978+
* `FromPrimitive`, to create an instance from a numeric primitive.
1979+
* `Show`, to format a value using the `{}` formatter.
19791980

19801981
### Stability
19811982
One can indicate the stability of an API using the following attributes:

src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ enum ABC { A, B, C }
25232523

25242524
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
25252525
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`,
2526-
`IterBytes`, `Rand`, `Default`, `Zero`, and `ToStr`.
2526+
`IterBytes`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
25272527

25282528
# Crates and the module system
25292529

src/etc/generate-deriving-span-tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def write_file(name, string):
118118
for (trait, supers, errs) in [('Rand', [], 1),
119119
('Clone', [], 1), ('DeepClone', ['Clone'], 1),
120120
('Eq', [], 2), ('Ord', [], 8),
121-
('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1)]:
121+
('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1),
122+
('Show', [], 1)]:
122123
traits[trait] = (ALL, supers, errs)
123124

124125
for (trait, (types, super_traits, error_count)) in traits.items():
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
12+
13+
#[feature(struct_variant)];
14+
extern mod extra;
15+
16+
17+
struct Error;
18+
19+
#[deriving(Show)]
20+
enum Enum {
21+
A {
22+
x: Error //~ ERROR
23+
}
24+
}
25+
26+
fn main() {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
12+
13+
#[feature(struct_variant)];
14+
extern mod extra;
15+
16+
17+
struct Error;
18+
19+
#[deriving(Show)]
20+
enum Enum {
21+
A(
22+
Error //~ ERROR
23+
)
24+
}
25+
26+
fn main() {}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
12+
13+
#[feature(struct_variant)];
14+
extern mod extra;
15+
16+
17+
struct Error;
18+
19+
#[deriving(Show)]
20+
struct Struct {
21+
x: Error //~ ERROR
22+
}
23+
24+
fn main() {}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
12+
13+
#[feature(struct_variant)];
14+
extern mod extra;
15+
16+
17+
struct Error;
18+
19+
#[deriving(Show)]
20+
struct Struct(
21+
Error //~ ERROR
22+
);
23+
24+
fn main() {}

0 commit comments

Comments
 (0)