Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unused qualifications #9

Merged
merged 3 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
18 changes: 18 additions & 0 deletions tests/issue-9.rs
Original file line number Diff line number Diff line change
@@ -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());
}