From 2d7f3ad21e1df77e39933ca006e04b9816e90c53 Mon Sep 17 00:00:00 2001 From: Psilon Date: Fri, 26 Jan 2018 11:56:43 +0300 Subject: [PATCH 1/3] unused qualifications --- Cargo.toml | 2 +- RELEASES.md | 7 +++++++ src/lib.rs | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f30a878..b0eb120 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ categories = [ "science" ] license = "MIT/Apache-2.0" name = "num-derive" repository = "https://github.com/rust-num/num-derive" -version = "0.1.43" +version = "0.1.44" readme = "README.md" [dependencies] diff --git a/RELEASES.md b/RELEASES.md index 9851a1a..5785fdd 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,10 @@ +# Release 0.1.44 + +- [The derived code now explicitly allows `unused_qualifications`][9], so users + that globally deny that lint don't encounter an error. + +[9]: https://github.com/rust-num/num-derive/pull/9 + # Release 0.1.43 - [The derived code now explicitly allows `trivial_numeric_casts`][7], so users diff --git a/src/lib.rs b/src/lib.rs index c0140c6..3a727aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -148,6 +148,7 @@ pub fn to_primitive(input: TokenStream) -> TokenStream { let res = quote! { #[allow(non_upper_case_globals)] + #[allow(unused_qualifications)] const #dummy_const: () = { extern crate num as _num; From ce3d4cfc37e15d8b7edab78aee64e9e8ff54b9da Mon Sep 17 00:00:00 2001 From: Psilon Date: Fri, 26 Jan 2018 23:25:26 +0300 Subject: [PATCH 2/3] tests issue 9 --- tests/issue-9.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/issue-9.rs diff --git a/tests/issue-9.rs b/tests/issue-9.rs new file mode 100644 index 0000000..bf30900 --- /dev/null +++ b/tests/issue-9.rs @@ -0,0 +1,15 @@ +#![deny(unused_qualifications)] +extern crate num; +#[macro_use] +extern crate num_derive; +use num::ToPrimitive; + +#[derive(ToPrimitive)] +pub enum SomeEnum { + A = 1 +} + +#[test] +fn test_trivial_numeric_casts() { + assert!(SomeEnum::A.to_i64().is_some()); +} From 13e8c1fbc137f5c23dfa45058395439e711f66d6 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 26 Jan 2018 13:58:00 -0800 Subject: [PATCH 3/3] Also allow unused qualifications in FromPrimitive --- src/lib.rs | 1 + tests/issue-9.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3a727aa..fab9688 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,6 +72,7 @@ pub fn from_primitive(input: TokenStream) -> TokenStream { let res = quote! { #[allow(non_upper_case_globals)] + #[allow(unused_qualifications)] const #dummy_const: () = { extern crate num as _num; diff --git a/tests/issue-9.rs b/tests/issue-9.rs index bf30900..c349474 100644 --- a/tests/issue-9.rs +++ b/tests/issue-9.rs @@ -2,14 +2,17 @@ extern crate num; #[macro_use] extern crate num_derive; +use num::FromPrimitive; use num::ToPrimitive; -#[derive(ToPrimitive)] +#[derive(FromPrimitive, ToPrimitive)] pub enum SomeEnum { A = 1 } #[test] -fn test_trivial_numeric_casts() { +fn test_unused_qualifications() { + assert!(SomeEnum::from_u64(1).is_some()); + assert!(SomeEnum::from_i64(-1).is_none()); assert!(SomeEnum::A.to_i64().is_some()); }