Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c522669

Browse files
committed
Remove dead code
1 parent c5dcc77 commit c522669

File tree

3 files changed

+2
-79
lines changed

3 files changed

+2
-79
lines changed

crates/ide-completion/src/completions/flyimport.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
110110
if !ctx.config.enable_imports_on_the_fly {
111111
return None;
112112
}
113-
if matches!(ctx.path_kind(), Some(PathKind::Vis { .. } | PathKind::Use))
113+
if matches!(ctx.path_kind(), Some(PathKind::Vis { .. } | PathKind::Use | PathKind::Item { .. }))
114114
|| ctx.is_path_disallowed()
115-
|| ctx.expects_item()
116-
|| ctx.expects_assoc_item()
117115
{
118116
return None;
119117
}

crates/ide-completion/src/context.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,6 @@ impl<'a> CompletionContext<'a> {
334334
self.dot_receiver().is_some()
335335
}
336336

337-
pub(crate) fn expects_assoc_item(&self) -> bool {
338-
matches!(self.completion_location, Some(ImmediateLocation::Trait | ImmediateLocation::Impl))
339-
}
340-
341-
pub(crate) fn expects_item(&self) -> bool {
342-
matches!(self.completion_location, Some(ImmediateLocation::ItemList))
343-
}
344-
345337
// FIXME: This shouldn't exist
346338
pub(crate) fn expects_generic_arg(&self) -> bool {
347339
matches!(self.completion_location, Some(ImmediateLocation::GenericArgList(_)))

crates/ide-completion/src/patterns.rs

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ pub(crate) enum TypeAnnotation {
3939
/// from which file the nodes are.
4040
#[derive(Clone, Debug, PartialEq, Eq)]
4141
pub(crate) enum ImmediateLocation {
42-
Impl,
43-
Trait,
44-
TupleField,
4542
RefExpr,
46-
IdentPat,
47-
StmtList,
48-
ItemList,
4943
TypeBound,
5044
/// Original file ast node
5145
TypeAnnotation(TypeAnnotation),
@@ -140,30 +134,14 @@ pub(crate) fn determine_location(
140134
_ => parent,
141135
},
142136
// SourceFile
143-
None => {
144-
return match node.kind() {
145-
MACRO_ITEMS | SOURCE_FILE => Some(ImmediateLocation::ItemList),
146-
_ => None,
147-
}
148-
}
137+
None => return None,
149138
};
150139

151140
let res = match_ast! {
152141
match parent {
153-
ast::IdentPat(_) => ImmediateLocation::IdentPat,
154-
ast::StmtList(_) => ImmediateLocation::StmtList,
155-
ast::SourceFile(_) => ImmediateLocation::ItemList,
156-
ast::ItemList(_) => ImmediateLocation::ItemList,
157142
ast::RefExpr(_) => ImmediateLocation::RefExpr,
158-
ast::TupleField(_) => ImmediateLocation::TupleField,
159-
ast::TupleFieldList(_) => ImmediateLocation::TupleField,
160143
ast::TypeBound(_) => ImmediateLocation::TypeBound,
161144
ast::TypeBoundList(_) => ImmediateLocation::TypeBound,
162-
ast::AssocItemList(it) => match it.syntax().parent().map(|it| it.kind()) {
163-
Some(IMPL) => ImmediateLocation::Impl,
164-
Some(TRAIT) => ImmediateLocation::Trait,
165-
_ => return None,
166-
},
167145
ast::GenericArgList(_) => sema
168146
.find_node_at_offset_with_macros(original_file, offset)
169147
.map(ImmediateLocation::GenericArgList)?,
@@ -359,56 +337,11 @@ mod tests {
359337
});
360338
}
361339

362-
#[test]
363-
fn test_trait_loc() {
364-
check_location(r"trait A { f$0 }", ImmediateLocation::Trait);
365-
check_location(r"trait A { #[attr] f$0 }", ImmediateLocation::Trait);
366-
check_location(r"trait A { f$0 fn f() {} }", ImmediateLocation::Trait);
367-
check_location(r"trait A { fn f() {} f$0 }", ImmediateLocation::Trait);
368-
check_location(r"trait A$0 {}", None);
369-
check_location(r"trait A { fn f$0 }", None);
370-
}
371-
372-
#[test]
373-
fn test_impl_loc() {
374-
check_location(r"impl A { f$0 }", ImmediateLocation::Impl);
375-
check_location(r"impl A { #[attr] f$0 }", ImmediateLocation::Impl);
376-
check_location(r"impl A { f$0 fn f() {} }", ImmediateLocation::Impl);
377-
check_location(r"impl A { fn f() {} f$0 }", ImmediateLocation::Impl);
378-
check_location(r"impl A$0 {}", None);
379-
check_location(r"impl A { fn f$0 }", None);
380-
}
381-
382-
#[test]
383-
fn test_block_expr_loc() {
384-
check_location(r"fn my_fn() { let a = 2; f$0 }", ImmediateLocation::StmtList);
385-
check_location(r"fn my_fn() { f$0 f }", ImmediateLocation::StmtList);
386-
}
387-
388-
#[test]
389-
fn test_ident_pat_loc() {
390-
check_location(r"fn my_fn(m$0) {}", ImmediateLocation::IdentPat);
391-
check_location(r"fn my_fn() { let m$0 }", ImmediateLocation::IdentPat);
392-
check_location(r"fn my_fn(&m$0) {}", ImmediateLocation::IdentPat);
393-
check_location(r"fn my_fn() { let &m$0 }", ImmediateLocation::IdentPat);
394-
}
395-
396340
#[test]
397341
fn test_ref_expr_loc() {
398342
check_location(r"fn my_fn() { let x = &m$0 foo; }", ImmediateLocation::RefExpr);
399343
}
400344

401-
#[test]
402-
fn test_item_list_loc() {
403-
check_location(r"i$0", ImmediateLocation::ItemList);
404-
check_location(r"#[attr] i$0", ImmediateLocation::ItemList);
405-
check_location(r"fn f() {} i$0", ImmediateLocation::ItemList);
406-
check_location(r"mod foo { f$0 }", ImmediateLocation::ItemList);
407-
check_location(r"mod foo { #[attr] f$0 }", ImmediateLocation::ItemList);
408-
check_location(r"mod foo { fn f() {} f$0 }", ImmediateLocation::ItemList);
409-
check_location(r"mod foo$0 {}", None);
410-
}
411-
412345
#[test]
413346
fn test_impl_prev_sibling() {
414347
check_prev_sibling(r"impl A w$0 ", ImmediatePrevSibling::ImplDefType);

0 commit comments

Comments
 (0)