Skip to content

Commit 96d223f

Browse files
committed
chore: fix clippy warnings
1 parent 093bf73 commit 96d223f

File tree

11 files changed

+43
-33
lines changed

11 files changed

+43
-33
lines changed

crates/els/completion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl CompletionCache {
462462
Self { cache }
463463
}
464464

465-
pub fn get(&self, namespace: &str) -> Option<MappedRwLockReadGuard<Vec<CompletionItem>>> {
465+
pub fn get(&self, namespace: &str) -> Option<MappedRwLockReadGuard<'_, Vec<CompletionItem>>> {
466466
RwLockReadGuard::try_map(self.cache.borrow(), |cache| cache.get(namespace)).ok()
467467
}
468468

crates/els/server.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
10661066
pub(crate) fn get_mod_ctx(
10671067
&self,
10681068
uri: &NormalizedUrl,
1069-
) -> Option<MappedRwLockReadGuard<ModuleContext>> {
1069+
) -> Option<MappedRwLockReadGuard<'_, ModuleContext>> {
10701070
let path = uri.to_file_path().ok()?;
10711071
let ent = self.shared.get_module(&path)?;
10721072
Some(MappedRwLockReadGuard::map(ent, |ent| &ent.module))
@@ -1111,7 +1111,7 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
11111111
self.restore_entry(uri, entry);
11121112
}
11131113

1114-
pub(crate) fn get_visitor(&self, uri: &NormalizedUrl) -> Option<HIRVisitor> {
1114+
pub(crate) fn get_visitor(&self, uri: &NormalizedUrl) -> Option<HIRVisitor<'_>> {
11151115
let path = uri.to_file_path().ok()?;
11161116
let Some(ent) = self.shared.get_module(&path) else {
11171117
_log!(self, "module not found: {uri}");
@@ -1122,7 +1122,11 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
11221122
Some(HIRVisitor::new(hir, &self.file_cache, uri.clone()))
11231123
}
11241124

1125-
pub(crate) fn get_searcher(&self, uri: &NormalizedUrl, kind: ExprKind) -> Option<HIRVisitor> {
1125+
pub(crate) fn get_searcher(
1126+
&self,
1127+
uri: &NormalizedUrl,
1128+
kind: ExprKind,
1129+
) -> Option<HIRVisitor<'_>> {
11261130
let path = uri.to_file_path().ok()?;
11271131
let ent = self.shared.get_module(&path)?;
11281132
ent.hir.as_ref()?;
@@ -1294,7 +1298,7 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
12941298
self.shared.insert_module(path.into(), entry);
12951299
}
12961300

1297-
pub fn get_hir(&self, uri: &NormalizedUrl) -> Option<MappedRwLockReadGuard<HIR>> {
1301+
pub fn get_hir(&self, uri: &NormalizedUrl) -> Option<MappedRwLockReadGuard<'_, HIR>> {
12981302
let path = uri.to_file_path().ok()?;
12991303
let ent = self.shared.get_module(&path)?;
13001304
MappedRwLockReadGuard::try_map(ent, |ent| ent.hir.as_ref()).ok()
@@ -1310,7 +1314,7 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
13101314
self.shared.insert_module(path.into(), entry);
13111315
}
13121316

1313-
pub fn get_ast(&self, uri: &NormalizedUrl) -> Option<MappedRwLockReadGuard<Module>> {
1317+
pub fn get_ast(&self, uri: &NormalizedUrl) -> Option<MappedRwLockReadGuard<'_, Module>> {
13141318
let path = uri.to_file_path().ok()?;
13151319
let ent = self.shared.get_module(&path)?;
13161320
MappedRwLockReadGuard::try_map(ent, |ent| ent.ast.as_ref()).ok()

crates/erg_common/dict.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ impl<K, V> Dict<K, V> {
172172
}
173173

174174
#[inline]
175-
pub fn keys(&self) -> Keys<K, V> {
175+
pub fn keys(&self) -> Keys<'_, K, V> {
176176
self.dict.keys()
177177
}
178178

179179
#[inline]
180-
pub fn values(&self) -> Values<K, V> {
180+
pub fn values(&self) -> Values<'_, K, V> {
181181
self.dict.values()
182182
}
183183

184184
#[inline]
185-
pub fn values_mut(&mut self) -> ValuesMut<K, V> {
185+
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
186186
self.dict.values_mut()
187187
}
188188

@@ -197,12 +197,12 @@ impl<K, V> Dict<K, V> {
197197
}
198198

199199
#[inline]
200-
pub fn iter(&self) -> Iter<K, V> {
200+
pub fn iter(&self) -> Iter<'_, K, V> {
201201
self.dict.iter()
202202
}
203203

204204
#[inline]
205-
pub fn iter_mut(&mut self) -> IterMut<K, V> {
205+
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
206206
self.dict.iter_mut()
207207
}
208208

@@ -395,7 +395,7 @@ impl<K: Hash + Eq, V> Dict<K, V> {
395395
self
396396
}
397397

398-
pub fn entry(&mut self, k: K) -> Entry<K, V> {
398+
pub fn entry(&mut self, k: K) -> Entry<'_, K, V> {
399399
self.dict.entry(k)
400400
}
401401
}

crates/erg_compiler/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ impl Params {
21582158
Self::new(vec![], Some(Box::new(sig)), vec![], None, vec![], None)
21592159
}
21602160

2161-
pub const fn ref_deconstruct(&self) -> RefRawParams {
2161+
pub const fn ref_deconstruct(&self) -> RefRawParams<'_> {
21622162
(
21632163
&self.non_defaults,
21642164
&self.var_params,

crates/erg_compiler/module/cache.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ impl SharedModuleCache {
255255
self.0.borrow().cache.len()
256256
}
257257

258-
pub fn get<Q: Eq + Hash + ?Sized>(&self, path: &Q) -> Option<MappedRwLockReadGuard<ModuleEntry>>
258+
pub fn get<Q: Eq + Hash + ?Sized>(
259+
&self,
260+
path: &Q,
261+
) -> Option<MappedRwLockReadGuard<'_, ModuleEntry>>
259262
where
260263
NormalizedPathBuf: Borrow<Q>,
261264
{
@@ -265,7 +268,7 @@ impl SharedModuleCache {
265268
pub fn get_mut<Q: Eq + Hash + ?Sized>(
266269
&self,
267270
path: &Q,
268-
) -> Option<MappedRwLockWriteGuard<ModuleEntry>>
271+
) -> Option<MappedRwLockWriteGuard<'_, ModuleEntry>>
269272
where
270273
NormalizedPathBuf: Borrow<Q>,
271274
{
@@ -275,7 +278,7 @@ impl SharedModuleCache {
275278
pub fn ref_ctx<Q: Eq + Hash + ?Sized>(
276279
&self,
277280
path: &Q,
278-
) -> Option<MappedRwLockReadGuard<ModuleContext>>
281+
) -> Option<MappedRwLockReadGuard<'_, ModuleContext>>
279282
where
280283
NormalizedPathBuf: Borrow<Q>,
281284
{
@@ -387,7 +390,7 @@ impl SharedModuleCache {
387390
self.0.borrow_mut().rename_path(path, new.into());
388391
}
389392

390-
pub fn ref_inner(&self) -> MappedRwLockReadGuard<Dict<NormalizedPathBuf, ModuleEntry>> {
393+
pub fn ref_inner(&self) -> MappedRwLockReadGuard<'_, Dict<NormalizedPathBuf, ModuleEntry>> {
391394
RwLockReadGuard::map(self.0.borrow(), |mc| &mc.cache)
392395
}
393396

crates/erg_compiler/module/global.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ impl SharedCompilerResource {
141141
}
142142
}
143143

144-
pub fn get_module(&self, path: &std::path::Path) -> Option<MappedRwLockReadGuard<ModuleEntry>> {
144+
pub fn get_module(
145+
&self,
146+
path: &std::path::Path,
147+
) -> Option<MappedRwLockReadGuard<'_, ModuleEntry>> {
145148
if path.to_string_lossy().ends_with(".d.er") {
146149
self.py_mod_cache.get(path)
147150
} else {

crates/erg_compiler/module/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl SharedModuleGraph {
320320
pub fn get_node(
321321
&self,
322322
path: &NormalizedPathBuf,
323-
) -> Option<MappedRwLockReadGuard<Node<NormalizedPathBuf, ()>>> {
323+
) -> Option<MappedRwLockReadGuard<'_, Node<NormalizedPathBuf, ()>>> {
324324
RwLockReadGuard::try_map(self.0.borrow(), |graph| graph.get_node(path)).ok()
325325
}
326326

@@ -359,7 +359,7 @@ impl SharedModuleGraph {
359359
self.0.borrow_mut().inc_ref(referrer, depends_on)
360360
}
361361

362-
pub fn ref_inner(&self) -> RwLockReadGuard<ModuleGraph> {
362+
pub fn ref_inner(&self) -> RwLockReadGuard<'_, ModuleGraph> {
363363
self.0.borrow()
364364
}
365365

crates/erg_compiler/module/impls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl SharedTraitImpls {
115115
pub fn get<Q: Eq + Hash + ?Sized>(
116116
&self,
117117
path: &Q,
118-
) -> Option<MappedRwLockReadGuard<Set<TraitImpl>>>
118+
) -> Option<MappedRwLockReadGuard<'_, Set<TraitImpl>>>
119119
where
120120
Str: Borrow<Q>,
121121
{
@@ -125,7 +125,7 @@ impl SharedTraitImpls {
125125
pub fn get_mut<Q: Eq + Hash + ?Sized>(
126126
&self,
127127
path: &Q,
128-
) -> Option<MappedRwLockWriteGuard<Set<TraitImpl>>>
128+
) -> Option<MappedRwLockWriteGuard<'_, Set<TraitImpl>>>
129129
where
130130
Str: Borrow<Q>,
131131
{
@@ -158,7 +158,7 @@ impl SharedTraitImpls {
158158
self.0.borrow_mut().rename_path(old, new);
159159
}
160160

161-
pub fn ref_inner(&self) -> MappedRwLockReadGuard<Dict<Str, Set<TraitImpl>>> {
161+
pub fn ref_inner(&self) -> MappedRwLockReadGuard<'_, Dict<Str, Set<TraitImpl>>> {
162162
RwLockReadGuard::map(self.0.borrow(), |tis| &tis.cache)
163163
}
164164

crates/erg_compiler/module/index.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use crate::varinfo::{AbsLocation, VarInfo};
1313
pub struct Members<'a>(MappedRwLockReadGuard<'a, Dict<AbsLocation, ModuleIndexValue>>);
1414

1515
impl Members<'_> {
16-
pub fn iter(&self) -> Iter<AbsLocation, ModuleIndexValue> {
16+
pub fn iter(&self) -> Iter<'_, AbsLocation, ModuleIndexValue> {
1717
self.0.iter()
1818
}
1919

20-
pub fn keys(&self) -> Keys<AbsLocation, ModuleIndexValue> {
20+
pub fn keys(&self) -> Keys<'_, AbsLocation, ModuleIndexValue> {
2121
self.0.keys()
2222
}
2323

24-
pub fn values(&self) -> Values<AbsLocation, ModuleIndexValue> {
24+
pub fn values(&self) -> Values<'_, AbsLocation, ModuleIndexValue> {
2525
self.0.values()
2626
}
2727
}
@@ -170,11 +170,11 @@ impl SharedModuleIndex {
170170
pub fn get_refs(
171171
&self,
172172
referee: &AbsLocation,
173-
) -> Option<MappedRwLockReadGuard<ModuleIndexValue>> {
173+
) -> Option<MappedRwLockReadGuard<'_, ModuleIndexValue>> {
174174
RwLockReadGuard::try_map(self.0.borrow(), |index| index.get_refs(referee)).ok()
175175
}
176176

177-
pub fn members(&self) -> Members {
177+
pub fn members(&self) -> Members<'_> {
178178
Members(RwLockReadGuard::map(self.0.borrow(), |mi| &mi.members))
179179
}
180180

crates/erg_compiler/ty/free.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ impl<T: Clone + Send + Sync + 'static> Free<T> {
11041104
}
11051105

11061106
#[track_caller]
1107-
pub fn get_linked_ref(&self) -> Option<Ref<T>> {
1107+
pub fn get_linked_ref(&self) -> Option<Ref<'_, T>> {
11081108
Ref::filter_map(self.borrow(), |f| match f {
11091109
FreeKind::Linked(t) | FreeKind::UndoableLinked { t, .. } => Some(t),
11101110
FreeKind::Unbound { .. } | FreeKind::NamedUnbound { .. } => None,
@@ -1113,7 +1113,7 @@ impl<T: Clone + Send + Sync + 'static> Free<T> {
11131113
}
11141114

11151115
#[track_caller]
1116-
pub fn get_linked_refmut(&self) -> Option<RefMut<T>> {
1116+
pub fn get_linked_refmut(&self) -> Option<RefMut<'_, T>> {
11171117
RefMut::filter_map(self.borrow_mut(), |f| match f {
11181118
FreeKind::Linked(t) | FreeKind::UndoableLinked { t, .. } => Some(t),
11191119
FreeKind::Unbound { .. } | FreeKind::NamedUnbound { .. } => None,
@@ -1122,15 +1122,15 @@ impl<T: Clone + Send + Sync + 'static> Free<T> {
11221122
}
11231123

11241124
#[track_caller]
1125-
pub fn get_previous(&self) -> Option<Ref<Box<FreeKind<T>>>> {
1125+
pub fn get_previous(&self) -> Option<Ref<'_, Box<FreeKind<T>>>> {
11261126
Ref::filter_map(self.borrow(), |f| match f {
11271127
FreeKind::UndoableLinked { previous, .. } => Some(previous),
11281128
_ => None,
11291129
})
11301130
.ok()
11311131
}
11321132

1133-
pub fn get_undoable_root(&self) -> Option<Ref<FreeKind<T>>> {
1133+
pub fn get_undoable_root(&self) -> Option<Ref<'_, FreeKind<T>>> {
11341134
let mut prev = Ref::map(self.get_previous()?, |f| f.as_ref());
11351135
loop {
11361136
match Ref::filter_map(prev, |f| f.get_previous()) {

0 commit comments

Comments
 (0)