Rollup merge of #124135 - petrochenkov:deleglob, r=fmease

delegation: Implement glob delegation

Support delegating to all trait methods in one go.
Overriding globs with explicit definitions is also supported.

The implementation is generally based on the design from https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2020869823, but unlike with list delegation in https://github.com/rust-lang/rust/pull/123413 we cannot expand glob delegation eagerly.
We have to enqueue it into the queue of unexpanded macros (most other macros are processed this way too), and then a glob delegation waits in that queue until its trait path is resolved, and enough code expands to generate the identifier list produced from the glob.

Glob delegation is only allowed in impls, and can only point to traits.
Supporting it in other places gives very little practical benefit, but significantly raises the implementation complexity.

Part of https://github.com/rust-lang/rust/issues/118212.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-06-19 01:51:36 +01:00 committed by GitHub
commit f8ce1cfbf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 878 additions and 123 deletions

View file

@ -2699,12 +2699,13 @@ pub(crate) struct SingleColonImportPath {
#[derive(Diagnostic)]
#[diag(parse_bad_item_kind)]
#[help]
pub(crate) struct BadItemKind {
#[primary_span]
pub span: Span,
pub descr: &'static str,
pub ctx: &'static str,
#[help]
pub help: Option<()>,
}
#[derive(Diagnostic)]