Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

HIR ty lowering: Clean up & refactor the lowering of type-relative paths #140218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

fmease
Copy link
Member

@fmease fmease commented Apr 23, 2025

While rebasing #126651 I realized that HIR ty lowering could benefit from some spring cleaning now that it's been extended to handle RTN and mGCA paths.

More seriously, similar to my merged PR #118668 which unified the handling of all associated item constraints (assoc ty, const (ACE) & fn (RTN)), this PR (commit 695fcf5) partially1 deduplicates the resolution code for all type-relative paths (assoc ty, const (mGCA) & fn (RTN)).

Why? DRY'ing that part of the code means PR #126651 will automatically support RTN paths like Ty::AssocTy::assoc_fn(..) and it also implies shared diagnostic code and thus better diagnostics for RTN.


The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering QPath(Resolved) paths now have _resolved_ in their name and ones lowering QPath(TypeRelative) paths now have _type_relative_ in their name. This should make it stupidly obvious what their purpose is.


Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier.
r? compiler-errors

Footnotes

  1. Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary unreachable!()s or rendering the code otherwise illegible with flags and micro helper traits.

fmease added 5 commits April 23, 2025 20:49
Name them more consistently, descriptively and appropriately.
Move large error reporting methods into the dedicated error module to
make the happy paths in HIR ty lowering more legible.
@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 Apr 23, 2025
fmease added 2 commits April 23, 2025 22:07
IMPORTANT: This leads to a tiny diagnostic regression that will be fixed in the next commit!
Most notably, this preserves the `(..)` of ambiguous RTN paths.
@fmease fmease force-pushed the hirtylo-clean-up-path-low branch from 0100118 to 3d66b7b Compare April 23, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants