mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Remove one more Ty
This commit is contained in:
parent
a1639d0d1e
commit
61c3887b70
3 changed files with 3 additions and 8 deletions
|
@ -986,11 +986,6 @@ impl Type {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: remove
|
|
||||||
pub fn into_ty(self) -> Ty {
|
|
||||||
self.ty.value
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_adt(&self) -> Option<Adt> {
|
pub fn as_adt(&self) -> Option<Adt> {
|
||||||
let (adt, _subst) = self.ty.value.as_adt()?;
|
let (adt, _subst) = self.ty.value.as_adt()?;
|
||||||
Some(adt.into())
|
Some(adt.into())
|
||||||
|
|
|
@ -427,7 +427,7 @@ impl SourceAnalyzer {
|
||||||
|
|
||||||
/// Checks that particular type `ty` implements `std::future::Future`.
|
/// Checks that particular type `ty` implements `std::future::Future`.
|
||||||
/// This function is used in `.await` syntax completion.
|
/// This function is used in `.await` syntax completion.
|
||||||
pub fn impls_future(&self, db: &impl HirDatabase, ty: Ty) -> bool {
|
pub fn impls_future(&self, db: &impl HirDatabase, ty: Type) -> bool {
|
||||||
let std_future_path = known::std_future_future();
|
let std_future_path = known::std_future_future();
|
||||||
|
|
||||||
let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) {
|
let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) {
|
||||||
|
@ -440,7 +440,7 @@ impl SourceAnalyzer {
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let canonical_ty = Canonical { value: ty, num_vars: 0 };
|
let canonical_ty = Canonical { value: ty.ty.value, num_vars: 0 };
|
||||||
implements_trait(&canonical_ty, db, &self.resolver, krate.into(), std_future_trait)
|
implements_trait(&canonical_ty, db, &self.resolver, krate.into(), std_future_trait)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
|
||||||
complete_methods(acc, ctx, &receiver_ty);
|
complete_methods(acc, ctx, &receiver_ty);
|
||||||
|
|
||||||
// Suggest .await syntax for types that implement Future trait
|
// Suggest .await syntax for types that implement Future trait
|
||||||
if ctx.analyzer.impls_future(ctx.db, receiver_ty.into_ty()) {
|
if ctx.analyzer.impls_future(ctx.db, receiver_ty) {
|
||||||
CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await")
|
CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await")
|
||||||
.detail("expr.await")
|
.detail("expr.await")
|
||||||
.insert_text("await")
|
.insert_text("await")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue