diff --git a/src/file/mod.rs b/src/file/mod.rs index 059ac40a3..023acd26a 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -918,10 +918,7 @@ impl Read for NamedTempFile { } } -impl<'a, F> Read for &'a NamedTempFile -where - &'a F: Read, -{ +impl Read for &NamedTempFile { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.as_file().read(buf).with_err_path(|| self.path()) } @@ -937,10 +934,7 @@ impl Write for NamedTempFile { } } -impl<'a, F> Write for &'a NamedTempFile -where - &'a F: Write, -{ +impl Write for &NamedTempFile { fn write(&mut self, buf: &[u8]) -> io::Result { self.as_file().write(buf).with_err_path(|| self.path()) } @@ -956,10 +950,7 @@ impl Seek for NamedTempFile { } } -impl<'a, F> Seek for &'a NamedTempFile -where - &'a F: Seek, -{ +impl Seek for &NamedTempFile { fn seek(&mut self, pos: SeekFrom) -> io::Result { self.as_file().seek(pos).with_err_path(|| self.path()) } diff --git a/tests/namedtempfile.rs b/tests/namedtempfile.rs index 22ec6a4f0..54396c3ac 100644 --- a/tests/namedtempfile.rs +++ b/tests/namedtempfile.rs @@ -439,3 +439,28 @@ fn test_make_uds_conflict() { assert!(socket.path().exists()); } } + +// Issue #224. +#[test] +fn test_overly_generic_bounds() { + pub struct Foo(T); + + impl Foo + where + T: Sync + Send + 'static, + for<'a> &'a T: Write + Read, + { + pub fn new(foo: T) -> Self { + Self(foo) + } + } + + // Don't really need to run this. Only care if it compiles. + if let Ok(file) = File::open("i_do_not_exist") { + let mut f; + let _x = { + f = Foo::new(file); + &mut f + }; + } +}