Skip to content

Commit 3c182e4

Browse files
committed
Relax lifetime bounds on Reader/Writer impls for trait boxes
Cargo needs this to be able to instantiate `TerminfoTerminal<Box<Writer+'a>>` for 'a other than 'static.
1 parent 2e92c67 commit 3c182e4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libstd/io/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,10 +945,16 @@ pub trait Reader {
945945
}
946946
}
947947

948+
#[cfg(stage0)]
948949
impl Reader for Box<Reader+'static> {
949950
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) }
950951
}
951952

953+
#[cfg(not(stage0))]
954+
impl<'a> Reader for Box<Reader+'a> {
955+
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) }
956+
}
957+
952958
impl<'a> Reader for &'a mut Reader+'a {
953959
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) }
954960
}
@@ -1295,6 +1301,7 @@ pub trait Writer {
12951301
}
12961302
}
12971303

1304+
#[cfg(stage0)]
12981305
impl Writer for Box<Writer+'static> {
12991306
#[inline]
13001307
fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) }
@@ -1303,6 +1310,15 @@ impl Writer for Box<Writer+'static> {
13031310
fn flush(&mut self) -> IoResult<()> { self.flush() }
13041311
}
13051312

1313+
#[cfg(not(stage0))]
1314+
impl<'a> Writer for Box<Writer+'a> {
1315+
#[inline]
1316+
fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) }
1317+
1318+
#[inline]
1319+
fn flush(&mut self) -> IoResult<()> { self.flush() }
1320+
}
1321+
13061322
impl<'a> Writer for &'a mut Writer+'a {
13071323
#[inline]
13081324
fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) }

0 commit comments

Comments
 (0)