diff options
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/lower.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 8 | ||||
-rw-r--r-- | crates/hir_ty/src/tests/method_resolution.rs | 4 |
3 files changed, 14 insertions, 8 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 39252bc5e..708e2af0f 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -1102,13 +1102,13 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> { | |||
1102 | let ctx = | 1102 | let ctx = |
1103 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); | 1103 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); |
1104 | let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST); | 1104 | let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST); |
1105 | let inner = if db.type_alias_data(t).is_extern { | 1105 | if db.type_alias_data(t).is_extern { |
1106 | Ty::simple(TypeCtor::ForeignType(t)) | 1106 | Binders::new(substs.len(), Ty::apply(TypeCtor::ForeignType(t), substs)) |
1107 | } else { | 1107 | } else { |
1108 | let type_ref = &db.type_alias_data(t).type_ref; | 1108 | let type_ref = &db.type_alias_data(t).type_ref; |
1109 | Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error)) | 1109 | let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error)); |
1110 | }; | 1110 | Binders::new(substs.len(), inner) |
1111 | Binders::new(substs.len(), inner) | 1111 | } |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 1114 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index ec59145c7..8961df404 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -250,6 +250,14 @@ impl Ty { | |||
250 | TypeCtor::Adt(def_id) => { | 250 | TypeCtor::Adt(def_id) => { |
251 | return Some(std::iter::once(def_id.module(db.upcast()).krate).collect()) | 251 | return Some(std::iter::once(def_id.module(db.upcast()).krate).collect()) |
252 | } | 252 | } |
253 | TypeCtor::ForeignType(type_alias_id) => { | ||
254 | return Some( | ||
255 | std::iter::once( | ||
256 | type_alias_id.lookup(db.upcast()).module(db.upcast()).krate, | ||
257 | ) | ||
258 | .collect(), | ||
259 | ) | ||
260 | } | ||
253 | TypeCtor::Bool => lang_item_crate!("bool"), | 261 | TypeCtor::Bool => lang_item_crate!("bool"), |
254 | TypeCtor::Char => lang_item_crate!("char"), | 262 | TypeCtor::Char => lang_item_crate!("char"), |
255 | TypeCtor::Float(f) => match f.bitness { | 263 | TypeCtor::Float(f) => match f.bitness { |
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 690f9d66e..0f17ff151 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs | |||
@@ -1072,7 +1072,6 @@ fn method_resolution_foreign_opaque_type() { | |||
1072 | s.foo(); | 1072 | s.foo(); |
1073 | } | 1073 | } |
1074 | "#, | 1074 | "#, |
1075 | // FIXME: 's.foo()' should be `bool`. | ||
1076 | expect![[r#" | 1075 | expect![[r#" |
1077 | 75..79 'self': &S | 1076 | 75..79 'self': &S |
1078 | 89..109 '{ ... }': bool | 1077 | 89..109 '{ ... }': bool |
@@ -1084,8 +1083,7 @@ fn method_resolution_foreign_opaque_type() { | |||
1084 | 146..147 'f': fn f() -> &S | 1083 | 146..147 'f': fn f() -> &S |
1085 | 146..149 'f()': &S | 1084 | 146..149 'f()': &S |
1086 | 157..158 's': &S | 1085 | 157..158 's': &S |
1087 | 157..164 's.foo()': {unknown} | 1086 | 157..164 's.foo()': bool |
1088 | "#]], | 1087 | "#]], |
1089 | ); | 1088 | ); |
1090 | } | 1089 | } |
1091 | |||