Skip to content

Commit 334f21f

Browse files
committed
Allow deriving for no-std targets
By pulling in `num-traits` as a direct dependency, we corrupt the feature selection for anybody using `num-derive` too, which makes it impossible to use on no-std targets. We really only need it for testing as a dev-dependency though.
1 parent 6a8631a commit 334f21f

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ env:
88
matrix:
99
- # no features
1010
- FEATURES="full-syntax"
11+
12+
matrix:
13+
include:
14+
# try a no-std target
15+
- rust: stable
16+
env: TARGET=thumbv6m-none-eabi
17+
before_script:
18+
- rustup target add "$TARGET"
19+
script:
20+
# This test crate is intentionally separate, because we need
21+
# independent features for no-std. (rust-lang/cargo#2589)
22+
- cd check && cargo check --target "$TARGET"
23+
1124
sudo: false
1225
script:
1326
- cargo build --verbose --features="$FEATURES"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ readme = "README.md"
1313
build = "build.rs"
1414

1515
[dependencies]
16-
num-traits = "0.2"
1716
proc-macro2 = "0.4.2"
1817
quote = "0.6"
1918
syn = "0.15"
2019

2120
[dev-dependencies]
2221
num = "0.2"
22+
num-traits = "0.2"
2323

2424
[features]
2525
full-syntax = ["syn/full"]

check/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "check"
3+
version = "0.1.0"
4+
authors = ["Josh Stone <cuviper@gmail.com>"]
5+
edition = "2018"
6+
7+
[dependencies.num-derive]
8+
path = ".."
9+
10+
[dependencies.num-traits]
11+
version = "0.2"
12+
default-features = false

check/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![no_std]
2+
3+
#[derive(num_derive::FromPrimitive)]
4+
pub enum ABC {
5+
A,
6+
B,
7+
C,
8+
}

0 commit comments

Comments
 (0)