Skip to content

Commit afd83e0

Browse files
Remove unnecessary region, relax Sized bounds
1 parent 39d992e commit afd83e0

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

crates/hir_def/src/intern.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_hash::FxHasher;
1616
type InternMap<T> = DashMap<Arc<T>, (), BuildHasherDefault<FxHasher>>;
1717

1818
#[derive(Hash)]
19-
pub struct Interned<T: Internable> {
19+
pub struct Interned<T: Internable + ?Sized> {
2020
arc: Arc<T>,
2121
}
2222

@@ -52,7 +52,7 @@ impl<T: Internable> Interned<T> {
5252
}
5353
}
5454

55-
impl<T: Internable> Drop for Interned<T> {
55+
impl<T: Internable + ?Sized> Drop for Interned<T> {
5656
fn drop(&mut self) {
5757
// When the last `Ref` is dropped, remove the object from the global map.
5858
if Arc::strong_count(&self.arc) == 2 {
@@ -83,23 +83,23 @@ impl<T: Internable> Drop for Interned<T> {
8383
}
8484

8585
/// Compares interned `Ref`s using pointer equality.
86-
impl<T: Internable> PartialEq for Interned<T> {
86+
impl<T: Internable + ?Sized> PartialEq for Interned<T> {
8787
#[inline]
8888
fn eq(&self, other: &Self) -> bool {
8989
Arc::ptr_eq(&self.arc, &other.arc)
9090
}
9191
}
9292

93-
impl<T: Internable> Eq for Interned<T> {}
93+
impl<T: Internable + ?Sized> Eq for Interned<T> {}
9494

95-
impl<T: Internable> AsRef<T> for Interned<T> {
95+
impl<T: Internable + ?Sized> AsRef<T> for Interned<T> {
9696
#[inline]
9797
fn as_ref(&self) -> &T {
9898
&self.arc
9999
}
100100
}
101101

102-
impl<T: Internable> Deref for Interned<T> {
102+
impl<T: Internable + ?Sized> Deref for Interned<T> {
103103
type Target = T;
104104

105105
#[inline]
@@ -108,40 +108,38 @@ impl<T: Internable> Deref for Interned<T> {
108108
}
109109
}
110110

111-
impl<T: Internable> Clone for Interned<T> {
111+
impl<T: Internable + ?Sized> Clone for Interned<T> {
112112
fn clone(&self) -> Self {
113113
Self { arc: self.arc.clone() }
114114
}
115115
}
116116

117-
impl<T: Debug + Internable> Debug for Interned<T> {
117+
impl<T: Debug + Internable + ?Sized> Debug for Interned<T> {
118118
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
119119
(*self.arc).fmt(f)
120120
}
121121
}
122122

123-
pub struct InternStorage<T> {
123+
pub struct InternStorage<T: ?Sized> {
124124
map: OnceCell<InternMap<T>>,
125125
}
126126

127-
impl<T> InternStorage<T> {
127+
impl<T: ?Sized> InternStorage<T> {
128128
pub const fn new() -> Self {
129129
Self { map: OnceCell::new() }
130130
}
131131
}
132132

133-
impl<T: Internable> InternStorage<T> {
133+
impl<T: Internable + ?Sized> InternStorage<T> {
134134
fn get(&self) -> &InternMap<T> {
135135
self.map.get_or_init(DashMap::default)
136136
}
137137
}
138138

139-
pub trait Internable: Hash + Eq + Sized + 'static {
139+
pub trait Internable: Hash + Eq + 'static {
140140
fn storage() -> &'static InternStorage<Self>;
141141
}
142142

143-
// region:`Internable` implementations
144-
145143
macro_rules! impl_internable {
146144
( $($t:ty),+ $(,)? ) => { $(
147145
impl Internable for $t {
@@ -154,5 +152,3 @@ macro_rules! impl_internable {
154152
}
155153

156154
impl_internable!(crate::type_ref::TypeRef, crate::type_ref::TraitRef, crate::path::ModPath);
157-
158-
// endregion

0 commit comments

Comments
 (0)