macros: Remove use requirement on error::Error.

Emmanuel Gil Peyrot created

Change summary

src/attention.rs       |  3 -
src/chatstates.rs      |  3 -
src/component.rs       |  1 
src/delay.rs           |  2 
src/eme.rs             |  3 -
src/ibb.rs             |  3 -
src/idle.rs            |  3 -
src/jingle_ibb.rs      |  3 -
src/macros.rs          | 66 ++++++++++++++++++++++----------------------
src/media_element.rs   |  3 -
src/message_correct.rs |  3 -
src/mood.rs            |  2 -
src/ping.rs            |  3 -
src/receipts.rs        |  2 -
src/roster.rs          |  2 
src/sasl.rs            |  2 -
src/stanza_id.rs       |  3 -
src/stream.rs          |  1 
src/websocket.rs       |  1 
19 files changed, 45 insertions(+), 64 deletions(-)

Detailed changes

src/attention.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 
 generate_empty_element!(Attention, "attention", ns::ATTENTION);
@@ -15,6 +13,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
 
     #[test]
     fn test_simple() {

src/chatstates.rs 🔗

@@ -6,8 +6,6 @@
 
 #![deny(missing_docs)]
 
-use error::Error;
-
 use ns;
 
 generate_element_enum!(
@@ -36,6 +34,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
 
     #[test]
     fn test_simple() {

src/component.rs 🔗

@@ -4,7 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
 use helpers::PlainText;
 use ns;
 

src/delay.rs 🔗

@@ -6,7 +6,6 @@
 
 use date::DateTime;
 
-use error::Error;
 use jid::Jid;
 
 use ns;
@@ -25,6 +24,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use std::str::FromStr;
 
     #[test]

src/eme.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 
 generate_element_with_only_attributes!(
@@ -24,6 +22,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
 
     #[test]
     fn test_simple() {

src/ibb.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 use helpers::Base64;
 
@@ -37,6 +35,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use std::error::Error as StdError;
 
     #[test]

src/idle.rs 🔗

@@ -6,8 +6,6 @@
 
 use date::DateTime;
 
-use error::Error;
-
 use ns;
 
 generate_element_with_only_attributes!(Idle, "idle", ns::IDLE, [
@@ -19,6 +17,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use std::str::FromStr;
     use std::error::Error as StdError;
 

src/jingle_ibb.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 
 use ibb::Stanza;
@@ -23,6 +21,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use std::error::Error as StdError;
 
     #[test]

src/macros.rs 🔗

@@ -24,7 +24,7 @@ macro_rules! get_attr {
     ($elem:ident, $attr:tt, required, $value:ident, $func:expr) => (
         match $elem.attr($attr) {
             Some($value) => $func,
-            None => return Err(Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
+            None => return Err(::error::Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
         }
     );
     ($elem:ident, $attr:tt, default, $value:ident, $func:expr) => (
@@ -52,11 +52,11 @@ macro_rules! generate_attribute {
             ),+
         }
         impl ::std::str::FromStr for $elem {
-            type Err = Error;
-            fn from_str(s: &str) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn from_str(s: &str) -> Result<$elem, ::error::Error> {
                 Ok(match s {
                     $($b => $elem::$a),+,
-                    _ => return Err(Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+                    _ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
                 })
             }
         }
@@ -78,11 +78,11 @@ macro_rules! generate_attribute {
             ),+
         }
         impl ::std::str::FromStr for $elem {
-            type Err = Error;
-            fn from_str(s: &str) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn from_str(s: &str) -> Result<$elem, ::error::Error> {
                 Ok(match s {
                     $($b => $elem::$a),+,
-                    _ => return Err(Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+                    _ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
                 })
             }
         }
@@ -117,14 +117,14 @@ macro_rules! generate_element_enum {
             ),+
         }
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_ns_only!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_attributes!(elem, $name);
                 Ok(match elem.name() {
                     $($enum_name => $elem::$enum,)+
-                    _ => return Err(Error::ParseError(concat!("This is not a ", $name, " element."))),
+                    _ => return Err(::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
                 })
             }
         }
@@ -153,14 +153,14 @@ macro_rules! generate_attribute_enum {
             ),+
         }
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_ns_only!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_unknown_attributes!(elem, $name, [$attr]);
                 Ok(match get_attr!(elem, $attr, required) {
                     $($enum_name => $elem::$enum,)+
-                    _ => return Err(Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
+                    _ => return Err(::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
                 })
             }
         }
@@ -183,7 +183,7 @@ macro_rules! check_self {
     );
     ($elem:ident, $name:tt, $ns:expr, $pretty_name:tt) => (
         if !$elem.is($name, $ns) {
-            return Err(Error::ParseError(concat!("This is not a ", $pretty_name, " element.")));
+            return Err(::error::Error::ParseError(concat!("This is not a ", $pretty_name, " element.")));
         }
     );
 }
@@ -191,7 +191,7 @@ macro_rules! check_self {
 macro_rules! check_ns_only {
     ($elem:ident, $name:tt, $ns:expr) => (
         if !$elem.has_ns($ns) {
-            return Err(Error::ParseError(concat!("This is not a ", $name, " element.")));
+            return Err(::error::Error::ParseError(concat!("This is not a ", $name, " element.")));
         }
     );
 }
@@ -199,7 +199,7 @@ macro_rules! check_ns_only {
 macro_rules! check_no_children {
     ($elem:ident, $name:tt) => (
         for _ in $elem.children() {
-            return Err(Error::ParseError(concat!("Unknown child in ", $name, " element.")));
+            return Err(::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
         }
     );
 }
@@ -207,7 +207,7 @@ macro_rules! check_no_children {
 macro_rules! check_no_attributes {
     ($elem:ident, $name:tt) => (
         for _ in $elem.attrs() {
-            return Err(Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
+            return Err(::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
         }
     );
 }
@@ -220,7 +220,7 @@ macro_rules! check_no_unknown_attributes {
                 continue;
             }
             )*
-            return Err(Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
+            return Err(::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
         }
     );
 }
@@ -232,9 +232,9 @@ macro_rules! generate_empty_element {
         pub struct $elem;
 
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
+            type Err = ::error::Error;
 
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_attributes!(elem, $name);
@@ -267,9 +267,9 @@ macro_rules! generate_element_with_only_attributes {
         }
 
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
+            type Err = ::error::Error;
 
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
@@ -299,8 +299,8 @@ macro_rules! generate_id {
         #[derive(Debug, Clone, PartialEq, Eq, Hash)]
         pub struct $elem(pub String);
         impl ::std::str::FromStr for $elem {
-            type Err = Error;
-            fn from_str(s: &str) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn from_str(s: &str) -> Result<$elem, ::error::Error> {
                 // TODO: add a way to parse that differently when needed.
                 Ok($elem(String::from(s)))
             }
@@ -318,15 +318,15 @@ macro_rules! generate_elem_id {
         #[derive(Debug, Clone, PartialEq, Eq, Hash)]
         pub struct $elem(pub String);
         impl ::std::str::FromStr for $elem {
-            type Err = Error;
-            fn from_str(s: &str) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn from_str(s: &str) -> Result<$elem, ::error::Error> {
                 // TODO: add a way to parse that differently when needed.
                 Ok($elem(String::from(s)))
             }
         }
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            type Err = ::error::Error;
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_attributes!(elem, $name);
@@ -361,9 +361,9 @@ macro_rules! generate_element_with_text {
         }
 
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
+            type Err = ::error::Error;
 
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
@@ -406,9 +406,9 @@ macro_rules! generate_element_with_children {
         }
 
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = Error;
+            type Err = ::error::Error;
 
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
                 let mut parsed_children = vec!();
@@ -420,7 +420,7 @@ macro_rules! generate_element_with_children {
                         continue;
                     }
                     )*
-                    return Err(Error::ParseError(concat!("Unknown child in ", $name, " element.")));
+                    return Err(::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
                 }
                 Ok($elem {
                     $(

src/media_element.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 use helpers::TrimmedPlainText;
 
@@ -31,6 +29,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use data_forms::DataForm;
     use std::error::Error as StdError;
 

src/message_correct.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 
 generate_element_with_only_attributes!(Replace, "replace", ns::MESSAGE_CORRECT, [
@@ -17,6 +15,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
 
     #[test]
     fn test_simple() {

src/mood.rs 🔗

@@ -6,8 +6,6 @@
 
 #![deny(missing_docs)]
 
-use error::Error;
-
 use ns;
 
 generate_element_enum!(

src/ping.rs 🔗

@@ -5,8 +5,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 
 generate_empty_element!(Ping, "ping", ns::PING);
@@ -16,6 +14,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
 
     #[test]
     fn test_simple() {

src/receipts.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 
 generate_empty_element!(Request, "request", ns::RECEIPTS);

src/roster.rs 🔗

@@ -6,7 +6,6 @@
 
 use jid::Jid;
 
-use error::Error;
 use ns;
 
 generate_elem_id!(Group, "group", ns::ROSTER);
@@ -62,6 +61,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use std::str::FromStr;
     use compare_elements::NamespaceAwareCompare;
 

src/sasl.rs 🔗

@@ -4,8 +4,6 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use error::Error;
-
 use ns;
 use helpers::Base64;
 

src/stanza_id.rs 🔗

@@ -6,8 +6,6 @@
 
 use jid::Jid;
 
-use error::Error;
-
 use ns;
 
 generate_element_with_only_attributes!(StanzaId, "stanza-id", ns::SID, [
@@ -24,6 +22,7 @@ mod tests {
     use super::*;
     use try_from::TryFrom;
     use minidom::Element;
+    use error::Error;
     use std::str::FromStr;
 
     #[test]

src/stream.rs 🔗

@@ -5,7 +5,6 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use jid::Jid;
-use error::Error;
 use ns;
 
 generate_element_with_only_attributes!(Stream, "stream", ns::STREAM, [

src/websocket.rs 🔗

@@ -5,7 +5,6 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use jid::Jid;
-use error::Error;
 use ns;
 
 generate_element_with_only_attributes!(Open, "open", ns::WEBSOCKET, [