about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSeiichi Uchida <seuchida@gmail.com>2020-09-09 12:52:52 +0900
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2020-12-20 12:05:05 -0600
commit0d022d08d875c857ffcc4eab958b6be99528a98a (patch)
tree7c1c289ee08e2f9f26c2e1b6406c765bfd5c8728 /src
parentc536d80dc1c7c70c870ba5ec9d73943cd8e9e3f6 (diff)
downloadrust-0d022d08d875c857ffcc4eab958b6be99528a98a.tar.gz
rust-0d022d08d875c857ffcc4eab958b6be99528a98a.zip
Format error and typeof types (#4416)
* Add a test for #4357

* Format error and typeof types
Diffstat (limited to 'src')
-rw-r--r--src/types.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/types.rs b/src/types.rs
index 7eeee2ac979..6e1fc8fc387 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -7,7 +7,9 @@ use rustc_span::{symbol::kw, BytePos, Pos, Span};
 use crate::comment::{combine_strs_with_missing_comments, contains_comment};
 use crate::config::lists::*;
 use crate::config::{IndentStyle, TypeDensity, Version};
-use crate::expr::{format_expr, rewrite_assign_rhs, rewrite_tuple, rewrite_unary_prefix, ExprType};
+use crate::expr::{
+    format_expr, rewrite_assign_rhs, rewrite_call, rewrite_tuple, rewrite_unary_prefix, ExprType,
+};
 use crate::lists::{
     definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator,
 };
@@ -797,7 +799,14 @@ impl Rewrite for ast::Ty {
                 })
             }
             ast::TyKind::CVarArgs => Some("...".to_owned()),
-            ast::TyKind::Err | ast::TyKind::Typeof(..) => unreachable!(),
+            ast::TyKind::Err => Some(context.snippet(self.span).to_owned()),
+            ast::TyKind::Typeof(ref anon_const) => rewrite_call(
+                context,
+                "typeof",
+                &[anon_const.value.clone()],
+                self.span,
+                shape,
+            ),
         }
     }
 }