Repository: rust-lang/rust-analyzer
Pull request #14857 (2023-05-20 08:38:36)

internal: Shrink ProcMacroExpander from 8 to 4 bytes

Veykril: @bors r+
bors: :pushpin: Commit 76d153ba2feb5f7d5f70ae41d8c9608f920eb1dc has been approved by `Veykril`

It is now in the [queue](https://bors.rust-lang.org/homu/queue/rust-analyzer) for this repository.

<!-- @bors r=Veykril 76d153ba2feb5f7d5f70ae41d8c9608f920eb1dc -->
<!-- homu: {"type":"Approved","sha":"76d153ba2feb5f7d5f70ae41d8c9608f920eb1dc","approver":"Veykril","queue":"https://bors.rust-lang.org/homu/queue/rust-analyzer"} -->
bors: :hourglass: Testing commit 76d153ba2feb5f7d5f70ae41d8c9608f920eb1dc with merge 68ddfc052bf634a762282560130f589c4d9435c4...
<!-- homu: {"type":"BuildStarted","head_sha":"76d153ba2feb5f7d5f70ae41d8c9608f920eb1dc","merge_sha":"68ddfc052bf634a762282560130f589c4d9435c4"} -->
bors: :broken_heart: Test failed - [checks-actions](https://github.com/rust-lang/rust-analyzer/actions/runs/5031322940/jobs/9024368563)
<!-- homu: {"type":"BuildFailed","builder_url":"https://github.com/rust-lang/rust-analyzer/actions/runs/5031322940/jobs/9024368563","builder_name":"checks-actions"} -->
Veykril: @bors r+
bors: :pushpin: Commit b68226e7fee4561b2371b14291973008053293b9 has been approved by `Veykril`

It is now in the [queue](https://bors.rust-lang.org/homu/queue/rust-analyzer) for this repository.

<!-- @bors r=Veykril b68226e7fee4561b2371b14291973008053293b9 -->
<!-- homu: {"type":"Approved","sha":"b68226e7fee4561b2371b14291973008053293b9","approver":"Veykril","queue":"https://bors.rust-lang.org/homu/queue/rust-analyzer"} -->
bors: :hourglass: Testing commit b68226e7fee4561b2371b14291973008053293b9 with merge a4096514045a681a76ed7e33dc0599f927a9ba8e...
<!-- homu: {"type":"BuildStarted","head_sha":"b68226e7fee4561b2371b14291973008053293b9","merge_sha":"a4096514045a681a76ed7e33dc0599f927a9ba8e"} -->
bors: :broken_heart: Test failed - [checks-actions](https://github.com/rust-lang/rust-analyzer/actions/runs/5031358467/jobs/9024426357)
<!-- homu: {"type":"BuildFailed","builder_url":"https://github.com/rust-lang/rust-analyzer/actions/runs/5031358467/jobs/9024426357","builder_name":"checks-actions"} -->

Patch:
diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs
index a387bdbc19..ea682f5cbd 100644
--- a/crates/hir-def/src/body.rs
+++ b/crates/hir-def/src/body.rs
@@ -221,15 +221,15 @@ impl Body {
 
     pub fn walk_bindings_in_pat(&self, pat_id: PatId, mut f: impl FnMut(BindingId)) {
         self.walk_pats(pat_id, &mut |pat| {
-            if let Pat::Bind { id, .. } = &self[pat] {
+            if let Pat::Bind { id, .. } = pat {
                 f(*id);
             }
         });
     }
 
-    pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(PatId)) {
+    pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(&Pat)) {
         let pat = &self[pat_id];
-        f(pat_id);
+        f(pat);
         match pat {
             Pat::Range { .. }
             | Pat::Lit(..)
diff --git a/crates/hir-expand/src/proc_macro.rs b/crates/hir-expand/src/proc_macro.rs
index dc04a41155..c9539210ab 100644
--- a/crates/hir-expand/src/proc_macro.rs
+++ b/crates/hir-expand/src/proc_macro.rs
@@ -7,20 +7,23 @@ use crate::{db::ExpandDatabase, tt, ExpandError, ExpandResult};
 
 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
 pub struct ProcMacroExpander {
-    proc_macro_id: Option<ProcMacroId>,
+    proc_macro_id: ProcMacroId,
 }
 
+const DUMMY_ID: u32 = !0;
+
 impl ProcMacroExpander {
     pub fn new(proc_macro_id: ProcMacroId) -> Self {
-        Self { proc_macro_id: Some(proc_macro_id) }
+        assert_ne!(proc_macro_id.0, DUMMY_ID);
+        Self { proc_macro_id }
     }
 
     pub fn dummy() -> Self {
-        Self { proc_macro_id: None }
+        Self { proc_macro_id: ProcMacroId(DUMMY_ID) }
     }
 
     pub fn is_dummy(&self) -> bool {
-        self.proc_macro_id.is_none()
+        self.proc_macro_id.0 == DUMMY_ID
     }
 
     pub fn expand(
@@ -32,7 +35,10 @@ impl ProcMacroExpander {
         attr_arg: Option<&tt::Subtree>,
     ) -> ExpandResult<tt::Subtree> {
         match self.proc_macro_id {
-            Some(id) => {
+            ProcMacroId(DUMMY_ID) => {
+                ExpandResult::new(tt::Subtree::empty(), ExpandError::UnresolvedProcMacro(def_crate))
+            }
+            ProcMacroId(id) => {
                 let proc_macros = db.proc_macros();
                 let proc_macros = match proc_macros.get(&def_crate) {
                     Some(Ok(proc_macros)) => proc_macros,
@@ -44,13 +50,13 @@ impl ProcMacroExpander {
                         );
                     }
                 };
-                let proc_macro = match proc_macros.get(id.0 as usize) {
+                let proc_macro = match proc_macros.get(id as usize) {
                     Some(proc_macro) => proc_macro,
                     None => {
                         never!(
                             "Proc macro index out of bounds: the length is {} but the index is {}",
                             proc_macros.len(),
-                            id.0
+                            id
                         );
                         return ExpandResult::new(
                             tt::Subtree::empty(),
@@ -81,9 +87,6 @@ impl ProcMacroExpander {
                     },
                 }
             }
-            None => {
-                ExpandResult::new(tt::Subtree::empty(), ExpandError::UnresolvedProcMacro(def_crate))
-            }
         }
     }
 }
diff --git a/crates/hir-ty/src/diagnostics/match_check.rs b/crates/hir-ty/src/diagnostics/match_check.rs
index 2b78e7e14f..125df2ba76 100644
--- a/crates/hir-ty/src/diagnostics/match_check.rs
+++ b/crates/hir-ty/src/diagnostics/match_check.rs
@@ -147,7 +147,7 @@ impl<'a> PatCtxt<'a> {
             }
 
             hir_def::hir::Pat::Bind { id, subpat, .. } => {
-                let bm = self.infer.binding_modes[id];
+                let bm = self.infer.pat_binding_modes[&pat];
                 ty = &self.infer[id];
                 let name = &self.body.bindings[id].name;
                 match (bm, ty.kind(Interner)) {
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index f01ee1b4e6..32e8703143 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -389,7 +389,7 @@ pub struct InferenceResult {
     standard_types: InternedStandardTypes,
     /// Stores the types which were implicitly dereferenced in pattern binding modes.
     pub pat_adjustments: FxHashMap<PatId, Vec<Ty>>,
-    pub binding_modes: ArenaMap<BindingId, BindingMode>,
+    pub pat_binding_modes: FxHashMap<PatId, BindingMode>,
     pub expr_adjustments: FxHashMap<ExprId, Vec<Adjustment>>,
     pub(crate) closure_info: FxHashMap<ClosureId, (Vec<CapturedItem>, FnTrait)>,
     // FIXME: remove this field
diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs
index a7d9246b7c..87ec2755d0 100644
--- a/crates/hir-ty/src/infer/closure.rs
+++ b/crates/hir-ty/src/infer/closure.rs
@@ -504,27 +504,9 @@ impl InferenceContext<'_> {
                 self.consume_exprs(args.iter().copied());
             }
             Expr::Match { expr, arms } => {
+                self.consume_expr(*expr);
                 for arm in arms.iter() {
                     self.consume_expr(arm.expr);
-                    if let Some(guard) = arm.guard {
-                        self.consume_expr(guard);
-                    }
-                }
-                self.walk_expr(*expr);
-                if let Some(discr_place) = self.place_of_expr(*expr) {
-                    if self.is_upvar(&discr_place) {
-                        let mut capture_mode = None;
-                        for arm in arms.iter() {
-                            self.walk_pat(&mut capture_mode, arm.pat);
-                        }
-                        if let Some(c) = capture_mode {
-                            self.push_capture(CapturedItemWithoutTy {
-                                place: discr_place,
-                                kind: c,
-                                span: (*expr).into(),
-                            })
-                        }
-                    }
                 }
             }
             Expr::Break { expr, label: _ }
@@ -636,57 +618,6 @@ impl InferenceContext<'_> {
         }
     }
 
-    fn walk_pat(&mut self, result: &mut Option<CaptureKind>, pat: PatId) {
-        let mut update_result = |ck: CaptureKind| match result {
-            Some(r) => {
-                *r = cmp::max(*r, ck);
-            }
-            None => *result = Some(ck),
-        };
-        self.body.walk_pats(pat, &mut |p| match &self.body[p] {
-            Pat::Ref { .. }
-            | Pat::Box { .. }
-            | Pat::Missing
-            | Pat::Wild
-            | Pat::Tuple { .. }
-            | Pat::Or(_) => (),
-            Pat::TupleStruct { .. } | Pat::Record { .. } => {
-                if let Some(variant) = self.result.variant_resolution_for_pat(p) {
-                    let adt = variant.adt_id();
-                    let is_multivariant = match adt {
-                        hir_def::AdtId::EnumId(e) => self.db.enum_data(e).variants.len() != 1,
-                        _ => false,
-                    };
-                    if is_multivariant {
-                        update_result(CaptureKind::ByRef(BorrowKind::Shared));
-                    }
-                }
-            }
-            Pat::Slice { .. }
-            | Pat::ConstBlock(_)
-            | Pat::Path(_)
-            | Pat::Lit(_)
-            | Pat::Range { .. } => {
-                update_result(CaptureKind::ByRef(BorrowKind::Shared));
-            }
-            Pat::Bind { id, .. } => match self.result.binding_modes[*id] {
-                crate::BindingMode::Move => {
-                    if self.is_ty_copy(self.result.type_of_binding[*id].clone()) {
-                        update_result(CaptureKind::ByRef(BorrowKind::Shared));
-                    } else {
-                        update_result(CaptureKind::ByValue);
-                    }
-                }
-                crate::BindingMode::Ref(r) => match r {
-                    Mutability::Mut => update_result(CaptureKind::ByRef(BorrowKind::Mut {
-                        allow_two_phase_borrow: false,
-                    })),
-                    Mutability::Not => update_result(CaptureKind::ByRef(BorrowKind::Shared)),
-                },
-            },
-        });
-    }
-
     fn expr_ty(&self, expr: ExprId) -> Ty {
         self.result[expr].clone()
     }
@@ -710,14 +641,14 @@ impl InferenceContext<'_> {
         false
     }
 
-    fn is_ty_copy(&mut self, ty: Ty) -> bool {
+    fn is_ty_copy(&self, ty: Ty) -> bool {
         if let TyKind::Closure(id, _) = ty.kind(Interner) {
             // FIXME: We handle closure as a special case, since chalk consider every closure as copy. We
             // should probably let chalk know which closures are copy, but I don't know how doing it
             // without creating query cycles.
             return self.result.closure_info.get(id).map(|x| x.1 == FnTrait::Fn).unwrap_or(true);
         }
-        self.table.resolve_completely(ty).is_copy(self.db, self.owner)
+        ty.is_copy(self.db, self.owner)
     }
 
     fn select_from_expr(&mut self, expr: ExprId) {
diff --git a/crates/hir-ty/src/infer/pat.rs b/crates/hir-ty/src/infer/pat.rs
index 05f6fcaead..dd56dc3d9c 100644
--- a/crates/hir-ty/src/infer/pat.rs
+++ b/crates/hir-ty/src/infer/pat.rs
@@ -340,7 +340,7 @@ impl<'a> InferenceContext<'a> {
         } else {
             BindingMode::convert(mode)
         };
-        self.result.binding_modes.insert(binding, mode);
+        self.result.pat_binding_modes.insert(pat, mode);
 
         let inner_ty = match subpat {
             Some(subpat) => self.infer_pat(subpat, &expected, default_bm),
@@ -439,7 +439,7 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool {
 pub(super) fn contains_explicit_ref_binding(body: &Body, pat_id: PatId) -> bool {
     let mut res = false;
     body.walk_pats(pat_id, &mut |pat| {
-        res |= matches!(body[pat], Pat::Bind { id, .. } if body.bindings[id].mode == BindingAnnotation::Ref);
+        res |= matches!(pat, Pat::Bind { id, .. } if body.bindings[*id].mode == BindingAnnotation::Ref);
     });
     res
 }
diff --git a/crates/hir-ty/src/mir.rs b/crates/hir-ty/src/mir.rs
index f8451f28d7..11c35dfb8a 100644
--- a/crates/hir-ty/src/mir.rs
+++ b/crates/hir-ty/src/mir.rs
@@ -205,7 +205,7 @@ type PlaceElem = ProjectionElem<LocalId, Ty>;
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct Place {
     pub local: LocalId,
-    pub projection: Box<[PlaceElem]>,
+    pub projection: Vec<PlaceElem>,
 }
 
 impl Place {
@@ -216,20 +216,13 @@ impl Place {
     fn iterate_over_parents(&self) -> impl Iterator<Item = Place> + '_ {
         (0..self.projection.len())
             .map(|x| &self.projection[0..x])
-            .map(|x| Place { local: self.local, projection: x.to_vec().into() })
-    }
-
-    fn project(&self, projection: PlaceElem) -> Place {
-        Place {
-            local: self.local,
-            projection: self.projection.iter().cloned().chain([projection]).collect(),
-        }
+            .map(|x| Place { local: self.local, projection: x.to_vec() })
     }
 }
 
 impl From<LocalId> for Place {
     fn from(local: LocalId) -> Self {
-        Self { local, projection: vec![].into() }
+        Self { local, projection: vec![] }
     }
 }
 
@@ -444,7 +437,7 @@ pub enum TerminatorKind {
         /// These are owned by the callee, which is free to modify them.
         /// This allows the memory occupied by "by-value" arguments to be
         /// reused across function calls without duplicating the contents.
-        args: Box<[Operand]>,
+        args: Vec<Operand>,
         /// Where the returned value will be written
         destination: Place,
         /// Where to go after this call returns. If none, the call necessarily diverges.
@@ -901,7 +894,7 @@ pub enum Rvalue {
     ///
     /// Disallowed after deaggregation for all aggregate kinds except `Array` and `Generator`. After
     /// generator lowering, `Generator` aggregate kinds are disallowed too.
-    Aggregate(AggregateKind, Box<[Operand]>),
+    Aggregate(AggregateKind, Vec<Operand>),
 
     /// Transmutes a `*mut u8` into shallow-initialized `Box<T>`.
     ///
@@ -1018,7 +1011,7 @@ impl MirBody {
                                 for_operand(o2, &mut f);
                             }
                             Rvalue::Aggregate(_, ops) => {
-                                for op in ops.iter_mut() {
+                                for op in ops {
                                     for_operand(op, &mut f);
                                 }
                             }
@@ -1065,27 +1058,6 @@ impl MirBody {
             }
         }
     }
-
-    fn shrink_to_fit(&mut self) {
-        let MirBody {
-            basic_blocks,
-            locals,
-            start_block: _,
-            owner: _,
-            binding_locals,
-            param_locals,
-            closures,
-        } = self;
-        basic_blocks.shrink_to_fit();
-        locals.shrink_to_fit();
-        binding_locals.shrink_to_fit();
-        param_locals.shrink_to_fit();
-        closures.shrink_to_fit();
-        for (_, b) in basic_blocks.iter_mut() {
-            let BasicBlock { statements, terminator: _, is_cleanup: _ } = b;
-            statements.shrink_to_fit();
-        }
-    }
 }
 
 #[derive(Debug, PartialEq, Eq, Clone, Copy)]
diff --git a/crates/hir-ty/src/mir/borrowck.rs b/crates/hir-ty/src/mir/borrowck.rs
index 66af6658e8..412390d3fa 100644
--- a/crates/hir-ty/src/mir/borrowck.rs
+++ b/crates/hir-ty/src/mir/borrowck.rs
@@ -93,7 +93,7 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec<MovedOutOfRef>
         Operand::Copy(p) | Operand::Move(p) => {
             let mut ty: Ty = body.locals[p.local].ty.clone();
             let mut is_dereference_of_ref = false;
-            for proj in &*p.projection {
+            for proj in &p.projection {
                 if *proj == ProjectionElem::Deref && ty.as_reference().is_some() {
                     is_dereference_of_ref = true;
                 }
@@ -143,7 +143,7 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec<MovedOutOfRef>
                         for_operand(o2, statement.span);
                     }
                     Rvalue::Aggregate(_, ops) => {
-                        for op in ops.iter() {
+                        for op in ops {
                             for_operand(op, statement.span);
                         }
                     }
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index e4acd10aa9..327161b99e 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -562,7 +562,7 @@ impl Evaluator<'_> {
         let mut ty: Ty =
             self.ty_filler(&locals.body.locals[p.local].ty, locals.subst, locals.body.owner)?;
         let mut metadata: Option<IntervalOrOwned> = None; // locals are always sized
-        for proj in &*p.projection {
+        for proj in &p.projection {
             let prev_ty = ty.clone();
             ty = proj.projected_ty(
                 ty,
diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs
index f73b25d83f..292a771baf 100644
--- a/crates/hir-ty/src/mir/lower.rs
+++ b/crates/hir-ty/src/mir/lower.rs
@@ -387,7 +387,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
                                 current,
                                 place,
                                 ty,
-                                Box::new([]),
+                                vec![],
                                 expr_id.into(),
                             )?;
                         }
@@ -561,7 +561,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
                 };
                 self.push_assignment(current, ref_mut_iterator_place.clone(), Rvalue::Ref(BorrowKind::Mut { allow_two_phase_borrow: false }, iterator_place), expr_id.into());
                 self.lower_loop(current, place, label, expr_id.into(), |this, begin| {
-                    let Some(current) = this.lower_call(iter_next_fn_op, Box::new([Operand::Copy(ref_mut_iterator_place)]), option_item_place.clone(), begin, false, expr_id.into())?
+                    let Some(current) = this.lower_call(iter_next_fn_op, vec![Operand::Copy(ref_mut_iterator_place)], option_item_place.clone(), begin, false, expr_id.into())?
                     else {
                         return Ok(());
                     };
@@ -758,7 +758,8 @@ impl<'ctx> MirLowerCtx<'ctx> {
                                         match x {
                                             Some(x) => x,
                                             None => {
-                                                let p = sp.project(ProjectionElem::Field(FieldId {
+                                                let mut p = sp.clone();
+                                                p.projection.push(ProjectionElem::Field(FieldId {
                                                     parent: variant_id,
                                                     local_id: LocalFieldId::from_raw(RawIdx::from(i as u32)),
                                                 }));
@@ -781,7 +782,10 @@ impl<'ctx> MirLowerCtx<'ctx> {
                         };
                         let local_id =
                             variant_data.field(name).ok_or(MirLowerError::UnresolvedField)?;
-                        let place = place.project(PlaceElem::Field(FieldId { parent: union_id.into(), local_id }));
+                        let mut place = place;
+                        place
+                            .projection
+                            .push(PlaceElem::Field(FieldId { parent: union_id.into(), local_id }));
                         self.lower_expr_to_place(*expr, place, current)
                     }
                 }
@@ -822,7 +826,8 @@ impl<'ctx> MirLowerCtx<'ctx> {
                 let Some((operand, current)) = self.lower_expr_to_some_operand(*expr, current)? else {
                     return Ok(None);
                 };
-                let p = place.project(ProjectionElem::Deref);
+                let mut p = place;
+                p.projection.push(ProjectionElem::Deref);
                 self.push_assignment(current, p, operand.into(), expr_id.into());
                 Ok(Some(current))
             },
@@ -1026,7 +1031,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
                 self.push_assignment(
                     current,
                     place,
-                    Rvalue::Aggregate(AggregateKind::Closure(ty), operands.into()),
+                    Rvalue::Aggregate(AggregateKind::Closure(ty), operands),
                     expr_id.into(),
                 );
                 Ok(Some(current))
@@ -1123,11 +1128,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
                 let index = name
                     .as_tuple_index()
                     .ok_or(MirLowerError::TypeError("named field on tuple"))?;
-                *place = place.project(ProjectionElem::TupleOrClosureField(index))
+                place.projection.push(ProjectionElem::TupleOrClosureField(index))
             } else {
                 let field =
                     self.infer.field_resolution(expr_id).ok_or(MirLowerError::UnresolvedField)?;
-                *place = place.project(ProjectionElem::Field(field));
+                place.projection.push(ProjectionElem::Field(field));
             }
         } else {
             not_supported!("")
@@ -1237,7 +1242,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
         prev_block: BasicBlockId,
         place: Place,
         ty: Ty,
-        fields: Box<[Operand]>,
+        fields: Vec<Operand>,
         span: MirSpan,
     ) -> Result<BasicBlockId> {
         let subst = match ty.kind(Interner) {
@@ -1275,13 +1280,13 @@ impl<'ctx> MirLowerCtx<'ctx> {
         else {
             return Ok(None);
         };
-        self.lower_call(func, args.into(), place, current, is_uninhabited, span)
+        self.lower_call(func, args, place, current, is_uninhabited, span)
     }
 
     fn lower_call(
         &mut self,
         func: Operand,
-        args: Box<[Operand]>,
+        args: Vec<Operand>,
         place: Place,
         current: BasicBlockId,
         is_uninhabited: bool,
@@ -1739,13 +1744,12 @@ pub fn mir_body_for_closure_query(
             match r {
                 Some(x) => {
                     p.local = closure_local;
-                    let mut next_projs = vec![PlaceElem::TupleOrClosureField(x.1)];
-                    let prev_projs = mem::take(&mut p.projection);
+                    let prev_projs =
+                        mem::replace(&mut p.projection, vec![PlaceElem::TupleOrClosureField(x.1)]);
                     if x.0.kind != CaptureKind::ByValue {
-                        next_projs.push(ProjectionElem::Deref);
+                        p.projection.push(ProjectionElem::Deref);
                     }
-                    next_projs.extend(prev_projs.iter().cloned().skip(x.0.place.projections.len()));
-                    p.projection = next_projs.into();
+                    p.projection.extend(prev_projs.into_iter().skip(x.0.place.projections.len()));
                 }
                 None => err = Some(p.clone()),
             }
@@ -1760,7 +1764,6 @@ pub fn mir_body_for_closure_query(
     if let Some(err) = err {
         return Err(MirLowerError::UnresolvedUpvar(err));
     }
-    ctx.result.shrink_to_fit();
     Ok(Arc::new(ctx.result))
 }
 
@@ -1777,8 +1780,7 @@ pub fn mir_body_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Result<Arc<Mi
     });
     let body = db.body(def);
     let infer = db.infer(def);
-    let mut result = lower_to_mir(db, def, &body, &infer, body.body_expr)?;
-    result.shrink_to_fit();
+    let result = lower_to_mir(db, def, &body, &infer, body.body_expr)?;
     Ok(Arc::new(result))
 }
 
diff --git a/crates/hir-ty/src/mir/lower/as_place.rs b/crates/hir-ty/src/mir/lower/as_place.rs
index d2c8d9a089..9515c18bb6 100644
--- a/crates/hir-ty/src/mir/lower/as_place.rs
+++ b/crates/hir-ty/src/mir/lower/as_place.rs
@@ -65,7 +65,7 @@ impl MirLowerCtx<'_> {
                     )? else {
                         return Ok(None);
                     };
-                    x.0 = x.0.project(ProjectionElem::Deref);
+                    x.0.projection.push(ProjectionElem::Deref);
                     Ok(Some(x))
                 }
                 Adjust::Deref(Some(od)) => {
@@ -139,14 +139,15 @@ impl MirLowerCtx<'_> {
                         let ty = self.expr_ty_without_adjust(expr_id);
                         let ref_ty =
                             TyKind::Ref(Mutability::Not, static_lifetime(), ty).intern(Interner);
-                        let temp: Place = self.temp(ref_ty, current, expr_id.into())?.into();
+                        let mut temp: Place = self.temp(ref_ty, current, expr_id.into())?.into();
                         self.push_assignment(
                             current,
                             temp.clone(),
                             Operand::Static(s).into(),
                             expr_id.into(),
                         );
-                        Ok(Some((temp.project(ProjectionElem::Deref), current)))
+                        temp.projection.push(ProjectionElem::Deref);
+                        Ok(Some((temp, current)))
                     }
                     _ => try_rvalue(self),
                 }
@@ -195,7 +196,7 @@ impl MirLowerCtx<'_> {
                     let Some((mut r, current)) = self.lower_expr_as_place(current, *expr, true)? else {
                         return Ok(None);
                     };
-                    r = r.project(ProjectionElem::Deref);
+                    r.projection.push(ProjectionElem::Deref);
                     Ok(Some((r, current)))
                 }
                 _ => try_rvalue(self),
@@ -252,7 +253,7 @@ impl MirLowerCtx<'_> {
                 let Some(current) = self.lower_expr_to_place(*index, l_index.into(), current)? else {
                     return Ok(None);
                 };
-                p_base = p_base.project(ProjectionElem::Index(l_index));
+                p_base.projection.push(ProjectionElem::Index(l_index));
                 Ok(Some((p_base, current)))
             }
             _ => try_rvalue(self),
@@ -282,10 +283,10 @@ impl MirLowerCtx<'_> {
             )
             .intern(Interner),
         );
-        let Some(current) = self.lower_call(index_fn_op, Box::new([Operand::Copy(place), index_operand]), result.clone(), current, false, span)? else {
+        let Some(current) = self.lower_call(index_fn_op, vec![Operand::Copy(place), index_operand], result.clone(), current, false, span)? else {
             return Ok(None);
         };
-        result = result.project(ProjectionElem::Deref);
+        result.projection.push(ProjectionElem::Deref);
         Ok(Some((result, current)))
     }
 
@@ -329,10 +330,10 @@ impl MirLowerCtx<'_> {
             .intern(Interner),
         );
         let mut result: Place = self.temp(target_ty_ref, current, span)?.into();
-        let Some(current) = self.lower_call(deref_fn_op, Box::new([Operand::Copy(ref_place)]), result.clone(), current, false, span)? else {
+        let Some(current) = self.lower_call(deref_fn_op, vec![Operand::Copy(ref_place)], result.clone(), current, false, span)? else {
             return Ok(None);
         };
-        result = result.project(ProjectionElem::Deref);
+        result.projection.push(ProjectionElem::Deref);
         Ok(Some((result, current)))
     }
 }
diff --git a/crates/hir-ty/src/mir/lower/pattern_matching.rs b/crates/hir-ty/src/mir/lower/pattern_matching.rs
index 00864907ac..45c245e281 100644
--- a/crates/hir-ty/src/mir/lower/pattern_matching.rs
+++ b/crates/hir-ty/src/mir/lower/pattern_matching.rs
@@ -110,10 +110,10 @@ impl MirLowerCtx<'_> {
             Pat::Slice { prefix, slice, suffix } => {
                 pattern_matching_dereference(&mut cond_ty, &mut binding_mode, &mut cond_place);
                 for (i, &pat) in prefix.iter().enumerate() {
-                    let next_place = cond_place.project(ProjectionElem::ConstantIndex {
-                        offset: i as u64,
-                        from_end: false,
-                    });
+                    let mut next_place = cond_place.clone();
+                    next_place
+                        .projection
+                        .push(ProjectionElem::ConstantIndex { offset: i as u64, from_end: false });
                     let cond_ty = self.infer[pat].clone();
                     (current, current_else) = self.pattern_match(
                         current,
@@ -126,7 +126,8 @@ impl MirLowerCtx<'_> {
                 }
                 if let Some(slice) = slice {
                     if let Pat::Bind { id, subpat: _ } = self.body[*slice] {
-                        let next_place = cond_place.project(ProjectionElem::Subslice {
+                        let mut next_place = cond_place.clone();
+                        next_place.projection.push(ProjectionElem::Subslice {
                             from: prefix.len() as u64,
                             to: suffix.len() as u64,
                         });
@@ -141,10 +142,10 @@ impl MirLowerCtx<'_> {
                     }
                 }
                 for (i, &pat) in suffix.iter().enumerate() {
-                    let next_place = cond_place.project(ProjectionElem::ConstantIndex {
-                        offset: i as u64,
-                        from_end: true,
-                    });
+                    let mut next_place = cond_place.clone();
+                    next_place
+                        .projection
+                        .push(ProjectionElem::ConstantIndex { offset: i as u64, from_end: true });
                     let cond_ty = self.infer[pat].clone();
                     (current, current_else) = self.pattern_match(
                         current,
@@ -268,10 +269,11 @@ impl MirLowerCtx<'_> {
             Pat::Ref { pat, mutability: _ } => {
                 if let Some((ty, _, _)) = cond_ty.as_reference() {
                     cond_ty = ty.clone();
+                    cond_place.projection.push(ProjectionElem::Deref);
                     self.pattern_match(
                         current,
                         current_else,
-                        cond_place.project(ProjectionElem::Deref),
+                        cond_place,
                         cond_ty,
                         *pat,
                         binding_mode,
@@ -477,7 +479,8 @@ impl MirLowerCtx<'_> {
         binding_mode: BindingAnnotation,
     ) -> Result<(BasicBlockId, Option<BasicBlockId>)> {
         for (proj, arg, ty) in args {
-            let cond_place = cond_place.project(proj);
+            let mut cond_place = cond_place.clone();
+            cond_place.projection.push(proj);
             (current, current_else) =
                 self.pattern_match(current, current_else, cond_place, ty, arg, binding_mode)?;
         }
@@ -510,11 +513,5 @@ fn pattern_matching_dereference(
     cond_place: &mut Place,
 ) {
     let cnt = pattern_matching_dereference_count(cond_ty, binding_mode);
-    cond_place.projection = cond_place
-        .projection
-        .iter()
-        .cloned()
-        .chain((0..cnt).map(|_| ProjectionElem::Deref))
-        .collect::<Vec<_>>()
-        .into();
+    cond_place.projection.extend((0..cnt).map(|_| ProjectionElem::Deref));
 }
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 8fac7fcd87..bc925552f3 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -45,7 +45,7 @@ use hir_def::{
     hir::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat},
     item_tree::ItemTreeNode,
     lang_item::LangItemTarget,
-    layout::{self, ReprOptions},
+    layout::ReprOptions,
     macro_id_to_def_id,
     nameres::{self, diagnostics::DefDiagnostic, ModuleOrigin},
     per_ns::PerNs,
@@ -62,7 +62,7 @@ use hir_ty::{
     consteval::{try_const_usize, unknown_const_as_generic, ConstEvalError, ConstExt},
     diagnostics::BodyValidationDiagnostic,
     display::HexifiedConst,
-    layout::{layout_of_ty, Layout, LayoutError, RustcEnumVariantIdx, TagEncoding},
+    layout::{layout_of_ty, Layout, LayoutError},
     method_resolution::{self, TyFingerprint},
     mir::{self, interpret_mir},
     primitive::UintTy,
@@ -1089,7 +1089,7 @@ impl Enum {
         Type::new_for_crate(
             self.id.lookup(db.upcast()).container.krate(),
             TyBuilder::builtin(match db.enum_data(self.id).variant_body_type() {
-                layout::IntegerType::Pointer(sign) => match sign {
+                hir_def::layout::IntegerType::Pointer(sign) => match sign {
                     true => hir_def::builtin_type::BuiltinType::Int(
                         hir_def::builtin_type::BuiltinInt::Isize,
                     ),
@@ -1097,20 +1097,20 @@ impl Enum {
                         hir_def::builtin_type::BuiltinUint::Usize,
                     ),
                 },
-                layout::IntegerType::Fixed(i, sign) => match sign {
+                hir_def::layout::IntegerType::Fixed(i, sign) => match sign {
                     true => hir_def::builtin_type::BuiltinType::Int(match i {
-                        layout::Integer::I8 => hir_def::builtin_type::BuiltinInt::I8,
-                        layout::Integer::I16 => hir_def::builtin_type::BuiltinInt::I16,
-                        layout::Integer::I32 => hir_def::builtin_type::BuiltinInt::I32,
-                        layout::Integer::I64 => hir_def::builtin_type::BuiltinInt::I64,
-                        layout::Integer::I128 => hir_def::builtin_type::BuiltinInt::I128,
+                        hir_def::layout::Integer::I8 => hir_def::builtin_type::BuiltinInt::I8,
+                        hir_def::layout::Integer::I16 => hir_def::builtin_type::BuiltinInt::I16,
+                        hir_def::layout::Integer::I32 => hir_def::builtin_type::BuiltinInt::I32,
+                        hir_def::layout::Integer::I64 => hir_def::builtin_type::BuiltinInt::I64,
+                        hir_def::layout::Integer::I128 => hir_def::builtin_type::BuiltinInt::I128,
                     }),
                     false => hir_def::builtin_type::BuiltinType::Uint(match i {
-                        layout::Integer::I8 => hir_def::builtin_type::BuiltinUint::U8,
-                        layout::Integer::I16 => hir_def::builtin_type::BuiltinUint::U16,
-                        layout::Integer::I32 => hir_def::builtin_type::BuiltinUint::U32,
-                        layout::Integer::I64 => hir_def::builtin_type::BuiltinUint::U64,
-                        layout::Integer::I128 => hir_def::builtin_type::BuiltinUint::U128,
+                        hir_def::layout::Integer::I8 => hir_def::builtin_type::BuiltinUint::U8,
+                        hir_def::layout::Integer::I16 => hir_def::builtin_type::BuiltinUint::U16,
+                        hir_def::layout::Integer::I32 => hir_def::builtin_type::BuiltinUint::U32,
+                        hir_def::layout::Integer::I64 => hir_def::builtin_type::BuiltinUint::U64,
+                        hir_def::layout::Integer::I128 => hir_def::builtin_type::BuiltinUint::U128,
                     }),
                 },
             }),
@@ -1177,28 +1177,6 @@ impl Variant {
     pub fn eval(self, db: &dyn HirDatabase) -> Result<i128, ConstEvalError> {
         db.const_eval_discriminant(self.into())
     }
-
-    /// Return layout of the variant and tag size of the parent enum.
-    pub fn layout(&self, db: &dyn HirDatabase) -> Result<(Layout, usize), LayoutError> {
-        let parent_enum = self.parent_enum(db);
-        let parent_layout = Adt::from(parent_enum).layout(db)?;
-        if let layout::Variants::Multiple { variants, tag, tag_encoding, tag_field: _ } =
-            parent_layout.variants
-        {
-            let tag_size = match tag_encoding {
-                TagEncoding::Direct => {
-                    let target_data_layout = db
-                        .target_data_layout(parent_enum.module(db).krate().id)
-                        .ok_or(LayoutError::TargetLayoutNotAvailable)?;
-                    tag.size(&*target_data_layout).bytes_usize()
-                }
-                TagEncoding::Niche { .. } => 0,
-            };
-            Ok((variants[RustcEnumVariantIdx(self.id)].clone(), tag_size))
-        } else {
-            Ok((parent_layout, 0))
-        }
-    }
 }
 
 /// Variants inherit visibility from the parent enum.
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 1374fa332c..dae77fad2f 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -236,9 +236,9 @@ impl SourceAnalyzer {
         _db: &dyn HirDatabase,
         pat: &ast::IdentPat,
     ) -> Option<BindingMode> {
-        let binding_id = self.binding_id_of_pat(pat)?;
+        let pat_id = self.pat_id(&pat.clone().into())?;
         let infer = self.infer.as_ref()?;
-        infer.binding_modes.get(binding_id).map(|bm| match bm {
+        infer.pat_binding_modes.get(&pat_id).map(|bm| match bm {
             hir_ty::BindingMode::Move => BindingMode::Move,
             hir_ty::BindingMode::Ref(hir_ty::Mutability::Mut) => BindingMode::Ref(Mutability::Mut),
             hir_ty::BindingMode::Ref(hir_ty::Mutability::Not) => {
diff --git a/crates/hir/src/symbols.rs b/crates/hir/src/symbols.rs
index 4eaf99e3e7..af37206ead 100644
--- a/crates/hir/src/symbols.rs
+++ b/crates/hir/src/symbols.rs
@@ -50,7 +50,7 @@ impl DeclarationLocation {
     pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
         if let Some(file_id) = self.hir_file_id.file_id() {
             // fast path to prevent parsing
-            return Some(FileRange { file_id, range: self.ptr.text_range() });
+            return Some(FileRange { file_id, range: self.name_ptr.text_range() });
         }
         let node = resolve_node(db, self.hir_file_id, &self.name_ptr);
         node.as_ref().original_file_range_opt(db.upcast())
diff --git a/crates/ide-db/src/syntax_helpers/node_ext.rs b/crates/ide-db/src/syntax_helpers/node_ext.rs
index 22ced69d81..a34dc1b695 100644
--- a/crates/ide-db/src/syntax_helpers/node_ext.rs
+++ b/crates/ide-db/src/syntax_helpers/node_ext.rs
@@ -52,9 +52,7 @@ pub fn preorder_expr(start: &ast::Expr, cb: &mut dyn FnMut(WalkEvent<ast::Expr>)
             }
         };
         if let Some(let_stmt) = node.parent().and_then(ast::LetStmt::cast) {
-            if let_stmt.initializer().map(|it| it.syntax() != &node).unwrap_or(true)
-                && let_stmt.let_else().map(|it| it.syntax() != &node).unwrap_or(true)
-            {
+            if Some(node.clone()) != let_stmt.initializer().map(|it| it.syntax().clone()) {
                 // skipping potential const pat expressions in  let statements
                 preorder.skip_subtree();
                 continue;
diff --git a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
index 32e321107e..99243a5ab8 100644
--- a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
+++ b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
@@ -151,25 +151,4 @@ fn f(x: &mut X<'_>) {
 "#,
         );
     }
-
-    #[test]
-    fn no_false_positive_match_and_closure_capture() {
-        check_diagnostics(
-            r#"
-//- minicore: copy, fn
-enum X {
-    Foo(u16),
-    Bar,
-}
-
-fn main() {
-    let x = &X::Bar;
-    let c = || match *x {
-        X::Foo(t) => t,
-        _ => 5,
-    };
-}
-            "#,
-        );
-    }
 }
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index 7e545491f8..ff73d5ec9f 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -692,29 +692,6 @@ pub async$0 fn foo() {
         );
     }
 
-    #[test]
-    fn test_hl_let_else_yield_points() {
-        check(
-            r#"
-pub async fn foo() {
- // ^^^^^
-    let x = foo()
-        .await$0
-      // ^^^^^
-        .await;
-      // ^^^^^
-    || { 0.await };
-    let Some(_) = None else {
-        foo().await
-           // ^^^^^
-    };
-    (async { 0.await }).await
-                     // ^^^^^
-}
-"#,
-        );
-    }
-
     #[test]
     fn test_hl_yield_nested_fn() {
         check(
@@ -811,26 +788,6 @@ async fn foo() {
         );
     }
 
-    #[test]
-    fn test_hl_let_else_exit_points() {
-        check(
-            r#"
-  fn$0 foo() -> u32 {
-//^^
-    let Some(bar) = None else {
-        return 0;
-     // ^^^^^^
-    };
-
-    0?;
-  // ^
-    0xDEAD_BEEF
- // ^^^^^^^^^^^
-}
-"#,
-        );
-    }
-
     #[test]
     fn test_hl_prefer_ref_over_tail_exit() {
         check(
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index fffc837876..c2b9222cb9 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -417,25 +417,15 @@ pub(super) fn definition(
             let layout = it.layout(db).ok()?;
             Some(format!("size = {}, align = {}", layout.size.bytes(), layout.align.abi.bytes()))
         }),
-        Definition::Variant(it) => label_value_and_layout_info_and_docs(db, it, config, |&it| {
-            let layout = (|| {
-                let (layout, tag_size) = it.layout(db).ok()?;
-                let size = layout.size.bytes_usize() - tag_size;
-                if size == 0 {
-                    // There is no value in showing layout info for fieldless variants
-                    return None;
-                }
-                Some(format!("size = {}", layout.size.bytes()))
-            })();
-            let value = if !it.parent_enum(db).is_data_carrying(db) {
+        Definition::Variant(it) => label_value_and_docs(db, it, |&it| {
+            if !it.parent_enum(db).is_data_carrying(db) {
                 match it.eval(db) {
                     Ok(x) => Some(if x >= 10 { format!("{x} ({x:#X})") } else { format!("{x}") }),
                     Err(_) => it.value(db).map(|x| format!("{x:?}")),
                 }
             } else {
                 None
-            };
-            (value, layout)
+            }
         }),
         Definition::Const(it) => label_value_and_docs(db, it, |it| {
             let body = it.render_eval(db);
@@ -470,7 +460,7 @@ pub(super) fn definition(
                 .and_then(|fd| builtin(fd, it))
                 .or_else(|| Some(Markup::fenced_block(&it.name())))
         }
-        Definition::Local(it) => return local(db, it, config),
+        Definition::Local(it) => return local(db, it),
         Definition::SelfType(impl_def) => {
             impl_def.self_ty(db).as_adt().map(|adt| label_and_docs(db, adt))?
         }
@@ -647,32 +637,6 @@ where
     (label, docs)
 }
 
-fn label_value_and_layout_info_and_docs<D, E, V, L>(
-    db: &RootDatabase,
-    def: D,
-    config: &HoverConfig,
-    value_extractor: E,
-) -> (String, Option<hir::Documentation>)
-where
-    D: HasAttrs + HirDisplay,
-    E: Fn(&D) -> (Option<V>, Option<L>),
-    V: Display,
-    L: Display,
-{
-    let (value, layout) = value_extractor(&def);
-    let label = if let Some(value) = value {
-        format!("{} = {value}", def.display(db))
-    } else {
-        def.display(db).to_string()
-    };
-    let label = match layout {
-        Some(layout) if config.memory_layout => format!("{} // {layout}", label),
-        _ => label,
-    };
-    let docs = def.attrs(db).docs();
-    (label, docs)
-}
-
 fn label_value_and_docs<D, E, V>(
     db: &RootDatabase,
     def: D,
@@ -732,11 +696,11 @@ fn find_std_module(famous_defs: &FamousDefs<'_, '_>, name: &str) -> Option<hir::
         .find(|module| module.name(db).map_or(false, |module| module.to_string() == name))
 }
 
-fn local(db: &RootDatabase, it: hir::Local, config: &HoverConfig) -> Option<Markup> {
+fn local(db: &RootDatabase, it: hir::Local) -> Option<Markup> {
     let ty = it.ty(db);
     let ty = ty.display_truncated(db, None);
     let is_mut = if it.is_mut(db) { "mut " } else { "" };
-    let mut desc = match it.primary_source(db).into_ident_pat() {
+    let desc = match it.primary_source(db).into_ident_pat() {
         Some(ident) => {
             let name = it.name(db);
             let let_kw = if ident
@@ -752,16 +716,6 @@ fn local(db: &RootDatabase, it: hir::Local, config: &HoverConfig) -> Option<Mark
         }
         None => format!("{is_mut}self: {ty}"),
     };
-    if config.memory_layout {
-        if let Ok(layout) = it.ty(db).layout(db) {
-            format_to!(
-                desc,
-                " // size = {}, align = {}",
-                layout.size.bytes(),
-                layout.align.abi.bytes()
-            );
-        }
-    }
     markup(None, desc, None)
 }
 


Test patch:
diff --git a/crates/hir-ty/src/layout/tests/closure.rs b/crates/hir-ty/src/layout/tests/closure.rs
index 811d608880..a2e19852a0 100644
--- a/crates/hir-ty/src/layout/tests/closure.rs
+++ b/crates/hir-ty/src/layout/tests/closure.rs
@@ -182,43 +182,6 @@ fn capture_specific_fields() {
     }
 }
 
-#[test]
-fn match_pattern() {
-    size_and_align_expr! {
-        struct X(i64, i32, (u8, i128));
-        let y: X = X(2, 5, (7, 3));
-        move |x: i64| {
-            match y {
-                _ => x,
-            }
-        }
-    }
-    size_and_align_expr! {
-        minicore: copy;
-        stmts: [
-            struct X(i64, i32, (u8, i128));
-            let y: X = X(2, 5, (7, 3));
-        ]
-        |x: i64| {
-            match y {
-                X(_a, _b, _c) => x,
-            }
-        }
-    }
-    size_and_align_expr! {
-        minicore: copy;
-        stmts: [
-            struct X(i64, i32, (u8, i128));
-            let y: X = X(2, 5, (7, 3));
-        ]
-        |x: i64| {
-            match y {
-                _y => x,
-            }
-        }
-    }
-}
-
 #[test]
 fn ellipsis_pattern() {
     size_and_align_expr! {
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index ca6c169348..0d8fc8a5f7 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -150,7 +150,7 @@ fn foo() {
             *local*
 
             ```rust
-            let local: i32 // size = 4, align = 4
+            let local: i32
             ```
         "#]],
     );
@@ -301,33 +301,6 @@ fn main() {
             * `(*x.f2.0.0).f` by mutable borrow
         "#]],
     );
-    check(
-        r#"
-//- minicore: copy, option
-
-fn do_char(c: char) {}
-
-fn main() {
-    let x = None;
-    let y = |$0| {
-        match x {
-            Some(c) => do_char(c),
-            None => x = None,
-        }
-    };
-}
-"#,
-        expect![[r#"
-            *|*
-            ```rust
-            {closure#0} // size = 8, align = 8
-            impl FnMut()
-            ```
-
-            ## Captures
-            * `x` by mutable borrow
-        "#]],
-    );
 }
 
 #[test]
@@ -423,12 +396,12 @@ fn main() {
 }
 "#,
         expect![[r#"
-            *iter*
+                *iter*
 
-            ```rust
-            let mut iter: Iter<Scan<OtherStruct<OtherStruct<i32>>, impl Fn(&mut u32, &u32, &mut u32) -> Option<u32>, u32>> // size = 8, align = 4
-            ```
-        "#]],
+                ```rust
+                let mut iter: Iter<Scan<OtherStruct<OtherStruct<i32>>, impl Fn(&mut u32, &u32, &mut u32) -> Option<u32>, u32>>
+                ```
+            "#]],
     );
 }
 
@@ -805,12 +778,12 @@ fn main() {
     let zz$0 = Test { t: 23u8, k: 33 };
 }"#,
         expect![[r#"
-            *zz*
+                *zz*
 
-            ```rust
-            let zz: Test<i32> // size = 8, align = 4
-            ```
-        "#]],
+                ```rust
+                let zz: Test<i32>
+                ```
+            "#]],
     );
     check_hover_range(
         r#"
@@ -856,12 +829,12 @@ use Option::Some;
 fn main() { let b$0ar = Some(12); }
 "#,
         expect![[r#"
-            *bar*
+                *bar*
 
-            ```rust
-            let bar: Option<i32> // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                let bar: Option<i32>
+                ```
+            "#]],
     );
 }
 
@@ -925,12 +898,12 @@ fn hover_for_local_variable() {
     check(
         r#"fn func(foo: i32) { fo$0o; }"#,
         expect![[r#"
-            *foo*
+                *foo*
 
-            ```rust
-            foo: i32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                foo: i32
+                ```
+            "#]],
     )
 }
 
@@ -939,12 +912,12 @@ fn hover_for_local_variable_pat() {
     check(
         r#"fn func(fo$0o: i32) {}"#,
         expect![[r#"
-            *foo*
+                *foo*
 
-            ```rust
-            foo: i32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                foo: i32
+                ```
+            "#]],
     )
 }
 
@@ -953,12 +926,12 @@ fn hover_local_var_edge() {
     check(
         r#"fn func(foo: i32) { if true { $0foo; }; }"#,
         expect![[r#"
-            *foo*
+                *foo*
 
-            ```rust
-            foo: i32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                foo: i32
+                ```
+            "#]],
     )
 }
 
@@ -967,12 +940,12 @@ fn hover_for_param_edge() {
     check(
         r#"fn func($0foo: i32) {}"#,
         expect![[r#"
-            *foo*
+                *foo*
 
-            ```rust
-            foo: i32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                foo: i32
+                ```
+            "#]],
     )
 }
 
@@ -1011,12 +984,12 @@ impl Thing {
 fn main() { let foo_$0test = Thing::new(); }
 "#,
         expect![[r#"
-            *foo_test*
+                *foo_test*
 
-            ```rust
-            let foo_test: Thing // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                let foo_test: Thing
+                ```
+            "#]],
     )
 }
 
@@ -1171,12 +1144,12 @@ fn y() {
 }
 "#,
         expect![[r#"
-            *x*
+                *x*
 
-            ```rust
-            let x: i32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                let x: i32
+                ```
+            "#]],
     )
 }
 
@@ -1301,12 +1274,12 @@ macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
 fn foo(bar:u32) { let a = id!(ba$0r); }
 "#,
         expect![[r#"
-            *bar*
+                *bar*
 
-            ```rust
-            bar: u32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                bar: u32
+                ```
+            "#]],
     );
 }
 
@@ -1319,12 +1292,12 @@ macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
 fn foo(bar:u32) { let a = id!(ba$0r); }
 "#,
         expect![[r#"
-            *bar*
+                *bar*
 
-            ```rust
-            bar: u32 // size = 4, align = 4
-            ```
-        "#]],
+                ```rust
+                bar: u32
+                ```
+            "#]],
     );
 }
 
@@ -1868,27 +1841,6 @@ pub fn fo$0o() {}
     );
 }
 
-#[test]
-fn test_hover_layout_of_variant() {
-    check(
-        r#"enum Foo {
-            Va$0riant1(u8, u16),
-            Variant2(i32, u8, i64),
-        }"#,
-        expect![[r#"
-            *Variant1*
-
-            ```rust
-            test::Foo
-            ```
-
-            ```rust
-            Variant1(u8, u16) // size = 4
-            ```
-        "#]],
-    );
-}
-
 #[test]
 fn test_hover_no_memory_layout() {
     check_hover_no_memory_layout(
@@ -3183,7 +3135,7 @@ fn main() {
             *f*
 
             ```rust
-            f: &i32 // size = 8, align = 8
+            f: &i32
             ```
             ---
 
@@ -3233,7 +3185,7 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<1> // size = 0, align = 1
+            let value: Const<1>
             ```
         "#]],
     );
@@ -3253,7 +3205,7 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<0> // size = 0, align = 1
+            let value: Const<0>
             ```
         "#]],
     );
@@ -3273,7 +3225,7 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<-1> // size = 0, align = 1
+            let value: Const<-1>
             ```
         "#]],
     );
@@ -3293,7 +3245,7 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<true> // size = 0, align = 1
+            let value: Const<true>
             ```
         "#]],
     );
@@ -3313,7 +3265,7 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<'🦀'> // size = 0, align = 1
+            let value: Const<'🦀'>
             ```
         "#]],
     );
@@ -3329,12 +3281,12 @@ impl Foo {
 }
 "#,
         expect![[r#"
-            *self*
+                *self*
 
-            ```rust
-            self: &Foo // size = 8, align = 8
-            ```
-        "#]],
+                ```rust
+                self: &Foo
+                ```
+            "#]],
     );
 }
 
@@ -3349,12 +3301,12 @@ impl Foo {
 }
 "#,
         expect![[r#"
-            *self*
+                *self*
 
-            ```rust
-            self: Arc<Foo> // size = 0, align = 1
-            ```
-        "#]],
+                ```rust
+                self: Arc<Foo>
+                ```
+            "#]],
     );
 }
 
@@ -4412,9 +4364,9 @@ fn main() {
             *tile4*
 
             ```rust
-            let tile4: [u32; 8] // size = 32, align = 4
+            let tile4: [u32; 8]
             ```
-        "#]],
+            "#]],
     );
 }
 
@@ -5589,7 +5541,7 @@ enum Enum {
             ```
 
             ```rust
-            RecordV { field: u32 } // size = 4
+            RecordV { field: u32 }
             ```
         "#]],
     );