mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Use Ty::apply instead of simple and fix method resolution.
This commit is contained in:
parent
eb96964756
commit
3fff5aa4d7
3 changed files with 14 additions and 8 deletions
|
@ -1102,13 +1102,13 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
|
|||
let ctx =
|
||||
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
|
||||
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
|
||||
let inner = if db.type_alias_data(t).is_extern {
|
||||
Ty::simple(TypeCtor::ForeignType(t))
|
||||
if db.type_alias_data(t).is_extern {
|
||||
Binders::new(substs.len(), Ty::apply(TypeCtor::ForeignType(t), substs))
|
||||
} else {
|
||||
let type_ref = &db.type_alias_data(t).type_ref;
|
||||
Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error))
|
||||
};
|
||||
Binders::new(substs.len(), inner)
|
||||
let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error));
|
||||
Binders::new(substs.len(), inner)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -250,6 +250,14 @@ impl Ty {
|
|||
TypeCtor::Adt(def_id) => {
|
||||
return Some(std::iter::once(def_id.module(db.upcast()).krate).collect())
|
||||
}
|
||||
TypeCtor::ForeignType(type_alias_id) => {
|
||||
return Some(
|
||||
std::iter::once(
|
||||
type_alias_id.lookup(db.upcast()).module(db.upcast()).krate,
|
||||
)
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
TypeCtor::Bool => lang_item_crate!("bool"),
|
||||
TypeCtor::Char => lang_item_crate!("char"),
|
||||
TypeCtor::Float(f) => match f.bitness {
|
||||
|
|
|
@ -1072,7 +1072,6 @@ fn method_resolution_foreign_opaque_type() {
|
|||
s.foo();
|
||||
}
|
||||
"#,
|
||||
// FIXME: 's.foo()' should be `bool`.
|
||||
expect![[r#"
|
||||
75..79 'self': &S
|
||||
89..109 '{ ... }': bool
|
||||
|
@ -1084,8 +1083,7 @@ fn method_resolution_foreign_opaque_type() {
|
|||
146..147 'f': fn f() -> &S
|
||||
146..149 'f()': &S
|
||||
157..158 's': &S
|
||||
157..164 's.foo()': {unknown}
|
||||
157..164 's.foo()': bool
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue