From fd30134cf84b134259fe8140e513b152e37f3f88 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Mon, 15 Jun 2020 07:19:45 -0400 Subject: [PATCH] Remove token tree from ReprKind::Other variant, expose ReprKind higher, remove debug println. --- crates/ra_hir/src/code_model.rs | 6 +++--- crates/ra_ide/src/syntax_highlighting.rs | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 6f9c56d2943..0007d7fa881 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -432,8 +432,8 @@ pub fn ty(self, db: &dyn HirDatabase) -> Type { Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id) } - pub fn is_packed(self, db: &dyn HirDatabase) -> bool { - matches!(db.struct_data(self.id).repr, Some(ReprKind::Packed)) + pub fn repr(self, db: &dyn HirDatabase) -> Option { + db.struct_data(self.id).repr.clone() } fn variant_data(self, db: &dyn HirDatabase) -> Arc { @@ -1266,7 +1266,7 @@ pub fn is_packed(&self, db: &dyn HirDatabase) -> bool { let adt = adt_id.into(); match adt { - Adt::Struct(s) => s.is_packed(db), + Adt::Struct(s) => matches!(s.repr(db), Some(ReprKind::Packed)), _ => false, } } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 0cab684eb47..b82b51efda5 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -574,13 +574,7 @@ fn highlight_element( }; let expr = field_expr.expr()?; - let ty = match sema.type_of_expr(&expr) { - Some(ty) => ty, - None => { - println!("No type :("); - return None; - } - }; + let ty = sema.type_of_expr(&expr)?; if !ty.is_packed(db) { return None; } -- 2.44.0