5759: Rename hypothetical -> speculative
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-08-14 13:23:58 +00:00 committed by GitHub
commit 3b5947e1cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View file

@ -112,14 +112,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> { pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
self.imp.expand(macro_call) self.imp.expand(macro_call)
} }
pub fn speculative_expand(
pub fn expand_hypothetical(
&self, &self,
actual_macro_call: &ast::MacroCall, actual_macro_call: &ast::MacroCall,
hypothetical_args: &ast::TokenTree, hypothetical_args: &ast::TokenTree,
token_to_map: SyntaxToken, token_to_map: SyntaxToken,
) -> Option<(SyntaxNode, SyntaxToken)> { ) -> Option<(SyntaxNode, SyntaxToken)> {
self.imp.expand_hypothetical(actual_macro_call, hypothetical_args, token_to_map) self.imp.speculative_expand(actual_macro_call, hypothetical_args, token_to_map)
} }
pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken {
@ -311,7 +310,7 @@ impl<'db> SemanticsImpl<'db> {
Some(node) Some(node)
} }
fn expand_hypothetical( fn speculative_expand(
&self, &self,
actual_macro_call: &ast::MacroCall, actual_macro_call: &ast::MacroCall,
hypothetical_args: &ast::TokenTree, hypothetical_args: &ast::TokenTree,
@ -756,7 +755,7 @@ impl<'a> SemanticsScope<'a> {
/// Resolve a path as-if it was written at the given scope. This is /// Resolve a path as-if it was written at the given scope. This is
/// necessary a heuristic, as it doesn't take hygiene into account. /// necessary a heuristic, as it doesn't take hygiene into account.
pub fn resolve_hypothetical(&self, path: &ast::Path) -> Option<PathResolution> { pub fn speculative_resolve(&self, path: &ast::Path) -> Option<PathResolution> {
let hygiene = Hygiene::new(self.db.upcast(), self.file_id); let hygiene = Hygiene::new(self.db.upcast(), self.file_id);
let path = Path::from_src(path.clone(), &hygiene)?; let path = Path::from_src(path.clone(), &hygiene)?;
self.resolve_hir_path(&path) self.resolve_hir_path(&path)

View file

@ -185,7 +185,7 @@ impl<'a> CompletionContext<'a> {
}; };
if let (Some(actual_expansion), Some(hypothetical_expansion)) = ( if let (Some(actual_expansion), Some(hypothetical_expansion)) = (
ctx.sema.expand(&actual_macro_call), ctx.sema.expand(&actual_macro_call),
ctx.sema.expand_hypothetical( ctx.sema.speculative_expand(
&actual_macro_call, &actual_macro_call,
&hypothetical_args, &hypothetical_args,
fake_ident_token, fake_ident_token,

View file

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