about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-10-03 04:13:10 -0700
committerDaniel Micay <danielmicay@gmail.com>2013-10-03 04:13:10 -0700
commit6d598989f62c15b6093cdaf116f2f6318ed1b95c (patch)
tree44a0b553e1f947a25093d6ada633089f5e7b15d5
parent8f40641e01fe7f79e21f606733646c600820bbd8 (diff)
parent435ca16f4fa7bd47c16de693054be5cba5fd4ebb (diff)
downloadrust-6d598989f62c15b6093cdaf116f2f6318ed1b95c.tar.gz
rust-6d598989f62c15b6093cdaf116f2f6318ed1b95c.zip
Merge pull request #9697 from sfackler/issue_9155
Close out #9155
-rw-r--r--src/libstd/rt/io/buffered.rs22
-rw-r--r--src/test/auxiliary/issue_9155.rs17
-rw-r--r--src/test/run-pass/issue_9155.rs20
3 files changed, 46 insertions, 13 deletions
diff --git a/src/libstd/rt/io/buffered.rs b/src/libstd/rt/io/buffered.rs
index 3e801f28991..a8cf8151499 100644
--- a/src/libstd/rt/io/buffered.rs
+++ b/src/libstd/rt/io/buffered.rs
@@ -187,25 +187,21 @@ impl<W: Writer> Decorator<W> for BufferedWriter<W> {
     }
 }
 
-// FIXME #9155 this should be a newtype struct
-struct InternalBufferedWriter<W> {
-    inner: BufferedWriter<W>
-}
+struct InternalBufferedWriter<W>(BufferedWriter<W>);
 
 impl<W: Reader> Reader for InternalBufferedWriter<W> {
     fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
-        self.inner.inner.read(buf)
+        self.inner.read(buf)
     }
 
     fn eof(&mut self) -> bool {
-        self.inner.inner.eof()
+        self.inner.eof()
     }
 }
 
 /// Wraps a Stream and buffers input and output to and from it
 ///
 /// Note that `BufferedStream` will NOT flush its output buffer when dropped.
-// FIXME #9155 this should be a newtype struct
 pub struct BufferedStream<S> {
     priv inner: BufferedReader<InternalBufferedWriter<S>>
 }
@@ -214,7 +210,7 @@ impl<S: Stream> BufferedStream<S> {
     pub fn with_capacities(reader_cap: uint, writer_cap: uint, inner: S)
                            -> BufferedStream<S> {
         let writer = BufferedWriter::with_capacity(writer_cap, inner);
-        let internal_writer = InternalBufferedWriter { inner: writer };
+        let internal_writer = InternalBufferedWriter(writer);
         let reader = BufferedReader::with_capacity(reader_cap,
                                                    internal_writer);
         BufferedStream { inner: reader }
@@ -238,25 +234,25 @@ impl<S: Stream> Reader for BufferedStream<S> {
 
 impl<S: Stream> Writer for BufferedStream<S> {
     fn write(&mut self, buf: &[u8]) {
-        self.inner.inner.inner.write(buf)
+        self.inner.inner.write(buf)
     }
 
     fn flush(&mut self) {
-        self.inner.inner.inner.flush()
+        self.inner.inner.flush()
     }
 }
 
 impl<S: Stream> Decorator<S> for BufferedStream<S> {
     fn inner(self) -> S {
-        self.inner.inner.inner.inner()
+        self.inner.inner.inner()
     }
 
     fn inner_ref<'a>(&'a self) -> &'a S {
-        self.inner.inner.inner.inner_ref()
+        self.inner.inner.inner_ref()
     }
 
     fn inner_mut_ref<'a>(&'a mut self) -> &'a mut S {
-        self.inner.inner.inner.inner_mut_ref()
+        self.inner.inner.inner_mut_ref()
     }
 }
 
diff --git a/src/test/auxiliary/issue_9155.rs b/src/test/auxiliary/issue_9155.rs
new file mode 100644
index 00000000000..486eb8fd6f6
--- /dev/null
+++ b/src/test/auxiliary/issue_9155.rs
@@ -0,0 +1,17 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub struct Foo<T>(T);
+
+impl<T> Foo<T> {
+    pub fn new(t: T) -> Foo<T> {
+        Foo(t)
+    }
+}
diff --git a/src/test/run-pass/issue_9155.rs b/src/test/run-pass/issue_9155.rs
new file mode 100644
index 00000000000..ba92a0c7b1f
--- /dev/null
+++ b/src/test/run-pass/issue_9155.rs
@@ -0,0 +1,20 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:issue_9155.rs
+// xfail-fast windows doesn't like the aux-build
+
+extern mod issue_9155;
+
+struct Baz;
+
+fn main() {
+    issue_9155::Foo::new(Baz);
+}