Skip to content

Commit 418f419

Browse files
committed
Cleanup assoc_type_shorthand_candidates
1 parent 73a5134 commit 418f419

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/tools/rust-analyzer/crates/hir/src/semantics.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,18 +2288,19 @@ impl<'db> SemanticsScope<'db> {
22882288

22892289
/// Iterates over associated types that may be specified after the given path (using
22902290
/// `Ty::Assoc` syntax).
2291-
pub fn assoc_type_shorthand_candidates<R>(
2291+
pub fn assoc_type_shorthand_candidates(
22922292
&self,
22932293
resolution: &PathResolution,
2294-
mut cb: impl FnMut(&Name, TypeAlias) -> Option<R>,
2295-
) -> Option<R> {
2296-
let def = self.resolver.generic_def()?;
2297-
hir_ty::associated_type_shorthand_candidates(
2298-
self.db,
2299-
def,
2300-
resolution.in_type_ns()?,
2301-
|name, id| cb(name, id.into()),
2302-
)
2294+
mut cb: impl FnMut(TypeAlias),
2295+
) {
2296+
let (Some(def), Some(resolution)) = (self.resolver.generic_def(), resolution.in_type_ns())
2297+
else {
2298+
return;
2299+
};
2300+
hir_ty::associated_type_shorthand_candidates(self.db, def, resolution, |_, id| {
2301+
cb(id.into());
2302+
None::<()>
2303+
});
23032304
}
23042305

23052306
pub fn generic_def(&self) -> Option<crate::GenericDef> {

src/tools/rust-analyzer/crates/ide-completion/src/completions/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ pub(crate) fn complete_expr_path(
140140
Qualified::With { resolution: None, .. } => {}
141141
Qualified::With { resolution: Some(resolution), .. } => {
142142
// Add associated types on type parameters and `Self`.
143-
ctx.scope.assoc_type_shorthand_candidates(resolution, |_, alias| {
143+
ctx.scope.assoc_type_shorthand_candidates(resolution, |alias| {
144144
acc.add_type_alias(ctx, alias);
145-
None::<()>
146145
});
147146
match resolution {
148147
hir::PathResolution::Def(hir::ModuleDef::Module(module)) => {

src/tools/rust-analyzer/crates/ide-completion/src/completions/type.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ pub(crate) fn complete_type_path(
7777
Qualified::With { resolution: None, .. } => {}
7878
Qualified::With { resolution: Some(resolution), .. } => {
7979
// Add associated types on type parameters and `Self`.
80-
ctx.scope.assoc_type_shorthand_candidates(resolution, |_, alias| {
80+
ctx.scope.assoc_type_shorthand_candidates(resolution, |alias| {
8181
acc.add_type_alias(ctx, alias);
82-
None::<()>
8382
});
8483

8584
match resolution {

0 commit comments

Comments
 (0)