diff options
Diffstat (limited to 'crates/hir_ty/src/infer.rs')
-rw-r--r-- | crates/hir_ty/src/infer.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index db3c937ff..7a4268819 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -28,13 +28,14 @@ use hir_def::{ | |||
28 | AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, FunctionId, HasModule, Lookup, | 28 | AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, FunctionId, HasModule, Lookup, |
29 | TraitId, TypeAliasId, VariantId, | 29 | TraitId, TypeAliasId, VariantId, |
30 | }; | 30 | }; |
31 | use hir_expand::{diagnostics::DiagnosticSink, name::name}; | 31 | use hir_expand::name::name; |
32 | use la_arena::ArenaMap; | 32 | use la_arena::ArenaMap; |
33 | use rustc_hash::FxHashMap; | 33 | use rustc_hash::FxHashMap; |
34 | use stdx::impl_from; | 34 | use stdx::impl_from; |
35 | use syntax::SmolStr; | 35 | use syntax::SmolStr; |
36 | 36 | ||
37 | use super::{DomainGoal, InEnvironment, ProjectionTy, TraitEnvironment, TraitRef, Ty}; | 37 | use super::{DomainGoal, InEnvironment, ProjectionTy, TraitEnvironment, TraitRef, Ty}; |
38 | use crate::diagnostics_sink::DiagnosticSink; | ||
38 | use crate::{ | 39 | use crate::{ |
39 | db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic, | 40 | db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic, |
40 | lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy, Goal, Interner, Substitution, | 41 | lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy, Goal, Interner, Substitution, |
@@ -557,7 +558,13 @@ impl<'a> InferenceContext<'a> { | |||
557 | 558 | ||
558 | self.infer_pat(*pat, &ty, BindingMode::default()); | 559 | self.infer_pat(*pat, &ty, BindingMode::default()); |
559 | } | 560 | } |
560 | let return_ty = self.make_ty_with_mode(&data.ret_type, ImplTraitLoweringMode::Disallowed); // FIXME implement RPIT | 561 | let error_ty = &TypeRef::Error; |
562 | let return_ty = if data.is_async() { | ||
563 | data.async_ret_type.as_deref().unwrap_or(error_ty) | ||
564 | } else { | ||
565 | &*data.ret_type | ||
566 | }; | ||
567 | let return_ty = self.make_ty_with_mode(return_ty, ImplTraitLoweringMode::Disallowed); // FIXME implement RPIT | ||
561 | self.return_ty = return_ty; | 568 | self.return_ty = return_ty; |
562 | } | 569 | } |
563 | 570 | ||
@@ -578,9 +585,14 @@ impl<'a> InferenceContext<'a> { | |||
578 | } | 585 | } |
579 | 586 | ||
580 | fn resolve_ops_try_ok(&self) -> Option<TypeAliasId> { | 587 | fn resolve_ops_try_ok(&self) -> Option<TypeAliasId> { |
588 | // FIXME resolve via lang_item once try v2 is stable | ||
581 | let path = path![core::ops::Try]; | 589 | let path = path![core::ops::Try]; |
582 | let trait_ = self.resolver.resolve_known_trait(self.db.upcast(), &path)?; | 590 | let trait_ = self.resolver.resolve_known_trait(self.db.upcast(), &path)?; |
583 | self.db.trait_data(trait_).associated_type_by_name(&name![Ok]) | 591 | let trait_data = self.db.trait_data(trait_); |
592 | trait_data | ||
593 | // FIXME remove once try v2 is stable | ||
594 | .associated_type_by_name(&name![Ok]) | ||
595 | .or_else(|| trait_data.associated_type_by_name(&name![Output])) | ||
584 | } | 596 | } |
585 | 597 | ||
586 | fn resolve_ops_neg_output(&self) -> Option<TypeAliasId> { | 598 | fn resolve_ops_neg_output(&self) -> Option<TypeAliasId> { |
@@ -793,11 +805,11 @@ impl std::ops::BitOrAssign for Diverges { | |||
793 | 805 | ||
794 | mod diagnostics { | 806 | mod diagnostics { |
795 | use hir_def::{expr::ExprId, DefWithBodyId}; | 807 | use hir_def::{expr::ExprId, DefWithBodyId}; |
796 | use hir_expand::diagnostics::DiagnosticSink; | ||
797 | 808 | ||
798 | use crate::{ | 809 | use crate::{ |
799 | db::HirDatabase, | 810 | db::HirDatabase, |
800 | diagnostics::{BreakOutsideOfLoop, NoSuchField}, | 811 | diagnostics::{BreakOutsideOfLoop, NoSuchField}, |
812 | diagnostics_sink::DiagnosticSink, | ||
801 | }; | 813 | }; |
802 | 814 | ||
803 | #[derive(Debug, PartialEq, Eq, Clone)] | 815 | #[derive(Debug, PartialEq, Eq, Clone)] |