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..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; @@ -148,6 +149,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; diff --git a/tests/issue-9.rs b/tests/issue-9.rs new file mode 100644 index 0000000..c349474 --- /dev/null +++ b/tests/issue-9.rs @@ -0,0 +1,18 @@ +#![deny(unused_qualifications)] +extern crate num; +#[macro_use] +extern crate num_derive; +use num::FromPrimitive; +use num::ToPrimitive; + +#[derive(FromPrimitive, ToPrimitive)] +pub enum SomeEnum { + A = 1 +} + +#[test] +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()); +}