Skip to content

Commit

Permalink
syntax: make old #[deriving_foo] attribute obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
apasel422 committed Mar 22, 2013
1 parent e2abecd commit 999e7ef
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ pub fn syntax_expander_table() -> SyntaxEnv {
ext::deriving::expand_meta_deriving)));
syntax_expanders.insert(@~"deriving_eq",
@SE(ItemDecorator(
ext::deriving::eq::expand_deriving_eq)));
ext::deriving::eq::expand_deriving_obsolete)));
syntax_expanders.insert(@~"deriving_iter_bytes",
@SE(ItemDecorator(
ext::deriving::iter_bytes::expand_deriving_iter_bytes)));
ext::deriving::iter_bytes::expand_deriving_obsolete)));
syntax_expanders.insert(@~"deriving_clone",
@SE(ItemDecorator(
ext::deriving::clone::expand_deriving_clone)));
ext::deriving::clone::expand_deriving_obsolete)));

// Quasi-quoting expanders
syntax_expanders.insert(@~"quote_tokens",
Expand Down
9 changes: 9 additions & 0 deletions src/libsyntax/ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ pub fn expand_deriving_clone(cx: @ext_ctxt,
expand_deriving_clone_enum_def)
}

pub fn expand_deriving_obsolete(cx: @ext_ctxt,
span: span,
_mitem: @meta_item,
in_items: ~[@item])
-> ~[@item] {
cx.span_err(span, ~"`#[deriving_clone]` is obsolete; use `#[deriving(Clone)]` instead");
in_items
}

fn create_derived_clone_impl(cx: @ext_ctxt,
span: span,
type_ident: ident,
Expand Down
9 changes: 9 additions & 0 deletions src/libsyntax/ext/deriving/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ pub fn expand_deriving_eq(cx: @ext_ctxt,
expand_deriving_eq_enum_def)
}

pub fn expand_deriving_obsolete(cx: @ext_ctxt,
span: span,
_mitem: @meta_item,
in_items: ~[@item])
-> ~[@item] {
cx.span_err(span, ~"`#[deriving_eq]` is obsolete; use `#[deriving(Eq)]` instead");
in_items
}

/// Creates a method from the given expression, the signature of which
/// conforms to the `eq` or `ne` method.
fn create_eq_method(cx: @ext_ctxt,
Expand Down
10 changes: 10 additions & 0 deletions src/libsyntax/ext/deriving/iter_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ pub fn expand_deriving_iter_bytes(cx: @ext_ctxt,
expand_deriving_iter_bytes_enum_def)
}

pub fn expand_deriving_obsolete(cx: @ext_ctxt,
span: span,
_mitem: @meta_item,
in_items: ~[@item])
-> ~[@item] {
cx.span_err(span, ~"`#[deriving_iter_bytes]` is obsolete; use `#[deriving(IterBytes)]` \
instead");
in_items
}

fn create_derived_iter_bytes_impl(cx: @ext_ctxt,
span: span,
type_ident: ident,
Expand Down
17 changes: 17 additions & 0 deletions src/test/compile-fail/deriving-obsolete.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[deriving_clone] //~ ERROR `#[deriving_clone]` is obsolete; use `#[deriving(Clone)]` instead
#[deriving_eq] //~ ERROR `#[deriving_eq]` is obsolete; use `#[deriving(Eq)]` instead
#[deriving_iter_bytes]
//~^ ERROR `#[deriving_iter_bytes]` is obsolete; use `#[deriving(IterBytes)]` instead
struct Foo;

pub fn main() { }

5 comments on commit 999e7ef

@bors
Copy link
Contributor

@bors bors commented on 999e7ef Mar 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 999e7ef Mar 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging apasel422/rust/leibniz = 999e7ef into auto

@bors
Copy link
Contributor

@bors bors commented on 999e7ef Mar 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apasel422/rust/leibniz = 999e7ef merged ok, testing candidate = 0597647

@bors
Copy link
Contributor

@bors bors commented on 999e7ef Mar 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 999e7ef Mar 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 0597647

Please sign in to comment.