delegation: Implement list delegation
```rust reuse prefix::{a, b, c} ```
This commit is contained in:
parent
8387315ab3
commit
c30b41012d
29 changed files with 511 additions and 60 deletions
|
@ -825,7 +825,9 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
}
|
||||
ItemKind::Impl { .. } | ItemKind::ForeignMod(..) | ItemKind::GlobalAsm(..) => {}
|
||||
|
||||
ItemKind::MacroDef(..) | ItemKind::MacCall(_) => unreachable!(),
|
||||
ItemKind::MacroDef(..) | ItemKind::MacCall(_) | ItemKind::DelegationMac(..) => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1381,7 +1383,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
| AssocItemKind::Delegation(..)
|
||||
| AssocItemKind::Fn(..) => ValueNS,
|
||||
AssocItemKind::Type(..) => TypeNS,
|
||||
AssocItemKind::MacCall(_) => bug!(), // handled above
|
||||
AssocItemKind::MacCall(_) | AssocItemKind::DelegationMac(..) => bug!(), // handled above
|
||||
};
|
||||
|
||||
let parent = self.parent_scope.module;
|
||||
|
|
|
@ -139,6 +139,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
|||
ItemKind::GlobalAsm(..) => DefKind::GlobalAsm,
|
||||
ItemKind::Use(..) => return visit::walk_item(self, i),
|
||||
ItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
|
||||
ItemKind::DelegationMac(..) => unreachable!(),
|
||||
};
|
||||
let def_id = self.create_def(i.id, i.ident.name, def_kind, i.span);
|
||||
|
||||
|
@ -278,6 +279,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
|||
AssocItemKind::Const(..) => DefKind::AssocConst,
|
||||
AssocItemKind::Type(..) => DefKind::AssocTy,
|
||||
AssocItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
|
||||
AssocItemKind::DelegationMac(..) => unreachable!(),
|
||||
};
|
||||
|
||||
let def = self.create_def(i.id, i.ident.name, def_kind, i.span);
|
||||
|
|
|
@ -236,7 +236,7 @@ impl<'r, 'ast, 'tcx> Visitor<'ast> for EffectiveVisibilitiesVisitor<'ast, 'r, 't
|
|||
ast::ItemKind::Impl(..) => return,
|
||||
|
||||
// Should be unreachable at this stage
|
||||
ast::ItemKind::MacCall(..) => panic!(
|
||||
ast::ItemKind::MacCall(..) | ast::ItemKind::DelegationMac(..) => panic!(
|
||||
"ast::ItemKind::MacCall encountered, this should not anymore appear at this stage"
|
||||
),
|
||||
|
||||
|
|
|
@ -2561,7 +2561,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
|
||||
ItemKind::ExternCrate(..) => {}
|
||||
|
||||
ItemKind::MacCall(_) => panic!("unexpanded macro in resolve!"),
|
||||
ItemKind::MacCall(_) | ItemKind::DelegationMac(..) => {
|
||||
panic!("unexpanded macro in resolve!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2849,7 +2851,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| {
|
||||
walk_assoc_item(this, generics, LifetimeBinderKind::Item, item)
|
||||
}),
|
||||
AssocItemKind::MacCall(_) => {
|
||||
AssocItemKind::MacCall(_) | AssocItemKind::DelegationMac(..) => {
|
||||
panic!("unexpanded macro in resolve!")
|
||||
}
|
||||
};
|
||||
|
@ -3116,7 +3118,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
},
|
||||
);
|
||||
}
|
||||
AssocItemKind::MacCall(_) => {
|
||||
AssocItemKind::MacCall(_) | AssocItemKind::DelegationMac(..) => {
|
||||
panic!("unexpanded macro in resolve!")
|
||||
}
|
||||
}
|
||||
|
@ -3218,7 +3220,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
AssocItemKind::Fn(..) => (E0324, "method"),
|
||||
AssocItemKind::Type(..) => (E0325, "type"),
|
||||
AssocItemKind::Delegation(..) => (E0324, "method"),
|
||||
AssocItemKind::MacCall(..) => span_bug!(span, "unexpanded macro"),
|
||||
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
|
||||
span_bug!(span, "unexpanded macro")
|
||||
}
|
||||
};
|
||||
let trait_path = path_names_to_string(path);
|
||||
self.report_error(
|
||||
|
@ -4790,7 +4794,8 @@ impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> {
|
|||
| ItemKind::ExternCrate(..)
|
||||
| ItemKind::MacroDef(..)
|
||||
| ItemKind::GlobalAsm(..)
|
||||
| ItemKind::MacCall(..) => {}
|
||||
| ItemKind::MacCall(..)
|
||||
| ItemKind::DelegationMac(..) => {}
|
||||
ItemKind::Delegation(..) => {
|
||||
// Delegated functions have lifetimes, their count is not necessarily zero.
|
||||
// But skipping the delegation items here doesn't mean that the count will be considered zero,
|
||||
|
|
|
@ -2045,7 +2045,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
AssocSuggestion::MethodWithSelf { called }
|
||||
}
|
||||
ast::AssocItemKind::Delegation(..) => AssocSuggestion::AssocFn { called },
|
||||
ast::AssocItemKind::MacCall(_) => continue,
|
||||
ast::AssocItemKind::MacCall(_) | ast::AssocItemKind::DelegationMac(..) => {
|
||||
continue;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue