Skip to content

Commit 999e7ef

Browse files
committed
syntax: make old #[deriving_foo] attribute obsolete
1 parent e2abecd commit 999e7ef

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

src/libsyntax/ext/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ pub fn syntax_expander_table() -> SyntaxEnv {
153153
ext::deriving::expand_meta_deriving)));
154154
syntax_expanders.insert(@~"deriving_eq",
155155
@SE(ItemDecorator(
156-
ext::deriving::eq::expand_deriving_eq)));
156+
ext::deriving::eq::expand_deriving_obsolete)));
157157
syntax_expanders.insert(@~"deriving_iter_bytes",
158158
@SE(ItemDecorator(
159-
ext::deriving::iter_bytes::expand_deriving_iter_bytes)));
159+
ext::deriving::iter_bytes::expand_deriving_obsolete)));
160160
syntax_expanders.insert(@~"deriving_clone",
161161
@SE(ItemDecorator(
162-
ext::deriving::clone::expand_deriving_clone)));
162+
ext::deriving::clone::expand_deriving_obsolete)));
163163

164164
// Quasi-quoting expanders
165165
syntax_expanders.insert(@~"quote_tokens",

src/libsyntax/ext/deriving/clone.rs

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ pub fn expand_deriving_clone(cx: @ext_ctxt,
3939
expand_deriving_clone_enum_def)
4040
}
4141

42+
pub fn expand_deriving_obsolete(cx: @ext_ctxt,
43+
span: span,
44+
_mitem: @meta_item,
45+
in_items: ~[@item])
46+
-> ~[@item] {
47+
cx.span_err(span, ~"`#[deriving_clone]` is obsolete; use `#[deriving(Clone)]` instead");
48+
in_items
49+
}
50+
4251
fn create_derived_clone_impl(cx: @ext_ctxt,
4352
span: span,
4453
type_ident: ident,

src/libsyntax/ext/deriving/eq.rs

+9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ pub fn expand_deriving_eq(cx: @ext_ctxt,
5353
expand_deriving_eq_enum_def)
5454
}
5555

56+
pub fn expand_deriving_obsolete(cx: @ext_ctxt,
57+
span: span,
58+
_mitem: @meta_item,
59+
in_items: ~[@item])
60+
-> ~[@item] {
61+
cx.span_err(span, ~"`#[deriving_eq]` is obsolete; use `#[deriving(Eq)]` instead");
62+
in_items
63+
}
64+
5665
/// Creates a method from the given expression, the signature of which
5766
/// conforms to the `eq` or `ne` method.
5867
fn create_eq_method(cx: @ext_ctxt,

src/libsyntax/ext/deriving/iter_bytes.rs

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ pub fn expand_deriving_iter_bytes(cx: @ext_ctxt,
3939
expand_deriving_iter_bytes_enum_def)
4040
}
4141

42+
pub fn expand_deriving_obsolete(cx: @ext_ctxt,
43+
span: span,
44+
_mitem: @meta_item,
45+
in_items: ~[@item])
46+
-> ~[@item] {
47+
cx.span_err(span, ~"`#[deriving_iter_bytes]` is obsolete; use `#[deriving(IterBytes)]` \
48+
instead");
49+
in_items
50+
}
51+
4252
fn create_derived_iter_bytes_impl(cx: @ext_ctxt,
4353
span: span,
4454
type_ident: ident,
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 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+
#[deriving_clone] //~ ERROR `#[deriving_clone]` is obsolete; use `#[deriving(Clone)]` instead
12+
#[deriving_eq] //~ ERROR `#[deriving_eq]` is obsolete; use `#[deriving(Eq)]` instead
13+
#[deriving_iter_bytes]
14+
//~^ ERROR `#[deriving_iter_bytes]` is obsolete; use `#[deriving(IterBytes)]` instead
15+
struct Foo;
16+
17+
pub fn main() { }

0 commit comments

Comments
 (0)