Skip to content

Some ast lowering partial-res cleanups#158948

Open
oli-obk wants to merge 4 commits into
rust-lang:mainfrom
oli-obk:get_full_res
Open

Some ast lowering partial-res cleanups#158948
oli-obk wants to merge 4 commits into
rust-lang:mainfrom
oli-obk:get_full_res

Conversation

@oli-obk

@oli-obk oli-obk commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Everyone (including me) pretty much randomly uses whatever works between get_partial_res, expect_partial_res and expect_full_res. I went through all use sites and picked the strictest one, and added some helpers along the line. Also added docs guiding ppl towards the stricter ones

r? @cjgillot or @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 Jul 8, 2026
@petrochenkov petrochenkov self-assigned this Jul 8, 2026
}

fn get_full_res(&self, id: NodeId) -> Option<Res<NodeId>> {
self.get_partial_res(id)?.full_res()

@petrochenkov petrochenkov Jul 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.

The behavior here is different from expect_full_res.

get_partial_res can return None in two cases:

  • id does not refer to any kind of path, we'd ideally panic in this case, this should not happen.
  • id refers to some unsuccessfully resolved path, we do not always put Res::Err for such paths into the table, unfortunately.
    That's why fn expect_full_res defaults to Res::Err if it doesn't find anything in the table. That is better than what this function does, because Res::Err is a full resolution. But it is also fishy because it creates Res::Err without ErrorGuaranteed, ideally we'd run delayed_bug if that fallback happens.

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 Jul 9, 2026
@rust-bors

rust-bors Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159057) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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