Repository: brendanzab/approx (language: rust)

Issue:
Use macro on Rust 1.30
I replaced all `#[macro_use] extern crate approx;` in my project with simple `use`.

It went well for `relative_eq!`, but not for `assert_relative_eq!`. When I try to use it, the compiler tells me that `__assert_approx` is missing, then  `relative_eq` is missing, so I need to type:

    use approx::{assert_relative_eq, __assert_approx, relative_eq};

I know I can a) keep `#[macro_use]` or b) `use approx::*;` but neither are interesting.


Discussion / hints:
iiinteresting! We'll have to figure out what is up with this. 🤔 

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index c03fccb..9f207ee 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,6 +18,7 @@ matrix:
     - rust: nightly
 
 before_script:
+  - if [ "$TRAVIS_RUST_VERSION" == "1.20.0" ]; then rm -f tests/macro_import.rs; fi
   - cargo build --verbose
 
 script:
diff --git a/src/macros.rs b/src/macros.rs
index bcd1fbf..6462fb2 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -121,7 +121,7 @@ macro_rules! __assert_approx {
 }
 
 /// An assertion that delegates to `abs_diff_eq!`, and panics with a helpful error on failure.
-#[macro_export]
+#[macro_export(local_inner_macros)]
 macro_rules! assert_abs_diff_eq {
     ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => {
         __assert_approx!(abs_diff_eq, $given, $expected $(, $opt = $val)*)
@@ -132,7 +132,7 @@ macro_rules! assert_abs_diff_eq {
 }
 
 /// An assertion that delegates to `abs_diff_ne!`, and panics with a helpful error on failure.
-#[macro_export]
+#[macro_export(local_inner_macros)]
 macro_rules! assert_abs_diff_ne {
     ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => {
         __assert_approx!(abs_diff_ne, $given, $expected $(, $opt = $val)*)
@@ -143,7 +143,7 @@ macro_rules! assert_abs_diff_ne {
 }
 
 /// An assertion that delegates to `relative_eq!`, and panics with a helpful error on failure.
-#[macro_export]
+#[macro_export(local_inner_macros)]
 macro_rules! assert_relative_eq {
     ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => {
         __assert_approx!(relative_eq, $given, $expected $(, $opt = $val)*)
@@ -154,7 +154,7 @@ macro_rules! assert_relative_eq {
 }
 
 /// An assertion that delegates to `relative_ne!`, and panics with a helpful error on failure.
-#[macro_export]
+#[macro_export(local_inner_macros)]
 macro_rules! assert_relative_ne {
     ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => {
         __assert_approx!(relative_ne, $given, $expected $(, $opt = $val)*)
@@ -165,7 +165,7 @@ macro_rules! assert_relative_ne {
 }
 
 /// An assertion that delegates to `ulps_eq!`, and panics with a helpful error on failure.
-#[macro_export]
+#[macro_export(local_inner_macros)]
 macro_rules! assert_ulps_eq {
     ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => {
         __assert_approx!(ulps_eq, $given, $expected $(, $opt = $val)*)
@@ -176,7 +176,7 @@ macro_rules! assert_ulps_eq {
 }
 
 /// An assertion that delegates to `ulps_ne!`, and panics with a helpful error on failure.
-#[macro_export]
+#[macro_export(local_inner_macros)]
 macro_rules! assert_ulps_ne {
     ($given:expr, $expected:expr $(, $opt:ident = $val:expr)*) => {
         __assert_approx!(ulps_ne, $given, $expected $(, $opt = $val)*)


Test patch:
diff --git a/tests/macro_import.rs b/tests/macro_import.rs
new file mode 100644
index 0000000..02b949d
--- /dev/null
+++ b/tests/macro_import.rs
@@ -0,0 +1,18 @@
+extern crate approx;
+
+mod test_macro_import {
+    use approx::{
+        assert_abs_diff_eq, assert_abs_diff_ne, assert_relative_eq, assert_relative_ne,
+        assert_ulps_eq, assert_ulps_ne,
+    };
+
+    #[test]
+    fn test() {
+        assert_abs_diff_eq!(1.0f32, 1.0f32);
+        assert_abs_diff_ne!(1.0f32, 2.0f32);
+        assert_relative_eq!(1.0f32, 1.0f32);
+        assert_relative_ne!(1.0f32, 2.0f32);
+        assert_ulps_eq!(1.0f32, 1.0f32);
+        assert_ulps_ne!(1.0f32, 2.0f32);
+    }
+}