Add cycle recovery for type aliases
This commit is contained in:
parent
3ca40f7c08
commit
1c622e9fed
3 changed files with 10 additions and 2 deletions
|
@ -22,6 +22,7 @@ pub trait HirDatabase: DefDatabase {
|
||||||
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
|
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
|
||||||
|
|
||||||
#[salsa::invoke(crate::lower::ty_query)]
|
#[salsa::invoke(crate::lower::ty_query)]
|
||||||
|
#[salsa::cycle(crate::lower::ty_recover)]
|
||||||
fn ty(&self, def: TyDefId) -> Ty;
|
fn ty(&self, def: TyDefId) -> Ty;
|
||||||
|
|
||||||
#[salsa::invoke(crate::lower::value_ty_query)]
|
#[salsa::invoke(crate::lower::value_ty_query)]
|
||||||
|
|
|
@ -742,6 +742,11 @@ pub(crate) fn ty_query(db: &impl HirDatabase, def: TyDefId) -> Ty {
|
||||||
TyDefId::TypeAliasId(it) => type_for_type_alias(db, it),
|
TyDefId::TypeAliasId(it) => type_for_type_alias(db, it),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn ty_recover(_db: &impl HirDatabase, _cycle: &[String], _def: &TyDefId) -> Ty {
|
||||||
|
Ty::Unknown
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty {
|
pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty {
|
||||||
match def {
|
match def {
|
||||||
ValueTyDefId::FunctionId(it) => type_for_fn(db, it),
|
ValueTyDefId::FunctionId(it) => type_for_fn(db, it),
|
||||||
|
|
|
@ -2154,7 +2154,6 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic] // we currently can't handle this
|
|
||||||
fn recursive_type_alias() {
|
fn recursive_type_alias() {
|
||||||
assert_snapshot!(
|
assert_snapshot!(
|
||||||
infer(r#"
|
infer(r#"
|
||||||
|
@ -2163,7 +2162,10 @@ type Foo = Foo;
|
||||||
type Bar = A<Bar>;
|
type Bar = A<Bar>;
|
||||||
fn test(x: Foo) {}
|
fn test(x: Foo) {}
|
||||||
"#),
|
"#),
|
||||||
@""
|
@r###"
|
||||||
|
[59; 60) 'x': {unknown}
|
||||||
|
[67; 69) '{}': ()
|
||||||
|
"###
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue