Format error and typeof types (#4416)

* Add a test for #4357

* Format error and typeof types
This commit is contained in:
Seiichi Uchida 2020-09-09 12:52:52 +09:00 committed by Caleb Cartwright
parent c536d80dc1
commit 0d022d08d8
3 changed files with 21 additions and 2 deletions

View file

@ -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,
),
}
}
}

View file

@ -166,3 +166,9 @@ impl<T: ? const Trait> Foo<T> {
Self(t)
}
}
// #4357
type T = typeof(
1);
impl T for .. {
}

View file

@ -177,3 +177,7 @@ impl<T: ?const Trait> Foo<T> {
Self(t)
}
}
// #4357
type T = typeof(1);
impl T for .. {}