Better codes

Signed-off-by: JmPotato <ghzpotato@gmail.com>
This commit is contained in:
JmPotato 2020-08-10 17:51:45 +08:00
parent 4d9c8821e5
commit 958b91c1e8

View file

@ -61,15 +61,11 @@ impl ShortLabel for ast::TypeAlias {
impl ShortLabel for ast::Const {
fn short_label(&self) -> Option<String> {
match short_label_from_ty(self, self.ty(), "const ") {
Some(buf) => {
let mut new_buf = buf;
let body = self.body().unwrap();
format_to!(new_buf, " = {}", body.syntax());
Some(new_buf)
}
None => None,
let mut new_buf = short_label_from_ty(self, self.ty(), "const ")?;
if let Some(expr) = self.body() {
format_to!(new_buf, " = {}", expr.syntax());
}
Some(new_buf)
}
}