mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 11:53:44 +00:00
Lower extern type alias as foreign opaque type.
This commit is contained in:
parent
b302f69b7c
commit
389d9a6c2d
@ -54,6 +54,7 @@ pub struct TypeAliasData {
|
||||
pub name: Name,
|
||||
pub type_ref: Option<TypeRef>,
|
||||
pub visibility: RawVisibility,
|
||||
pub is_extern: bool,
|
||||
/// Bounds restricting the type alias itself (eg. `type Ty: Bound;` in a trait or impl).
|
||||
pub bounds: Vec<TypeBound>,
|
||||
}
|
||||
@ -71,6 +72,7 @@ impl TypeAliasData {
|
||||
name: typ.name.clone(),
|
||||
type_ref: typ.type_ref.clone(),
|
||||
visibility: item_tree[typ.visibility].clone(),
|
||||
is_extern: typ.is_extern,
|
||||
bounds: typ.bounds.to_vec(),
|
||||
})
|
||||
}
|
||||
|
@ -1101,9 +1101,13 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
|
||||
let resolver = t.resolver(db.upcast());
|
||||
let ctx =
|
||||
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
|
||||
let type_ref = &db.type_alias_data(t).type_ref;
|
||||
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
|
||||
let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error));
|
||||
let inner = if db.type_alias_data(t).is_extern {
|
||||
Ty::simple(TypeCtor::ForeignType(t))
|
||||
} 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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user