diff --git a/Cargo.toml b/Cargo.toml index dc1e216227..525c40554f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ license = "MIT" authors = ["Sean McArthur ", "Jonathan Reem "] keywords = ["http", "hyper", "hyperium"] +build = "build.rs" [dependencies] httparse = "1.0" @@ -28,5 +29,8 @@ url = "1.0" [dev-dependencies] env_logger = "0.3" +[build-dependencies] +rustc_version = "0.1" + [features] nightly = [] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000000..e886b7262a --- /dev/null +++ b/build.rs @@ -0,0 +1,7 @@ +extern crate rustc_version as rustc; + +fn main() { + if rustc::version_matches(">= 1.9") { + println!("cargo:rustc-cfg=has_deprecated"); + } +} diff --git a/src/header/mod.rs b/src/header/mod.rs index 87117dd205..3943428357 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -495,11 +495,14 @@ impl<'a> FromIterator> for Headers { } } -impl<'a> fmt::Display for &'a (HeaderFormat + Send + Sync) { - #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut multi = MultilineFormatter(Multi::Join(true, f)); - self.fmt_multi_header(&mut multi) +deprecated! { + #[deprecated(note="The semantics of formatting a HeaderFormat directly are not clear")] + impl<'a> fmt::Display for &'a (HeaderFormat + Send + Sync) { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut multi = MultilineFormatter(Multi::Join(true, f)); + self.fmt_multi_header(&mut multi) + } } } @@ -510,8 +513,12 @@ impl<'a> fmt::Display for &'a (HeaderFormat + Send + Sync) { /// /// Note: This may not necessarily be the value written to stream, such /// as with the SetCookie header. -pub struct HeaderFormatter<'a, H: HeaderFormat>(pub &'a H); +deprecated! { + #[deprecated(note="The semantics of formatting a HeaderFormat directly are not clear")] + pub struct HeaderFormatter<'a, H: HeaderFormat>(pub &'a H); +} +#[allow(deprecated)] impl<'a, H: HeaderFormat> fmt::Display for HeaderFormatter<'a, H> { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -520,6 +527,7 @@ impl<'a, H: HeaderFormat> fmt::Display for HeaderFormatter<'a, H> { } } +#[allow(deprecated)] impl<'a, H: HeaderFormat> fmt::Debug for HeaderFormatter<'a, H> { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/lib.rs b/src/lib.rs index ba4dba1241..3531830194 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,6 +172,13 @@ macro_rules! inspect( }) ); +macro_rules! deprecated { + (#[$note:meta] $i:item) => ( + #[cfg_attr(has_deprecated, $note)] + $i + ); +} + #[cfg(test)] #[macro_use] mod mock;