mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Rename hypothetical -> speculative
This commit is contained in:
parent
1ec23e7d33
commit
125744c057
3 changed files with 7 additions and 8 deletions
|
@ -112,14 +112,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
|||
pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
|
||||
self.imp.expand(macro_call)
|
||||
}
|
||||
|
||||
pub fn expand_hypothetical(
|
||||
pub fn speculative_expand(
|
||||
&self,
|
||||
actual_macro_call: &ast::MacroCall,
|
||||
hypothetical_args: &ast::TokenTree,
|
||||
token_to_map: 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 {
|
||||
|
@ -311,7 +310,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
Some(node)
|
||||
}
|
||||
|
||||
fn expand_hypothetical(
|
||||
fn speculative_expand(
|
||||
&self,
|
||||
actual_macro_call: &ast::MacroCall,
|
||||
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
|
||||
/// 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 path = Path::from_src(path.clone(), &hygiene)?;
|
||||
self.resolve_hir_path(&path)
|
||||
|
|
|
@ -185,7 +185,7 @@ impl<'a> CompletionContext<'a> {
|
|||
};
|
||||
if let (Some(actual_expansion), Some(hypothetical_expansion)) = (
|
||||
ctx.sema.expand(&actual_macro_call),
|
||||
ctx.sema.expand_hypothetical(
|
||||
ctx.sema.speculative_expand(
|
||||
&actual_macro_call,
|
||||
&hypothetical_args,
|
||||
fake_ident_token,
|
||||
|
|
|
@ -212,13 +212,13 @@ impl<'db> ResolutionScope<'db> {
|
|||
// First try resolving the whole path. This will work for things like
|
||||
// `std::collections::HashMap`, but will fail for things like
|
||||
// `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);
|
||||
}
|
||||
// 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
|
||||
// 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 {
|
||||
let name = path.segment()?.name_ref()?;
|
||||
adt.ty(self.scope.db).iterate_path_candidates(
|
||||
|
|
Loading…
Reference in a new issue