mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 20:03:37 +00:00
Add pretty-printing for const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
d7695abb76
commit
b4ef753e8f
@ -646,6 +646,11 @@ impl Sig for ast::Generics {
|
||||
param_text.push_str(&pprust::bounds_to_string(¶m.bounds));
|
||||
// FIXME descend properly into bounds.
|
||||
}
|
||||
ast::GenericParamKind::Const { ref ty } => {
|
||||
param_text.push_str(&pprust::bounds_to_string(¶m.bounds));
|
||||
param_text.push_str("= ");
|
||||
param_text.push_str(&pprust::ty_to_string(&ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
text.push_str(¶m_text);
|
||||
|
@ -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(¶m.attrs)?;
|
||||
let lt = ast::Lifetime { id: param.id, ident: param.ident };
|
||||
s.print_lifetime_bounds(lt, ¶m.bounds)
|
||||
},
|
||||
}
|
||||
ast::GenericParamKind::Type { ref default } => {
|
||||
s.print_outer_attributes_inline(¶m.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(¶m.attrs)?;
|
||||
s.word_space("const")?;
|
||||
s.print_ident(param.ident)?;
|
||||
s.s.space()?;
|
||||
s.word_space(":")?;
|
||||
s.print_type(ty)?;
|
||||
s.print_type_bounds(":", ¶m.bounds)
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user