From 6562eeb05396be4ee4d4f413ac3e0f9f1afcc536 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Sun, 13 Mar 2016 22:55:26 -0700 Subject: [PATCH] Add pretty printer output for `default` --- src/librustc_front/print/pprust.rs | 5 +++++ src/libsyntax/print/pprust.rs | 3 +++ .../specialization/specialization-default-methods.rs | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 143dfce09b602..1100f084454c7 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -1014,6 +1014,11 @@ impl<'a> State<'a> { try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(ii.span.lo)); try!(self.print_outer_attributes(&ii.attrs)); + + if let hir::Defaultness::Default = ii.defaultness { + try!(self.word_nbsp("default")); + } + match ii.node { hir::ImplItemKind::Const(ref ty, ref expr) => { try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis)); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2cfed1f82f7ec..533487ae1c547 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1582,6 +1582,9 @@ impl<'a> State<'a> { try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(ii.span.lo)); try!(self.print_outer_attributes(&ii.attrs)); + if let ast::Defaultness::Default = ii.defaultness { + try!(self.word_nbsp("default")); + } match ii.node { ast::ImplItemKind::Const(ref ty, ref expr) => { try!(self.print_associated_const(ii.ident, &ty, Some(&expr), ii.vis)); diff --git a/src/test/run-pass/specialization/specialization-default-methods.rs b/src/test/run-pass/specialization/specialization-default-methods.rs index b2fad9d171f9d..3f0f21ff03f27 100644 --- a/src/test/run-pass/specialization/specialization-default-methods.rs +++ b/src/test/run-pass/specialization/specialization-default-methods.rs @@ -63,7 +63,8 @@ trait Bar { // / \ // Vec $Vec -impl Bar for T {} // use the provided method +// use the provided method +impl Bar for T {} impl Bar for i32 { fn bar(&self) -> i32 { 1 }