Skip to content

Commit dce27cb

Browse files
committed
Enabled Self in type aliases.
1 parent 35585c4 commit dce27cb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/librustc_resolve/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,17 @@ impl<'a> Resolver<'a> {
25292529
debug!("(resolving item) resolving {} ({:?})", name, item.node);
25302530

25312531
match item.node {
2532-
ItemKind::Ty(_, ref generics) |
2532+
ItemKind::Ty(_, ref generics) => {
2533+
self.with_current_self_item(item, |this| {
2534+
this.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| {
2535+
let item_def_id = this.definitions.local_def_id(item.id);
2536+
this.with_self_rib(Def::SelfTy(Some(item_def_id), None), |this| {
2537+
visit::walk_item(this, item)
2538+
})
2539+
})
2540+
});
2541+
}
2542+
25332543
ItemKind::Existential(_, ref generics) |
25342544
ItemKind::Fn(_, _, ref generics, _) => {
25352545
self.with_generic_param_rib(

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
17701770
tcx.mk_ty_param(index, tcx.hir().name_by_hir_id(hir_id).as_interned_str())
17711771
}
17721772
Res::SelfTy(Some(_), None) => {
1773-
// `Self` in trait.
1773+
// `Self` in trait or type alias.
17741774
assert_eq!(opt_self_ty, None);
17751775
self.prohibit_generics(&path.segments);
17761776
tcx.mk_self_type()

0 commit comments

Comments
 (0)