diff --git a/Cargo.toml b/Cargo.toml index e344f41b..4b1a692f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ rustc-hash = "2.0" scc = "2" scoped-tls = "1.0" semver = "1.0" -smallvec = "1" +smallvec = { version = "1", features = ["const_generics", "union"] } thread_local = "1.1" tikv-jemallocator = "0.6" typed-arena = "2.0" diff --git a/crates/data-structures/Cargo.toml b/crates/data-structures/Cargo.toml index 4f820afa..96beeb9d 100644 --- a/crates/data-structures/Cargo.toml +++ b/crates/data-structures/Cargo.toml @@ -25,7 +25,7 @@ index_vec.workspace = true indexmap.workspace = true parking_lot.workspace = true rustc-hash.workspace = true -smallvec = { workspace = true, features = ["union"] } +smallvec.workspace = true [features] nightly = [ diff --git a/crates/data-structures/src/index.rs b/crates/data-structures/src/index.rs index 504d66ff..69b43a39 100644 --- a/crates/data-structures/src/index.rs +++ b/crates/data-structures/src/index.rs @@ -74,6 +74,7 @@ macro_rules! base_index { } impl fmt::Debug for $name { + #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.value.fmt(f) } diff --git a/crates/sema/src/ast_lowering/resolve.rs b/crates/sema/src/ast_lowering/resolve.rs index 5b714b78..216d85dd 100644 --- a/crates/sema/src/ast_lowering/resolve.rs +++ b/crates/sema/src/ast_lowering/resolve.rs @@ -3,7 +3,7 @@ use solar_ast::ast; use solar_data_structures::{ index::{Idx, IndexVec}, map::{FxIndexMap, IndexEntry}, - smallvec::{smallvec, SmallVec}, + smallvec::SmallVec, BumpExt, }; use solar_interface::{ @@ -1109,16 +1109,16 @@ impl Declarations { ) -> Result<(), Declaration> { match self.declarations.entry(name) { IndexEntry::Occupied(entry) => { - if let Some(conflict) = Self::conflicting_declaration(hir, decl, entry.get()) { + let declarations = entry.into_mut(); + if let Some(conflict) = Self::conflicting_declaration(hir, decl, declarations) { return Err(conflict); } - let declarations = entry.into_mut(); if !declarations.contains(&decl) { declarations.push(decl); } } IndexEntry::Vacant(entry) => { - entry.insert(smallvec![decl]); + entry.insert(SmallVec::from_buf([decl])); } } Ok(()) diff --git a/crates/sema/src/hir.rs b/crates/sema/src/hir.rs index e37ed141..44644c1a 100644 --- a/crates/sema/src/hir.rs +++ b/crates/sema/src/hir.rs @@ -166,6 +166,7 @@ impl<'hir> Hir<'hir> { } /// Returns the item associated with the given ID. + #[inline] pub fn item(&self, id: impl Into) -> Item<'_, 'hir> { match id.into() { ItemId::Contract(id) => Item::Contract(self.contract(id)), @@ -289,6 +290,7 @@ pub enum Item<'a, 'hir> { impl Item<'_, '_> { /// Returns the name of the item. + #[inline] pub fn name(self) -> Option { match self { Item::Contract(c) => Some(c.name), @@ -303,6 +305,7 @@ impl Item<'_, '_> { } /// Returns the description of the item. + #[inline] pub fn description(self) -> &'static str { match self { Item::Contract(c) => c.kind.to_str(), @@ -317,6 +320,7 @@ impl Item<'_, '_> { } /// Returns the span of the item. + #[inline] pub fn span(self) -> Span { match self { Item::Contract(c) => c.span, @@ -331,6 +335,7 @@ impl Item<'_, '_> { } /// Returns the contract ID if this item is part of a contract. + #[inline] pub fn contract(self) -> Option { match self { Item::Contract(_) => None, diff --git a/crates/sema/src/ty/mod.rs b/crates/sema/src/ty/mod.rs index 2183c627..b3b32f24 100644 --- a/crates/sema/src/ty/mod.rs +++ b/crates/sema/src/ty/mod.rs @@ -453,7 +453,7 @@ pub fn interface_functions(gcx: _, id: hir::ContractId) -> InterfaceFunctions<'g gcx.dcx().err(msg).span(c.name.span).span_note(f.span, "first function").span_note(f2.span, "second function").note(full_note).emit(); } - Some(InterfaceFunction{ selector, id: f_id, ty }) + Some(InterfaceFunction { selector, id: f_id, ty }) }); let functions = gcx.bump().alloc_from_iter(functions); let inheritance_start = inheritance_start.expect("linearized_bases did not contain self ID");