]> git.lizzy.rs Git - rust.git/commitdiff
Remove token tree from ReprKind::Other variant, expose ReprKind higher, remove debug...
authorPaul Daniel Faria <nashenas88@users.noreply.github.com>
Mon, 15 Jun 2020 11:19:45 +0000 (07:19 -0400)
committerPaul Daniel Faria <Nashenas88@users.noreply.github.com>
Mon, 10 Aug 2020 12:44:54 +0000 (08:44 -0400)
crates/ra_hir/src/code_model.rs
crates/ra_ide/src/syntax_highlighting.rs

index 6f9c56d2943adfea38e7d53992bd1642c28a7384..0007d7fa881a1fdf95a8de92b5d0c7eca4c04d10 100644 (file)
@@ -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<ReprKind> {
+        db.struct_data(self.id).repr.clone()
     }
 
     fn variant_data(self, db: &dyn HirDatabase) -> Arc<VariantData> {
@@ -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,
         }
     }
index 0cab684eb475dd02a8c25d5ddd0b4b2532fd48bb..b82b51efda5b419215c631c0081771acdca58d29 100644 (file)
@@ -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;
             }