summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_ast_pretty/src/pprust/state
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pprust/state')
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/expr.rs10
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/item.rs35
2 files changed, 31 insertions, 14 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
index 609920180..39741a039 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
@@ -477,7 +477,7 @@ impl<'a> State<'a> {
self.word(".");
self.print_ident(*ident);
}
- ast::ExprKind::Index(expr, index) => {
+ ast::ExprKind::Index(expr, index, _) => {
self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX);
self.word("[");
self.print_expr(index);
@@ -697,15 +697,15 @@ pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> St
write!(template, "{n}").unwrap();
if p.format_options != Default::default() || p.format_trait != FormatTrait::Display
{
- template.push_str(":");
+ template.push(':');
}
if let Some(fill) = p.format_options.fill {
template.push(fill);
}
match p.format_options.alignment {
- Some(FormatAlignment::Left) => template.push_str("<"),
- Some(FormatAlignment::Right) => template.push_str(">"),
- Some(FormatAlignment::Center) => template.push_str("^"),
+ Some(FormatAlignment::Left) => template.push('<'),
+ Some(FormatAlignment::Right) => template.push('>'),
+ Some(FormatAlignment::Center) => template.push('^'),
None => {}
}
match p.format_options.sign {
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
index 5c01b7ea7..d27a44f12 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
@@ -30,10 +30,15 @@ impl<'a> State<'a> {
ast::ForeignItemKind::Fn(box ast::Fn { defaultness, sig, generics, body }) => {
self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs);
}
- ast::ForeignItemKind::Static(ty, mutbl, body) => {
- let def = ast::Defaultness::Final;
- self.print_item_const(ident, Some(*mutbl), ty, body.as_deref(), vis, def);
- }
+ ast::ForeignItemKind::Static(ty, mutbl, body) => self.print_item_const(
+ ident,
+ Some(*mutbl),
+ &ast::Generics::default(),
+ ty,
+ body.as_deref(),
+ vis,
+ ast::Defaultness::Final,
+ ),
ast::ForeignItemKind::TyAlias(box ast::TyAlias {
defaultness,
generics,
@@ -67,6 +72,7 @@ impl<'a> State<'a> {
&mut self,
ident: Ident,
mutbl: Option<ast::Mutability>,
+ generics: &ast::Generics,
ty: &ast::Ty,
body: Option<&ast::Expr>,
vis: &ast::Visibility,
@@ -82,6 +88,7 @@ impl<'a> State<'a> {
};
self.word_space(leading);
self.print_ident(ident);
+ self.print_generic_params(&generics.params);
self.word_space(":");
self.print_type(ty);
if body.is_some() {
@@ -92,6 +99,7 @@ impl<'a> State<'a> {
self.word_space("=");
self.print_expr(body);
}
+ self.print_where_clause(&generics.where_clause);
self.word(";");
self.end(); // end the outer cbox
}
@@ -158,20 +166,21 @@ impl<'a> State<'a> {
self.word(";");
}
ast::ItemKind::Static(box StaticItem { ty, mutability: mutbl, expr: body }) => {
- let def = ast::Defaultness::Final;
self.print_item_const(
item.ident,
Some(*mutbl),
+ &ast::Generics::default(),
ty,
body.as_deref(),
&item.vis,
- def,
+ ast::Defaultness::Final,
);
}
- ast::ItemKind::Const(box ast::ConstItem { defaultness, ty, expr }) => {
+ ast::ItemKind::Const(box ast::ConstItem { defaultness, generics, ty, expr }) => {
self.print_item_const(
item.ident,
None,
+ generics,
ty,
expr.as_deref(),
&item.vis,
@@ -515,8 +524,16 @@ impl<'a> State<'a> {
ast::AssocItemKind::Fn(box ast::Fn { defaultness, sig, generics, body }) => {
self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs);
}
- ast::AssocItemKind::Const(box ast::ConstItem { defaultness, ty, expr }) => {
- self.print_item_const(ident, None, ty, expr.as_deref(), vis, *defaultness);
+ ast::AssocItemKind::Const(box ast::ConstItem { defaultness, generics, ty, expr }) => {
+ self.print_item_const(
+ ident,
+ None,
+ generics,
+ ty,
+ expr.as_deref(),
+ vis,
+ *defaultness,
+ );
}
ast::AssocItemKind::Type(box ast::TyAlias {
defaultness,