From d1deab56d17e3fdf07bfb09b0a4322155d364430 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 24 Apr 2025 09:22:41 +0200 Subject: [PATCH] Shrink `WherePredicate` by 8 bytes --- .../crates/hir-def/src/expr_store/lower/generics.rs | 2 +- src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower/generics.rs b/src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower/generics.rs index 004bbe949f2f..5cea8a243506 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower/generics.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower/generics.rs @@ -227,7 +227,7 @@ impl GenericParamsCollector { (_, TypeBound::Error | TypeBound::Use(_)) => return, (Either::Left(type_ref), bound) => match hrtb_lifetimes { Some(hrtb_lifetimes) => WherePredicate::ForLifetime { - lifetimes: hrtb_lifetimes.to_vec().into_boxed_slice(), + lifetimes: ThinVec::from_iter(hrtb_lifetimes.iter().cloned()), target: type_ref, bound, }, diff --git a/src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs b/src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs index 685847c9fdd2..1bb9e48d5599 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs @@ -4,6 +4,7 @@ use std::{ops, sync::LazyLock}; use hir_expand::name::Name; use la_arena::{Arena, Idx, RawIdx}; use stdx::impl_from; +use thin_vec::ThinVec; use triomphe::Arc; use crate::{ @@ -171,7 +172,7 @@ impl ops::Index for GenericParams { pub enum WherePredicate { TypeBound { target: TypeRefId, bound: TypeBound }, Lifetime { target: LifetimeRef, bound: LifetimeRef }, - ForLifetime { lifetimes: Box<[Name]>, target: TypeRefId, bound: TypeBound }, + ForLifetime { lifetimes: ThinVec, target: TypeRefId, bound: TypeBound }, } static EMPTY: LazyLock> = LazyLock::new(|| {