diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index ff7d7827fbb..7b84c005db5 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -518,6 +518,9 @@ impl<'a, T: Show> Show for &'a T { impl<'a, T: Show> Show for &'a mut T { fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) } } +impl<'a> Show for &'a Show { + fn fmt(&self, f: &mut Formatter) -> Result { (*self).fmt(f) } +} impl Bool for bool { fn fmt(&self, f: &mut Formatter) -> Result { diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 1258a498dac..e349f91a309 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -81,6 +81,9 @@ pub fn main() { t!(format!("{foo_bar}", foo_bar=1i), "1"); t!(format!("{:d}", 5i + 5i), "10"); + let a: &fmt::Show = &1i; + t!(format!("{}", a), "1"); + // Formatting strings and their arguments t!(format!("{:s}", "a"), "a"); t!(format!("{:4s}", "a"), "a ");