Skip to content

Commit fce481d

Browse files
bors[bot]maurercuviper
authored
Merge #54
54: Update to syn-2 r=cuviper a=maurer Also moves a test out of doctest compilefail since syn-2 will build it correctly even without the "full" feature. Co-authored-by: Matthew Maurer <[email protected]> Co-authored-by: Josh Stone <[email protected]>
2 parents c259ebc + d2fa314 commit fce481d

File tree

15 files changed

+67
-75
lines changed

15 files changed

+67
-75
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
rust: [1.31.0, stable, beta, nightly]
15+
rust: [1.56.0, stable, beta, nightly]
1616
steps:
1717
- uses: actions/checkout@v3
1818
- uses: dtolnay/rust-toolchain@master
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040
steps:
4141
- uses: actions/checkout@v3
42-
- uses: dtolnay/rust-toolchain@1.62.0
42+
- uses: dtolnay/rust-toolchain@1.70.0
4343
with:
4444
components: rustfmt
4545
- run: cargo fmt --all --check

.github/workflows/master.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
rust: [1.31.0, stable]
16+
rust: [1.56.0, stable]
1717
steps:
1818
- uses: actions/checkout@v3
1919
- uses: dtolnay/rust-toolchain@master

.github/workflows/pr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
rust: [1.31.0, stable]
12+
rust: [1.56.0, stable]
1313
steps:
1414
- uses: actions/checkout@v3
1515
- uses: dtolnay/rust-toolchain@master
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v3
26-
- uses: dtolnay/rust-toolchain@1.62.0
26+
- uses: dtolnay/rust-toolchain@1.70.0
2727
with:
2828
components: rustfmt
2929
- run: cargo fmt --all --check

Cargo.toml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,41 @@ categories = [ "science" ]
88
license = "MIT OR Apache-2.0"
99
name = "num-derive"
1010
repository = "https://github.com/rust-num/num-derive"
11-
version = "0.3.3"
11+
version = "0.4.0"
1212
readme = "README.md"
1313
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
14-
edition = "2018"
14+
edition = "2021"
15+
rust-version = "1.56.0"
1516

1617
[dependencies]
1718
proc-macro2 = "1"
1819
quote = "1"
19-
syn = "1"
20+
syn = "2.0.5"
2021

2122
[dev-dependencies]
22-
num = "0.3"
23+
num = "0.4"
2324
num-traits = "0.2"
2425

25-
[features]
26-
full-syntax = ["syn/full"]
27-
2826
[lib]
2927
name = "num_derive"
3028
proc-macro = true
3129
test = false
3230

33-
# Most of the tests are left implicily detected, compiled for Rust 2018,
34-
# but let's try a few of them with the old 2015 edition too.
31+
# Most of the tests are left implicily detected, compiled for Rust 2021,
32+
# but let's try a few of them with the older editions too.
3533

3634
[[test]]
3735
name = "newtype-2015"
3836
edition = "2015"
3937

38+
[[test]]
39+
name = "newtype-2018"
40+
edition = "2018"
41+
4042
[[test]]
4143
name = "trivial-2015"
4244
edition = "2015"
45+
46+
[[test]]
47+
name = "trivial-2018"
48+
edition = "2018"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![crate](https://img.shields.io/crates/v/num-derive.svg)](https://crates.io/crates/num-derive)
44
[![documentation](https://docs.rs/num-derive/badge.svg)](https://docs.rs/num-derive)
5-
[![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
5+
[![minimum rustc 1.56](https://img.shields.io/badge/rustc-1.56+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
66
[![build status](https://github.com/rust-num/num-derive/workflows/master/badge.svg)](https://github.com/rust-num/num-derive/actions)
77

88
Procedural macros to derive numeric traits in Rust.
@@ -14,7 +14,7 @@ Add this to your `Cargo.toml`:
1414
```toml
1515
[dependencies]
1616
num-traits = "0.2"
17-
num-derive = "0.3"
17+
num-derive = "0.4"
1818
```
1919

2020
and this to your crate root:
@@ -51,7 +51,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
5151

5252
## Compatibility
5353

54-
The `num-derive` crate is tested for rustc 1.31 and greater.
54+
The `num-derive` crate is tested for rustc 1.56 and greater.
5555

5656
## License
5757

RELEASES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release 0.4.0 (2023-06-29)
2+
3+
- [Update to syn-2][54] -- thanks @maurer!
4+
- This raises the minimum supported rustc to 1.56.
5+
- The "full-syntax" feature has also been removed.
6+
7+
[54]: https://github.com/rust-num/num-derive/pull/54
8+
19
# Release 0.3.3 (2020-10-29)
210

311
- [Make `NumOps` work with `no_std`][41] -- thanks @jedrzejboczar!

bors.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
status = [
2-
"Test (1.31.0)",
2+
"Test (1.56.0)",
33
"Test (stable)",
44
"Test (beta)",
55
"Test (nightly)",

ci/rustup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
set -ex
66

77
ci=$(dirname $0)
8-
for version in 1.31.0 stable beta nightly; do
8+
for version in 1.56.0 stable beta nightly; do
99
rustup run "$version" "$ci/test_full.sh"
1010
done

ci/test_full.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
CRATE=num-derive
6-
MSRV=1.31
6+
MSRV=1.56
77

88
get_rust_version() {
99
local array=($(rustc --version));
@@ -27,7 +27,7 @@ if ! check_version $MSRV ; then
2727
exit 1
2828
fi
2929

30-
FEATURES=(full-syntax)
30+
FEATURES=()
3131
echo "Testing supported features: ${FEATURES[*]}"
3232

3333
set -x

src/lib.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,11 @@ use quote::quote;
7171
use syn::{Data, Fields, Ident};
7272

7373
/// Try to parse the tokens, or else return a compilation error
74-
/// suggesting "full-syntax" if that's not already enabled.
7574
macro_rules! parse {
7675
($tokens:ident as $type:ty) => {
7776
match syn::parse::<$type>($tokens) {
7877
Ok(parsed) => parsed,
79-
Err(mut error) => {
80-
if cfg!(not(feature = "full-syntax")) {
81-
let hint = syn::Error::new(
82-
Span::call_site(),
83-
r#"this might need the "full-syntax" feature of `num-derive`"#,
84-
);
85-
error.combine(hint);
86-
}
78+
Err(error) => {
8779
return TokenStream::from(error.to_compile_error());
8880
}
8981
}
@@ -170,16 +162,22 @@ impl NumTraits {
170162
// retrieve its value, and use it to create an `Ident` to be used
171163
// to import the `num_traits` crate.
172164
for attr in &ast.attrs {
173-
if let Ok(syn::Meta::NameValue(mnv)) = attr.parse_meta() {
174-
if mnv.path.is_ident("num_traits") {
175-
if let syn::Lit::Str(lit_str) = mnv.lit {
176-
return NumTraits {
177-
import: syn::Ident::new(&lit_str.value(), lit_str.span()),
178-
explicit: true,
179-
};
180-
} else {
181-
panic!("#[num_traits] attribute value must be a str");
182-
}
165+
if attr.path().is_ident("num_traits") {
166+
if let Ok(syn::MetaNameValue {
167+
value:
168+
syn::Expr::Lit(syn::ExprLit {
169+
lit: syn::Lit::Str(ref lit_str),
170+
..
171+
}),
172+
..
173+
}) = attr.meta.require_name_value()
174+
{
175+
return NumTraits {
176+
import: syn::Ident::new(&lit_str.value(), lit_str.span()),
177+
explicit: true,
178+
};
179+
} else {
180+
panic!("#[num_traits] attribute value must be a str");
183181
}
184182
}
185183
}
@@ -954,5 +952,3 @@ pub fn float(input: TokenStream) -> TokenStream {
954952

955953
import.wrap("Float", &name, impl_).into()
956954
}
957-
958-
mod test;

0 commit comments

Comments
 (0)