From 941a5744095e55b9b0cafa63b10cb5480d02cc03 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 7 Mar 2020 17:53:22 +0100 Subject: Fix CompletionContext module field (by removing it) Two uses only needed the crate; one was wrong and should use the module from the scope instead. --- crates/ra_ide/src/completion/completion_context.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src/completion/completion_context.rs') diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index d173ef1f3..e7a8c78d0 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -24,7 +24,7 @@ pub(crate) struct CompletionContext<'a> { pub(super) original_token: SyntaxToken, /// The token before the cursor, in the macro-expanded file. pub(super) token: SyntaxToken, - pub(super) module: Option, + pub(super) krate: Option, pub(super) name_ref_syntax: Option, pub(super) function_syntax: Option, pub(super) use_item_syntax: Option, @@ -73,8 +73,7 @@ impl<'a> CompletionContext<'a> { let fake_ident_token = file_with_fake_ident.syntax().token_at_offset(position.offset).right_biased().unwrap(); - // TODO: shouldn't this take the position into account? (in case we're inside a mod {}) - let module = sema.to_module_def(position.file_id); + let krate = sema.to_module_def(position.file_id).map(|m| m.krate()); let original_token = original_file.syntax().token_at_offset(position.offset).left_biased()?; let token = sema.descend_into_macros(original_token.clone()); @@ -84,7 +83,7 @@ impl<'a> CompletionContext<'a> { original_token, token, offset: position.offset, - module, + krate, name_ref_syntax: None, function_syntax: None, use_item_syntax: None, @@ -132,7 +131,6 @@ impl<'a> CompletionContext<'a> { if new_offset >= actual_expansion.text_range().end() { break; } - // TODO check that the expansions 'look the same' up to the inserted token? original_file = actual_expansion; hypothetical_file = hypothetical_expansion.0; fake_ident_token = hypothetical_expansion.1; -- cgit v1.2.3