Skip to content

Eagerly resolve delegations in late resolution#157053

Open
oli-obk wants to merge 1 commit into
rust-lang:mainfrom
oli-obk:delegation-resolution-late
Open

Eagerly resolve delegations in late resolution#157053
oli-obk wants to merge 1 commit into
rust-lang:mainfrom
oli-obk:delegation-resolution-late

Conversation

@oli-obk
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk commented May 28, 2026

This is necessary for allowing the partial_res_map to be split by owners. The current logic follows NodeId -> DefId -> NodeId mappings, but the resulting NodeId is then not under the same owner, so we can't look it up in the current owner table. After this PR everything is just a DefId -> DefId mapping, which always works fine.

cc @aerooneqq

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 May 28, 2026
// NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution,
// for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914
pub resolution_node: ast::NodeId,
pub resolution_node: DefId,
Copy link
Copy Markdown
Contributor

@aerooneqq aerooneqq May 28, 2026

Choose a reason for hiding this comment

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

Nit: maybe resolution_id or res_def_id?

View changes since the review

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'm still not sure what would be a good name for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we just fully resolve in late resolution?

self.r.tcx.dcx().span_delayed_bug(
delegation.path.span,
format!(
"LoweringContext: couldn't resolve node {:?} in delegation item",
Copy link
Copy Markdown
Contributor

@aerooneqq aerooneqq May 28, 2026

Choose a reason for hiding this comment

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

Suggested change
"LoweringContext: couldn't resolve node {:?} in delegation item",
"LateResolutionVisitor: couldn't resolve node {:?} in delegation item",

View changes since the review

self.r.tcx.dcx().span_delayed_bug(
delegation.path.span,
format!(
"LoweringContext: couldn't resolve node {:?} in delegation item",
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov May 28, 2026

Choose a reason for hiding this comment

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

Suggested change
"LoweringContext: couldn't resolve node {:?} in delegation item",
"LoweringContext: couldn't resolve node {resolution_node:?} in delegation item"

View changes since the review

Comment thread compiler/rustc_middle/src/ty/mod.rs
#[derive(Debug)]
pub struct DelegationInfo {
// NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution,
// for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov May 28, 2026

Choose a reason for hiding this comment

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

This comment is still mostly relevant.

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 May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants