aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-14 14:23:58 +0100
committerGitHub <[email protected]>2020-08-14 14:23:58 +0100
commit3b5947e1cd2bcdbea6512c659c4e8590b5305ef3 (patch)
tree39cadc001951e59dca1ec17697a8507e438d4791
parent1ec23e7d33e29c6e14f4fe504e1e253e91339ea4 (diff)
parent125744c057a953b2f1b03042e9a6ec49f1eb0a1e (diff)
Merge #5759
5759: Rename hypothetical -> speculative r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/hir/src/semantics.rs9
-rw-r--r--crates/ide/src/completion/completion_context.rs2
-rw-r--r--crates/ssr/src/resolving.rs4
3 files changed, 7 insertions, 8 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index d8beac98a..3953017c3 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -112,14 +112,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
112 pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> { 112 pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
113 self.imp.expand(macro_call) 113 self.imp.expand(macro_call)
114 } 114 }
115 115 pub fn speculative_expand(
116 pub fn expand_hypothetical(
117 &self, 116 &self,
118 actual_macro_call: &ast::MacroCall, 117 actual_macro_call: &ast::MacroCall,
119 hypothetical_args: &ast::TokenTree, 118 hypothetical_args: &ast::TokenTree,
120 token_to_map: SyntaxToken, 119 token_to_map: SyntaxToken,
121 ) -> Option<(SyntaxNode, SyntaxToken)> { 120 ) -> Option<(SyntaxNode, SyntaxToken)> {
122 self.imp.expand_hypothetical(actual_macro_call, hypothetical_args, token_to_map) 121 self.imp.speculative_expand(actual_macro_call, hypothetical_args, token_to_map)
123 } 122 }
124 123
125 pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { 124 pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken {
@@ -311,7 +310,7 @@ impl<'db> SemanticsImpl<'db> {
311 Some(node) 310 Some(node)
312 } 311 }
313 312
314 fn expand_hypothetical( 313 fn speculative_expand(
315 &self, 314 &self,
316 actual_macro_call: &ast::MacroCall, 315 actual_macro_call: &ast::MacroCall,
317 hypothetical_args: &ast::TokenTree, 316 hypothetical_args: &ast::TokenTree,
@@ -756,7 +755,7 @@ impl<'a> SemanticsScope<'a> {
756 755
757 /// Resolve a path as-if it was written at the given scope. This is 756 /// Resolve a path as-if it was written at the given scope. This is
758 /// necessary a heuristic, as it doesn't take hygiene into account. 757 /// necessary a heuristic, as it doesn't take hygiene into account.
759 pub fn resolve_hypothetical(&self, path: &ast::Path) -> Option<PathResolution> { 758 pub fn speculative_resolve(&self, path: &ast::Path) -> Option<PathResolution> {
760 let hygiene = Hygiene::new(self.db.upcast(), self.file_id); 759 let hygiene = Hygiene::new(self.db.upcast(), self.file_id);
761 let path = Path::from_src(path.clone(), &hygiene)?; 760 let path = Path::from_src(path.clone(), &hygiene)?;
762 self.resolve_hir_path(&path) 761 self.resolve_hir_path(&path)
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs
index 3857dce67..85456a66f 100644
--- a/crates/ide/src/completion/completion_context.rs
+++ b/crates/ide/src/completion/completion_context.rs
@@ -185,7 +185,7 @@ impl<'a> CompletionContext<'a> {
185 }; 185 };
186 if let (Some(actual_expansion), Some(hypothetical_expansion)) = ( 186 if let (Some(actual_expansion), Some(hypothetical_expansion)) = (
187 ctx.sema.expand(&actual_macro_call), 187 ctx.sema.expand(&actual_macro_call),
188 ctx.sema.expand_hypothetical( 188 ctx.sema.speculative_expand(
189 &actual_macro_call, 189 &actual_macro_call,
190 &hypothetical_args, 190 &hypothetical_args,
191 fake_ident_token, 191 fake_ident_token,
diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs
index 4441fb426..b932132d5 100644
--- a/crates/ssr/src/resolving.rs
+++ b/crates/ssr/src/resolving.rs
@@ -212,13 +212,13 @@ impl<'db> ResolutionScope<'db> {
212 // First try resolving the whole path. This will work for things like 212 // First try resolving the whole path. This will work for things like
213 // `std::collections::HashMap`, but will fail for things like 213 // `std::collections::HashMap`, but will fail for things like
214 // `std::collections::HashMap::new`. 214 // `std::collections::HashMap::new`.
215 if let Some(resolution) = self.scope.resolve_hypothetical(&path) { 215 if let Some(resolution) = self.scope.speculative_resolve(&path) {
216 return Some(resolution); 216 return Some(resolution);
217 } 217 }
218 // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if 218 // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if
219 // that succeeds, then iterate through the candidates on the resolved type with the provided 219 // that succeeds, then iterate through the candidates on the resolved type with the provided
220 // name. 220 // name.
221 let resolved_qualifier = self.scope.resolve_hypothetical(&path.qualifier()?)?; 221 let resolved_qualifier = self.scope.speculative_resolve(&path.qualifier()?)?;
222 if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier { 222 if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier {
223 let name = path.segment()?.name_ref()?; 223 let name = path.segment()?.name_ref()?;
224 adt.ty(self.scope.db).iterate_path_candidates( 224 adt.ty(self.scope.db).iterate_path_candidates(