Skip to content

Commit 5dc5efe

Browse files
committed
syntax: deprecate #[auto_{en,de}code] in favour of #[deriving({En,De}codable)].
Replace all instances of #[auto_*code] with the appropriate #[deriving] attribute and remove the majority of the actual code, leaving stubs to refer the user to the new syntax.
1 parent 6a9c3bd commit 5dc5efe

19 files changed

+752
-1798
lines changed

src/librustc/middle/freevars.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use syntax::{ast, ast_util, visit};
2020

2121
// A vector of defs representing the free variables referred to in a function.
2222
// (The def_upvar will already have been stripped).
23-
#[auto_encode]
24-
#[auto_decode]
23+
#[deriving(Encodable, Decodable)]
2524
pub struct freevar_entry {
2625
def: ast::def, //< The variable being accessed free.
2726
span: span //< First span where it is accessed (there can be multiple)

src/librustc/middle/moves.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,14 @@ use syntax::visit::vt;
221221
use syntax::print::pprust;
222222
use syntax::codemap::span;
223223

224-
#[auto_encode]
225-
#[auto_decode]
224+
#[deriving(Encodable, Decodable)]
226225
pub enum CaptureMode {
227226
CapCopy, // Copy the value into the closure.
228227
CapMove, // Move the value into the closure.
229228
CapRef, // Reference directly from parent stack frame (used by `&fn()`).
230229
}
231230

232-
#[auto_encode]
233-
#[auto_decode]
231+
#[deriving(Encodable, Decodable)]
234232
pub struct CaptureVar {
235233
def: def, // Variable being accessed free
236234
span: span, // Location of an access to this variable

src/librustc/middle/ty.rs

+12-32
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,15 @@ pub struct mt {
9696
mutbl: ast::mutability,
9797
}
9898

99-
#[auto_encode]
100-
#[auto_decode]
101-
#[deriving(Eq)]
99+
#[deriving(Eq, Encodable, Decodable)]
102100
pub enum vstore {
103101
vstore_fixed(uint),
104102
vstore_uniq,
105103
vstore_box,
106104
vstore_slice(Region)
107105
}
108106

109-
#[auto_encode]
110-
#[auto_decode]
111-
#[deriving(Eq, IterBytes)]
107+
#[deriving(Eq, IterBytes, Encodable, Decodable)]
112108
pub enum TraitStore {
113109
BoxTraitStore, // @Trait
114110
UniqTraitStore, // ~Trait
@@ -117,9 +113,7 @@ pub enum TraitStore {
117113

118114
// XXX: This should probably go away at some point. Maybe after destructors
119115
// do?
120-
#[auto_encode]
121-
#[auto_decode]
122-
#[deriving(Eq)]
116+
#[deriving(Eq, Encodable, Decodable)]
123117
pub enum SelfMode {
124118
ByCopy,
125119
ByRef,
@@ -197,27 +191,22 @@ pub enum ast_ty_to_ty_cache_entry {
197191

198192
pub type opt_region_variance = Option<region_variance>;
199193

200-
#[auto_encode]
201-
#[auto_decode]
202-
#[deriving(Eq)]
194+
#[deriving(Eq, Decodable, Encodable)]
203195
pub enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
204196

205-
#[auto_encode]
206-
#[auto_decode]
197+
#[deriving(Decodable, Encodable)]
207198
pub enum AutoAdjustment {
208199
AutoAddEnv(ty::Region, ast::Sigil),
209200
AutoDerefRef(AutoDerefRef)
210201
}
211202

212-
#[auto_encode]
213-
#[auto_decode]
203+
#[deriving(Decodable, Encodable)]
214204
pub struct AutoDerefRef {
215205
autoderefs: uint,
216206
autoref: Option<AutoRef>
217207
}
218208

219-
#[auto_encode]
220-
#[auto_decode]
209+
#[deriving(Decodable, Encodable)]
221210
pub enum AutoRef {
222211
/// Convert from T to &T
223212
AutoPtr(Region, ast::mutability),
@@ -453,9 +442,7 @@ pub struct param_ty {
453442
}
454443

455444
/// Representation of regions:
456-
#[auto_encode]
457-
#[auto_decode]
458-
#[deriving(Eq, IterBytes)]
445+
#[deriving(Eq, IterBytes, Encodable, Decodable)]
459446
pub enum Region {
460447
/// Bound regions are found (primarily) in function types. They indicate
461448
/// region parameters that have yet to be replaced with actual regions
@@ -501,17 +488,13 @@ pub impl Region {
501488
}
502489
}
503490

504-
#[auto_encode]
505-
#[auto_decode]
506-
#[deriving(Eq, IterBytes)]
491+
#[deriving(Eq, IterBytes, Encodable, Decodable)]
507492
pub struct FreeRegion {
508493
scope_id: node_id,
509494
bound_region: bound_region
510495
}
511496

512-
#[auto_encode]
513-
#[auto_decode]
514-
#[deriving(Eq, IterBytes)]
497+
#[deriving(Eq, IterBytes, Encodable, Decodable)]
515498
pub enum bound_region {
516499
/// The self region for structs, impls (&T in a type defn or &'self T)
517500
br_self,
@@ -742,9 +725,7 @@ pub struct IntVid(uint);
742725
#[deriving(Eq)]
743726
pub struct FloatVid(uint);
744727

745-
#[deriving(Eq)]
746-
#[auto_encode]
747-
#[auto_decode]
728+
#[deriving(Eq, Encodable, Decodable)]
748729
pub struct RegionVid {
749730
id: uint
750731
}
@@ -777,8 +758,7 @@ impl to_bytes::IterBytes for InferTy {
777758
}
778759
}
779760

780-
#[auto_encode]
781-
#[auto_decode]
761+
#[deriving(Encodable, Decodable)]
782762
pub enum InferRegion {
783763
ReVar(RegionVid),
784764
ReSkolemized(uint, bound_region)

src/librustc/middle/typeck/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ pub mod infer;
7373
pub mod collect;
7474
pub mod coherence;
7575

76-
#[auto_encode]
77-
#[auto_decode]
76+
#[deriving(Encodable, Decodable)]
7877
pub enum method_origin {
7978
// supertrait method invoked on "self" inside a default method
8079
// first field is supertrait ID;
@@ -98,8 +97,7 @@ pub enum method_origin {
9897

9998
// details for a method invoked with a receiver whose type is a type parameter
10099
// with a bounded trait.
101-
#[auto_encode]
102-
#[auto_decode]
100+
#[deriving(Encodable, Decodable)]
103101
pub struct method_param {
104102
// the trait containing the method to be invoked
105103
trait_id: ast::def_id,

src/libstd/json.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1331,26 +1331,20 @@ mod tests {
13311331

13321332
use std::serialize::Decodable;
13331333

1334-
#[auto_encode]
1335-
#[auto_decode]
1336-
#[deriving(Eq)]
1334+
#[deriving(Eq, Encodable, Decodable)]
13371335
enum Animal {
13381336
Dog,
13391337
Frog(~str, int)
13401338
}
13411339

1342-
#[auto_encode]
1343-
#[auto_decode]
1344-
#[deriving(Eq)]
1340+
#[deriving(Eq, Encodable, Decodable)]
13451341
struct Inner {
13461342
a: (),
13471343
b: uint,
13481344
c: ~[~str],
13491345
}
13501346

1351-
#[auto_encode]
1352-
#[auto_decode]
1353-
#[deriving(Eq)]
1347+
#[deriving(Eq, Encodable, Decodable)]
13541348
struct Outer {
13551349
inner: ~[Inner],
13561350
}

src/libstd/time.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ pub mod rustrt {
2929
}
3030

3131
/// A record specifying a time value in seconds and nanoseconds.
32-
#[auto_encode]
33-
#[auto_decode]
34-
#[deriving(Eq)]
32+
#[deriving(Eq, Encodable, Decodable)]
3533
pub struct Timespec { sec: i64, nsec: i32 }
3634

3735
/*
@@ -100,9 +98,7 @@ pub fn tzset() {
10098
}
10199
}
102100

103-
#[auto_encode]
104-
#[auto_decode]
105-
#[deriving(Eq)]
101+
#[deriving(Eq, Encodable, Decodable)]
106102
pub struct Tm {
107103
tm_sec: i32, // seconds after the minute ~[0-60]
108104
tm_min: i32, // minutes after the hour ~[0-59]

src/libstd/workcache.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ use core::util::replace;
9292
*
9393
*/
9494

95-
#[deriving(Eq)]
96-
#[auto_encode]
97-
#[auto_decode]
95+
#[deriving(Eq, Encodable, Decodable)]
9896
struct WorkKey {
9997
kind: ~str,
10098
name: ~str

src/libsyntax/abi.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ enum AbiArchitecture {
5858
Archs(u32) // Multiple architectures (bitset)
5959
}
6060

61-
#[auto_encode]
62-
#[auto_decode]
63-
#[deriving(Eq)]
61+
#[deriving(Eq, Encodable, Decodable)]
6462
pub struct AbiSet {
6563
priv bits: u32 // each bit represents one of the abis below
6664
}

0 commit comments

Comments
 (0)