Skip to content

Commit 3b5947e

Browse files
bors[bot]matklad
andauthored
Merge #5759
5759: Rename hypothetical -> speculative r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 1ec23e7 + 125744c commit 3b5947e

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

crates/hir/src/semantics.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
112112
pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
113113
self.imp.expand(macro_call)
114114
}
115-
116-
pub fn expand_hypothetical(
115+
pub fn speculative_expand(
117116
&self,
118117
actual_macro_call: &ast::MacroCall,
119118
hypothetical_args: &ast::TokenTree,
120119
token_to_map: SyntaxToken,
121120
) -> 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)
123122
}
124123

125124
pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken {
@@ -311,7 +310,7 @@ impl<'db> SemanticsImpl<'db> {
311310
Some(node)
312311
}
313312

314-
fn expand_hypothetical(
313+
fn speculative_expand(
315314
&self,
316315
actual_macro_call: &ast::MacroCall,
317316
hypothetical_args: &ast::TokenTree,
@@ -756,7 +755,7 @@ impl<'a> SemanticsScope<'a> {
756755

757756
/// Resolve a path as-if it was written at the given scope. This is
758757
/// 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> {
760759
let hygiene = Hygiene::new(self.db.upcast(), self.file_id);
761760
let path = Path::from_src(path.clone(), &hygiene)?;
762761
self.resolve_hir_path(&path)

crates/ide/src/completion/completion_context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<'a> CompletionContext<'a> {
185185
};
186186
if let (Some(actual_expansion), Some(hypothetical_expansion)) = (
187187
ctx.sema.expand(&actual_macro_call),
188-
ctx.sema.expand_hypothetical(
188+
ctx.sema.speculative_expand(
189189
&actual_macro_call,
190190
&hypothetical_args,
191191
fake_ident_token,

crates/ssr/src/resolving.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ impl<'db> ResolutionScope<'db> {
212212
// First try resolving the whole path. This will work for things like
213213
// `std::collections::HashMap`, but will fail for things like
214214
// `std::collections::HashMap::new`.
215-
if let Some(resolution) = self.scope.resolve_hypothetical(&path) {
215+
if let Some(resolution) = self.scope.speculative_resolve(&path) {
216216
return Some(resolution);
217217
}
218218
// Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if
219219
// that succeeds, then iterate through the candidates on the resolved type with the provided
220220
// name.
221-
let resolved_qualifier = self.scope.resolve_hypothetical(&path.qualifier()?)?;
221+
let resolved_qualifier = self.scope.speculative_resolve(&path.qualifier()?)?;
222222
if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier {
223223
let name = path.segment()?.name_ref()?;
224224
adt.ty(self.scope.db).iterate_path_candidates(

0 commit comments

Comments
 (0)