mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Support path starting with a type
This commit is contained in:
parent
2d79a1ad83
commit
4926bed426
10 changed files with 210 additions and 127 deletions
|
@ -26,7 +26,7 @@ use crate::{
|
|||
},
|
||||
ids::LocationCtx,
|
||||
name,
|
||||
path::{PathKind, PathSegment},
|
||||
path::PathKind,
|
||||
resolve::{ScopeDef, TypeNs, ValueNs},
|
||||
ty::method_resolution::implements_trait,
|
||||
AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirFileId, MacroDef,
|
||||
|
@ -433,14 +433,10 @@ impl SourceAnalyzer {
|
|||
/// Checks that particular type `ty` implements `std::future::Future`.
|
||||
/// This function is used in `.await` syntax completion.
|
||||
pub fn impls_future(&self, db: &impl HirDatabase, ty: Ty) -> bool {
|
||||
let std_future_path = Path {
|
||||
kind: PathKind::Abs,
|
||||
segments: vec![
|
||||
PathSegment { name: name::STD, args_and_bindings: None },
|
||||
PathSegment { name: name::FUTURE_MOD, args_and_bindings: None },
|
||||
PathSegment { name: name::FUTURE_TYPE, args_and_bindings: None },
|
||||
],
|
||||
};
|
||||
let std_future_path = Path::from_simple_segments(
|
||||
PathKind::Abs,
|
||||
vec![name::STD, name::FUTURE_MOD, name::FUTURE_TYPE],
|
||||
);
|
||||
|
||||
let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) {
|
||||
Some(it) => it,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue