diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2024-12-01 22:10:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-01 22:10:23 -0500 |
| commit | 811eaebf7e1038cf229bc40f9f121f8709eeb5f4 (patch) | |
| tree | a6d713a8dda192eef05e00d1268b20c05cde8fd6 /compiler/rustc_hir_pretty/src | |
| parent | a522d78598415cdd614ccc6d961160f192f64b5c (diff) | |
| parent | d38f01312c1b827a7a0186c186482579a82cdec3 (diff) | |
| download | rust-811eaebf7e1038cf229bc40f9f121f8709eeb5f4.tar.gz rust-811eaebf7e1038cf229bc40f9f121f8709eeb5f4.zip | |
Rollup merge of #133589 - voidc:remove-array-len, r=boxyuwu
Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
Diffstat (limited to 'compiler/rustc_hir_pretty/src')
| -rw-r--r-- | compiler/rustc_hir_pretty/src/lib.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 5a5b39c694f..11864b61a94 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -118,7 +118,6 @@ impl<'a> State<'a> { Node::LetStmt(a) => self.print_local_decl(a), Node::Crate(..) => panic!("cannot print Crate"), Node::WherePredicate(pred) => self.print_where_predicate(pred), - Node::ArrayLenInfer(_) => self.word("_"), Node::Synthetic => unreachable!(), Node::Err(_) => self.word("/*ERROR*/"), } @@ -315,7 +314,7 @@ impl<'a> State<'a> { self.word("["); self.print_type(ty); self.word("; "); - self.print_array_length(length); + self.print_const_arg(length); self.word("]"); } hir::TyKind::Typeof(ref e) => { @@ -986,13 +985,6 @@ impl<'a> State<'a> { self.print_else(elseopt) } - fn print_array_length(&mut self, len: &hir::ArrayLen<'_>) { - match len { - hir::ArrayLen::Infer(..) => self.word("_"), - hir::ArrayLen::Body(ct) => self.print_const_arg(ct), - } - } - fn print_anon_const(&mut self, constant: &hir::AnonConst) { self.ann.nested(self, Nested::Body(constant.body)) } @@ -1001,6 +993,7 @@ impl<'a> State<'a> { match &const_arg.kind { ConstArgKind::Path(qpath) => self.print_qpath(qpath, true), ConstArgKind::Anon(anon) => self.print_anon_const(anon), + ConstArgKind::Infer(..) => self.word("_"), } } @@ -1073,12 +1066,12 @@ impl<'a> State<'a> { self.end() } - fn print_expr_repeat(&mut self, element: &hir::Expr<'_>, count: &hir::ArrayLen<'_>) { + fn print_expr_repeat(&mut self, element: &hir::Expr<'_>, count: &hir::ConstArg<'_>) { self.ibox(INDENT_UNIT); self.word("["); self.print_expr(element); self.word_space(";"); - self.print_array_length(count); + self.print_const_arg(count); self.word("]"); self.end() } |
