fix(rustup): Add PhantomData markers to phantom type users
Necessary since [RFC 738](https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md).
This commit is contained in:
committed by
Sean McArthur
parent
039e984f68
commit
1904c4561f
@@ -1,5 +1,6 @@
|
||||
//! Client Requests
|
||||
use std::old_io::{BufferedWriter, IoResult};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use url::Url;
|
||||
|
||||
@@ -25,6 +26,8 @@ pub struct Request<W> {
|
||||
body: HttpWriter<BufferedWriter<Box<NetworkStream + Send>>>,
|
||||
headers: Headers,
|
||||
method: method::Method,
|
||||
|
||||
_marker: PhantomData<W>,
|
||||
}
|
||||
|
||||
impl<W> Request<W> {
|
||||
@@ -66,7 +69,8 @@ impl Request<Fresh> {
|
||||
headers: headers,
|
||||
url: url,
|
||||
version: version::HttpVersion::Http11,
|
||||
body: stream
|
||||
body: stream,
|
||||
_marker: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -136,7 +140,8 @@ impl Request<Fresh> {
|
||||
headers: self.headers,
|
||||
url: self.url,
|
||||
version: self.version,
|
||||
body: stream
|
||||
body: stream,
|
||||
_marker: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Client Responses
|
||||
use std::num::FromPrimitive;
|
||||
use std::old_io::{BufferedReader, IoResult};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use header;
|
||||
use header::{ContentLength, TransferEncoding};
|
||||
@@ -23,6 +24,8 @@ pub struct Response<S = HttpStream> {
|
||||
pub version: version::HttpVersion,
|
||||
status_raw: RawStatus,
|
||||
body: HttpReader<BufferedReader<Box<NetworkStream + Send>>>,
|
||||
|
||||
_marker: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl Response {
|
||||
@@ -72,6 +75,7 @@ impl Response {
|
||||
headers: headers,
|
||||
body: body,
|
||||
status_raw: raw_status,
|
||||
_marker: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -98,6 +102,7 @@ mod tests {
|
||||
use std::borrow::Cow::Borrowed;
|
||||
use std::boxed::BoxAny;
|
||||
use std::old_io::BufferedReader;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use header::Headers;
|
||||
use header::TransferEncoding;
|
||||
@@ -119,7 +124,8 @@ mod tests {
|
||||
headers: Headers::new(),
|
||||
version: version::HttpVersion::Http11,
|
||||
body: EofReader(BufferedReader::new(box MockStream::new() as Box<NetworkStream + Send>)),
|
||||
status_raw: RawStatus(200, Borrowed("OK"))
|
||||
status_raw: RawStatus(200, Borrowed("OK")),
|
||||
_marker: PhantomData,
|
||||
};
|
||||
|
||||
let b = res.into_inner().downcast::<MockStream>().ok().unwrap();
|
||||
|
||||
@@ -22,7 +22,7 @@ impl<S: Scheme> DerefMut for Authorization<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Scheme + 'static> Header for Authorization<S> {
|
||||
impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
|
||||
fn header_name() -> &'static str {
|
||||
"Authorization"
|
||||
}
|
||||
@@ -43,7 +43,7 @@ impl<S: Scheme + 'static> Header for Authorization<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Scheme + 'static> HeaderFormat for Authorization<S> {
|
||||
impl<S: Scheme + 'static> HeaderFormat for Authorization<S> where <S as FromStr>::Err: 'static {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match Scheme::scheme(None::<S>) {
|
||||
Some(scheme) => try!(write!(fmt, "{} ", scheme)),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//! These are responses sent by a `hyper::Server` to clients, after
|
||||
//! receiving a request.
|
||||
use std::old_io::IoResult;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use time::now_utc;
|
||||
|
||||
@@ -22,7 +23,9 @@ pub struct Response<'a, W = Fresh> {
|
||||
// The status code for the request.
|
||||
status: status::StatusCode,
|
||||
// The outgoing headers on this response.
|
||||
headers: header::Headers
|
||||
headers: header::Headers,
|
||||
|
||||
_marker: PhantomData<W>
|
||||
}
|
||||
|
||||
impl<'a, W> Response<'a, W> {
|
||||
@@ -42,7 +45,8 @@ impl<'a, W> Response<'a, W> {
|
||||
status: status,
|
||||
version: version,
|
||||
body: body,
|
||||
headers: headers
|
||||
headers: headers,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +64,8 @@ impl<'a> Response<'a, Fresh> {
|
||||
status: status::StatusCode::Ok,
|
||||
version: version::HttpVersion::Http11,
|
||||
headers: header::Headers::new(),
|
||||
body: ThroughWriter(stream)
|
||||
body: ThroughWriter(stream),
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +124,8 @@ impl<'a> Response<'a, Fresh> {
|
||||
version: self.version,
|
||||
body: stream,
|
||||
status: self.status,
|
||||
headers: self.headers
|
||||
headers: self.headers,
|
||||
_marker: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user