Shrink WherePredicate by 8 bytes

This commit is contained in:
Lukas Wirth 2025-04-24 09:22:41 +02:00
parent 4a2eaddc77
commit 99a7e423e2
2 changed files with 3 additions and 2 deletions

View file

@ -227,7 +227,7 @@ impl GenericParamsCollector {
(_, TypeBound::Error | TypeBound::Use(_)) => return, (_, TypeBound::Error | TypeBound::Use(_)) => return,
(Either::Left(type_ref), bound) => match hrtb_lifetimes { (Either::Left(type_ref), bound) => match hrtb_lifetimes {
Some(hrtb_lifetimes) => WherePredicate::ForLifetime { Some(hrtb_lifetimes) => WherePredicate::ForLifetime {
lifetimes: hrtb_lifetimes.to_vec().into_boxed_slice(), lifetimes: ThinVec::from_iter(hrtb_lifetimes.iter().cloned()),
target: type_ref, target: type_ref,
bound, bound,
}, },

View file

@ -4,6 +4,7 @@ use std::{ops, sync::LazyLock};
use hir_expand::name::Name; use hir_expand::name::Name;
use la_arena::{Arena, Idx, RawIdx}; use la_arena::{Arena, Idx, RawIdx};
use stdx::impl_from; use stdx::impl_from;
use thin_vec::ThinVec;
use triomphe::Arc; use triomphe::Arc;
use crate::{ use crate::{
@ -171,7 +172,7 @@ impl ops::Index<LocalLifetimeParamId> for GenericParams {
pub enum WherePredicate { pub enum WherePredicate {
TypeBound { target: TypeRefId, bound: TypeBound }, TypeBound { target: TypeRefId, bound: TypeBound },
Lifetime { target: LifetimeRef, bound: LifetimeRef }, Lifetime { target: LifetimeRef, bound: LifetimeRef },
ForLifetime { lifetimes: Box<[Name]>, target: TypeRefId, bound: TypeBound }, ForLifetime { lifetimes: ThinVec<Name>, target: TypeRefId, bound: TypeBound },
} }
static EMPTY: LazyLock<Arc<GenericParams>> = LazyLock::new(|| { static EMPTY: LazyLock<Arc<GenericParams>> = LazyLock::new(|| {