Skip to content

Commit 34385e9

Browse files
camelidBoxyUwU
andcommitted
Reuse existing logic for type aliases
Co-authored-by: BoxyUwU <[email protected]>
1 parent 71cee31 commit 34385e9

File tree

1 file changed

+3
-14
lines changed
  • compiler/rustc_hir_analysis/src/hir_ty_lowering

1 file changed

+3
-14
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -1174,20 +1174,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
11741174
LowerAssocMode::Type { permit_variants },
11751175
)? {
11761176
LoweredAssoc::Term(def_id, args) => {
1177-
let assoc = tcx.associated_item(def_id);
1178-
let ty = if matches!(
1179-
assoc,
1180-
ty::AssocItem {
1181-
container: ty::AssocItemContainer::Impl,
1182-
trait_item_def_id: None,
1183-
..
1184-
}
1185-
) {
1186-
Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new_from_args(tcx, def_id, args))
1187-
} else {
1188-
Ty::new_projection_from_args(tcx, def_id, args)
1189-
};
1190-
Ok((ty, DefKind::AssocTy, def_id))
1177+
let alias_ty = ty::AliasTy::new_from_args(tcx, def_id, args);
1178+
let ty = Ty::new_alias(tcx, alias_ty.kind(tcx), alias_ty);
1179+
Ok((ty, tcx.def_kind(def_id), def_id))
11911180
}
11921181
LoweredAssoc::Variant { adt, variant_did } => Ok((adt, DefKind::Variant, variant_did)),
11931182
}

0 commit comments

Comments
 (0)