Skip to content

Commit

Permalink
Auto merge of #31400 - durka:civilized-deriving, r=alexcrichton
Browse files Browse the repository at this point in the history
You can `#[derive(FromPrimitive)]`, but it [fails later in the compile](https://play.rust-lang.org/?gist=82cb8ad2fac49e3fe472&version=stable) due to hardcoding `std::num::FromPrimitive` which [was removed](eeb9488) (for some reason Github doesn't show `FromPrimitive` in the diff, but `git show` does).

Anyway, this PR removes the code. I didn't mark it as a breaking change, even though [this extremely contrived code using highly unstable features](https://play.rust-lang.org/?gist=1e1b1bbff962837b228a&version=nightly) is broken by it -- should I?
  • Loading branch information
bors committed Feb 5, 2016
2 parents 38dfb96 + 45e716e commit 98422e8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 168 deletions.
3 changes: 0 additions & 3 deletions src/libsyntax_ext/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub mod decodable;
pub mod hash;
pub mod debug;
pub mod default;
pub mod primitive;

#[path="cmp/partial_eq.rs"]
pub mod partial_eq;
Expand Down Expand Up @@ -178,8 +177,6 @@ derive_traits! {

"Default" => default::expand_deriving_default,

"FromPrimitive" => primitive::expand_deriving_from_primitive,

"Send" => bounds::expand_deriving_unsafe_bound,
"Sync" => bounds::expand_deriving_unsafe_bound,
"Copy" => bounds::expand_deriving_copy,
Expand Down
142 changes: 0 additions & 142 deletions src/libsyntax_ext/deriving/primitive.rs

This file was deleted.

27 changes: 4 additions & 23 deletions src/test/compile-fail/deriving-primitive.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,27 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::num::FromPrimitive;
use std::isize;
#[derive(FromPrimitive)] //~ERROR `#[derive]` for custom traits is not stable
enum Foo {}

#[derive(FromPrimitive)]
struct A { x: isize }
//~^^ ERROR `FromPrimitive` cannot be derived for structs
//~^^^ ERROR `FromPrimitive` cannot be derived for structs
fn main() {}

#[derive(FromPrimitive)]
struct B(isize);
//~^^ ERROR `FromPrimitive` cannot be derived for structs
//~^^^ ERROR `FromPrimitive` cannot be derived for structs

#[derive(FromPrimitive)]
enum C { Foo(isize), Bar(usize) }
//~^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants
//~^^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants

#[derive(FromPrimitive)]
enum D { Baz { x: isize } }
//~^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants
//~^^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants

pub fn main() {}

0 comments on commit 98422e8

Please sign in to comment.