mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Include generics when lowering extern type
This commit is contained in:
parent
fa00326247
commit
e350bc2cf5
2 changed files with 21 additions and 5 deletions
|
@ -1976,13 +1976,13 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
|
||||||
.with_impl_trait_mode(ImplTraitLoweringMode::Opaque)
|
.with_impl_trait_mode(ImplTraitLoweringMode::Opaque)
|
||||||
.with_type_param_mode(ParamLoweringMode::Variable);
|
.with_type_param_mode(ParamLoweringMode::Variable);
|
||||||
let type_alias_data = db.type_alias_data(t);
|
let type_alias_data = db.type_alias_data(t);
|
||||||
if type_alias_data.is_extern {
|
let inner = if type_alias_data.is_extern {
|
||||||
Binders::empty(Interner, TyKind::Foreign(crate::to_foreign_def_id(t)).intern(Interner))
|
TyKind::Foreign(crate::to_foreign_def_id(t)).intern(Interner)
|
||||||
} else {
|
} else {
|
||||||
let type_ref = &type_alias_data.type_ref;
|
let type_ref = &type_alias_data.type_ref;
|
||||||
let inner = ctx.lower_ty(type_ref.as_deref().unwrap_or(&TypeRef::Error));
|
ctx.lower_ty(type_ref.as_deref().unwrap_or(&TypeRef::Error))
|
||||||
make_binders(db, &generics, inner)
|
};
|
||||||
}
|
make_binders(db, &generics, inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -2195,3 +2195,19 @@ impl<'a, T: Deref<Target = impl Trait>> Struct<'a, T> {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn issue_17767() {
|
||||||
|
check_infer(
|
||||||
|
r#"
|
||||||
|
extern "C" {
|
||||||
|
type Foo<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() -> Foo {}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
47..49 '{}': Foo
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue