Enabled Self
in type aliases.
This commit is contained in:
parent
35585c499f
commit
dce27cba78
2 changed files with 12 additions and 2 deletions
|
@ -2529,7 +2529,17 @@ impl<'a> Resolver<'a> {
|
||||||
debug!("(resolving item) resolving {} ({:?})", name, item.node);
|
debug!("(resolving item) resolving {} ({:?})", name, item.node);
|
||||||
|
|
||||||
match item.node {
|
match item.node {
|
||||||
ItemKind::Ty(_, ref generics) |
|
ItemKind::Ty(_, ref generics) => {
|
||||||
|
self.with_current_self_item(item, |this| {
|
||||||
|
this.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| {
|
||||||
|
let item_def_id = this.definitions.local_def_id(item.id);
|
||||||
|
this.with_self_rib(Def::SelfTy(Some(item_def_id), None), |this| {
|
||||||
|
visit::walk_item(this, item)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ItemKind::Existential(_, ref generics) |
|
ItemKind::Existential(_, ref generics) |
|
||||||
ItemKind::Fn(_, _, ref generics, _) => {
|
ItemKind::Fn(_, _, ref generics, _) => {
|
||||||
self.with_generic_param_rib(
|
self.with_generic_param_rib(
|
||||||
|
|
|
@ -1770,7 +1770,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||||
tcx.mk_ty_param(index, tcx.hir().name_by_hir_id(hir_id).as_interned_str())
|
tcx.mk_ty_param(index, tcx.hir().name_by_hir_id(hir_id).as_interned_str())
|
||||||
}
|
}
|
||||||
Res::SelfTy(Some(_), None) => {
|
Res::SelfTy(Some(_), None) => {
|
||||||
// `Self` in trait.
|
// `Self` in trait or type alias.
|
||||||
assert_eq!(opt_self_ty, None);
|
assert_eq!(opt_self_ty, None);
|
||||||
self.prohibit_generics(&path.segments);
|
self.prohibit_generics(&path.segments);
|
||||||
tcx.mk_self_type()
|
tcx.mk_self_type()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue