mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +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 =
|
let ctx =
|
||||||
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
|
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
|
||||||
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
|
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
|
||||||
let inner = if db.type_alias_data(t).is_extern {
|
if db.type_alias_data(t).is_extern {
|
||||||
Ty::simple(TypeCtor::ForeignType(t))
|
Binders::new(substs.len(), Ty::apply(TypeCtor::ForeignType(t), substs))
|
||||||
} else {
|
} else {
|
||||||
let type_ref = &db.type_alias_data(t).type_ref;
|
let type_ref = &db.type_alias_data(t).type_ref;
|
||||||
Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error))
|
let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error));
|
||||||
};
|
|
||||||
Binders::new(substs.len(), inner)
|
Binders::new(substs.len(), inner)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -250,6 +250,14 @@ impl Ty {
|
||||||
TypeCtor::Adt(def_id) => {
|
TypeCtor::Adt(def_id) => {
|
||||||
return Some(std::iter::once(def_id.module(db.upcast()).krate).collect())
|
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::Bool => lang_item_crate!("bool"),
|
||||||
TypeCtor::Char => lang_item_crate!("char"),
|
TypeCtor::Char => lang_item_crate!("char"),
|
||||||
TypeCtor::Float(f) => match f.bitness {
|
TypeCtor::Float(f) => match f.bitness {
|
||||||
|
|
|
@ -1072,7 +1072,6 @@ fn method_resolution_foreign_opaque_type() {
|
||||||
s.foo();
|
s.foo();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
// FIXME: 's.foo()' should be `bool`.
|
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
75..79 'self': &S
|
75..79 'self': &S
|
||||||
89..109 '{ ... }': bool
|
89..109 '{ ... }': bool
|
||||||
|
@ -1084,8 +1083,7 @@ fn method_resolution_foreign_opaque_type() {
|
||||||
146..147 'f': fn f() -> &S
|
146..147 'f': fn f() -> &S
|
||||||
146..149 'f()': &S
|
146..149 'f()': &S
|
||||||
157..158 's': &S
|
157..158 's': &S
|
||||||
157..164 's.foo()': {unknown}
|
157..164 's.foo()': bool
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue