Skip to content

delegation: refactor delegation list expansions so they have LocalExpnId#157657

Open
aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:delegation-macros-refactoring
Open

delegation: refactor delegation list expansions so they have LocalExpnId#157657
aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:delegation-macros-refactoring

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This PR refactors delegation's list and glob expansions such that they both use the same engine thus both having LocalExpnId which can be then used to properly emit diagnostic about unused target expression for list delegations.

Third part of #156798, tests will be adjusted after #157601 is merged.
Part of #118212.
r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 9, 2026
@aerooneqq aerooneqq changed the title delegation: refactor delegation list expansion so they have LocalExpnId delegation: refactor delegation list expansions so they have LocalExpnId Jun 9, 2026
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label Jun 9, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

We definitely don't need to delay expansion of list delegations by turning them into Invocations.

I'll think how to better assign some ids to list delegations so they can be used for the "common parent" check.
Any unique id will work for this purpose - ExpnId, NodeId, some new wrapper around u32, doesn't matter much.

);
Node::flatten_outputs(single_delegations.map(|item| {
let mut item = Node::from_item(item);
assign_id!(self, item.node_id_mut(), || item.walk_flat_map(self))

@petrochenkov petrochenkov Jun 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think let my_unique_id = self.cx.resolver.next_node_id() can be used as the unique id corresponding to the delegation list here.
That's unless NodeId ranges are checked for continuousness, or something like that.

Then list_delegation_parent_table.insert(item.node_id(), my_unique_id) here will be enough to keep all the information that we need for checking.
The table can be kept in Resolver, for example.

View changes since the review

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-fn_delegation `#![feature(fn_delegation)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants