Skip to content

Commit 98422e8

Browse files
committed
Auto merge of #31400 - durka:civilized-deriving, r=alexcrichton
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?
2 parents 38dfb96 + 45e716e commit 98422e8

File tree

3 files changed

+4
-168
lines changed

3 files changed

+4
-168
lines changed

src/libsyntax_ext/deriving/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ pub mod decodable;
6363
pub mod hash;
6464
pub mod debug;
6565
pub mod default;
66-
pub mod primitive;
6766

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

179178
"Default" => default::expand_deriving_default,
180179

181-
"FromPrimitive" => primitive::expand_deriving_from_primitive,
182-
183180
"Send" => bounds::expand_deriving_unsafe_bound,
184181
"Sync" => bounds::expand_deriving_unsafe_bound,
185182
"Copy" => bounds::expand_deriving_copy,

src/libsyntax_ext/deriving/primitive.rs

-142
This file was deleted.
+4-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,27 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

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

14-
#[derive(FromPrimitive)]
15-
struct A { x: isize }
16-
//~^^ ERROR `FromPrimitive` cannot be derived for structs
17-
//~^^^ ERROR `FromPrimitive` cannot be derived for structs
14+
fn main() {}
1815

19-
#[derive(FromPrimitive)]
20-
struct B(isize);
21-
//~^^ ERROR `FromPrimitive` cannot be derived for structs
22-
//~^^^ ERROR `FromPrimitive` cannot be derived for structs
23-
24-
#[derive(FromPrimitive)]
25-
enum C { Foo(isize), Bar(usize) }
26-
//~^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants
27-
//~^^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants
28-
29-
#[derive(FromPrimitive)]
30-
enum D { Baz { x: isize } }
31-
//~^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants
32-
//~^^^ ERROR `FromPrimitive` cannot be derived for enums with non-unit variants
33-
34-
pub fn main() {}

0 commit comments

Comments
 (0)