summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_hir_pretty
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /compiler/rustc_hir_pretty
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_hir_pretty')
-rw-r--r--compiler/rustc_hir_pretty/src/lib.rs106
1 files changed, 53 insertions, 53 deletions
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs
index c021fca71..74f5b3590 100644
--- a/compiler/rustc_hir_pretty/src/lib.rs
+++ b/compiler/rustc_hir_pretty/src/lib.rs
@@ -242,7 +242,7 @@ pub fn enum_def_to_string(
impl<'a> State<'a> {
pub fn bclose_maybe_open(&mut self, span: rustc_span::Span, close_box: bool) {
self.maybe_print_comment(span.hi());
- self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
+ self.break_offset_if_not_bol(1, -INDENT_UNIT);
self.word("}");
if close_box {
self.end(); // close the outer-box
@@ -1366,10 +1366,6 @@ impl<'a> State<'a> {
self.ibox(INDENT_UNIT);
self.ann.pre(self, AnnNode::Expr(expr));
match expr.kind {
- hir::ExprKind::Box(expr) => {
- self.word_space("box");
- self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
- }
hir::ExprKind::Array(exprs) => {
self.print_expr_vec(exprs);
}
@@ -1656,61 +1652,65 @@ impl<'a> State<'a> {
generic_args: &hir::GenericArgs<'_>,
colons_before_params: bool,
) {
- if generic_args.parenthesized {
- self.word("(");
- self.commasep(Inconsistent, generic_args.inputs(), |s, ty| s.print_type(ty));
- self.word(")");
+ match generic_args.parenthesized {
+ hir::GenericArgsParentheses::No => {
+ let start = if colons_before_params { "::<" } else { "<" };
+ let empty = Cell::new(true);
+ let start_or_comma = |this: &mut Self| {
+ if empty.get() {
+ empty.set(false);
+ this.word(start)
+ } else {
+ this.word_space(",")
+ }
+ };
+
+ let mut nonelided_generic_args: bool = false;
+ let elide_lifetimes = generic_args.args.iter().all(|arg| match arg {
+ GenericArg::Lifetime(lt) if lt.is_elided() => true,
+ GenericArg::Lifetime(_) => {
+ nonelided_generic_args = true;
+ false
+ }
+ _ => {
+ nonelided_generic_args = true;
+ true
+ }
+ });
- self.space_if_not_bol();
- self.word_space("->");
- self.print_type(generic_args.bindings[0].ty());
- } else {
- let start = if colons_before_params { "::<" } else { "<" };
- let empty = Cell::new(true);
- let start_or_comma = |this: &mut Self| {
- if empty.get() {
- empty.set(false);
- this.word(start)
- } else {
- this.word_space(",")
+ if nonelided_generic_args {
+ start_or_comma(self);
+ self.commasep(Inconsistent, generic_args.args, |s, generic_arg| {
+ match generic_arg {
+ GenericArg::Lifetime(lt) if !elide_lifetimes => s.print_lifetime(lt),
+ GenericArg::Lifetime(_) => {}
+ GenericArg::Type(ty) => s.print_type(ty),
+ GenericArg::Const(ct) => s.print_anon_const(&ct.value),
+ GenericArg::Infer(_inf) => s.word("_"),
+ }
+ });
}
- };
- let mut nonelided_generic_args: bool = false;
- let elide_lifetimes = generic_args.args.iter().all(|arg| match arg {
- GenericArg::Lifetime(lt) if lt.is_elided() => true,
- GenericArg::Lifetime(_) => {
- nonelided_generic_args = true;
- false
+ for binding in generic_args.bindings {
+ start_or_comma(self);
+ self.print_type_binding(binding);
}
- _ => {
- nonelided_generic_args = true;
- true
- }
- });
-
- if nonelided_generic_args {
- start_or_comma(self);
- self.commasep(
- Inconsistent,
- generic_args.args,
- |s, generic_arg| match generic_arg {
- GenericArg::Lifetime(lt) if !elide_lifetimes => s.print_lifetime(lt),
- GenericArg::Lifetime(_) => {}
- GenericArg::Type(ty) => s.print_type(ty),
- GenericArg::Const(ct) => s.print_anon_const(&ct.value),
- GenericArg::Infer(_inf) => s.word("_"),
- },
- );
- }
- for binding in generic_args.bindings {
- start_or_comma(self);
- self.print_type_binding(binding);
+ if !empty.get() {
+ self.word(">")
+ }
}
+ hir::GenericArgsParentheses::ParenSugar => {
+ self.word("(");
+ self.commasep(Inconsistent, generic_args.inputs(), |s, ty| s.print_type(ty));
+ self.word(")");
- if !empty.get() {
- self.word(">")
+ self.space_if_not_bol();
+ self.word_space("->");
+ self.print_type(generic_args.bindings[0].ty());
+ }
+ hir::GenericArgsParentheses::ReturnTypeNotation => {
+ self.word("(..)");
}
}
}