about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-02-05 16:50:16 +0100
committervarkor <github@varkor.com>2019-02-07 15:02:16 +0100
commitb4ef753e8f45a67f6756ad4c9103e0e327a1e078 (patch)
tree0f166cda41204e15aed2a8e7e0e86b87ec7335da /src/libsyntax
parentd7695abb7667d2e8b7a010282ad5f44abbc58a58 (diff)
downloadrust-b4ef753e8f45a67f6756ad4c9103e0e327a1e078.tar.gz
rust-b4ef753e8f45a67f6756ad4c9103e0e327a1e078.zip
Add pretty-printing for const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/print/pprust.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index c7c4c4f1620..c670f47b597 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1025,6 +1025,7 @@ impl<'a> State<'a> {
         match generic_arg {
             GenericArg::Lifetime(lt) => self.print_lifetime(*lt),
             GenericArg::Type(ty) => self.print_type(ty),
+            GenericArg::Const(ct) => self.print_expr(&ct.value),
         }
     }
 
@@ -2929,7 +2930,7 @@ impl<'a> State<'a> {
                     s.print_outer_attributes_inline(&param.attrs)?;
                     let lt = ast::Lifetime { id: param.id, ident: param.ident };
                     s.print_lifetime_bounds(lt, &param.bounds)
-                },
+                }
                 ast::GenericParamKind::Type { ref default } => {
                     s.print_outer_attributes_inline(&param.attrs)?;
                     s.print_ident(param.ident)?;
@@ -2943,6 +2944,15 @@ impl<'a> State<'a> {
                         _ => Ok(())
                     }
                 }
+                ast::GenericParamKind::Const { ref ty } => {
+                    s.print_outer_attributes_inline(&param.attrs)?;
+                    s.word_space("const")?;
+                    s.print_ident(param.ident)?;
+                    s.s.space()?;
+                    s.word_space(":")?;
+                    s.print_type(ty)?;
+                    s.print_type_bounds(":", &param.bounds)
+                }
             }
         })?;