Skip to content

Conversation

ChayimFriedman2
Copy link
Contributor

The compiler just puts DefId in there, but rust-analyzer uses different types for each kind of item.

See the Zulip discussion. In short, it will be a tremendous help to r-a to use specific associated types, while for the solver and the compiler it's a small change. So I ported TraitId, as a proof of concept and it's also likely the most impactful.

r? types

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 14, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Aug 15, 2025

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

@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2025

This PR was rebased onto a different master commit! Check out the changes with our range-diff.

@bors
Copy link
Collaborator

bors commented Aug 20, 2025

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

@lcnr
Copy link
Contributor

lcnr commented Aug 20, 2025

sorry for not replying to this PR up until now 😅

I am somewhat torn about this and avoided forming a final opinion up until now. I think this is generally useful and I am in favor of this change.

I do feel like ideally this should not limited to the solver and we actually have some struct AssocItemDefId { inner: DefId } outside of the solver as well. We already have struct BodyId for the HIR.

I feel like the main issue is to actually use these IDs everywhere 😅 I don't know what exactly I want and changing stuff here results in a lot of churn/merge conflicts

so yeah, want to take some time to properly sort out my thoughts here, am generally in favor, but don't have the time to do that rn

@ChayimFriedman2
Copy link
Contributor Author

@lcnr That's exactly why I opened this PR: so you can see (and I can be sure) that it's not, in fact, a big change.

Doing it throughout the compiler might be interesting but it definitely will be a big change, and I don't want to do that. I also didn't create this PR to have better type safety within the solver (although this is nice), but to help rust-analyzer.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

Can you rename TraitSolverLangItem to SolverLangItem?

TraitSolverTrait is hard to read.

Also, rename uses of trait_def_id to just trait_id maybe?

then r=me. While I'd like to maybe extend that to rustc, I agree that it doesn't make the trait solver harder to read and it's useful for r-a

View changes since this review

@rustbot
Copy link
Collaborator

rustbot commented Aug 24, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ChayimFriedman2
Copy link
Contributor Author

@lcnr Did what you requested, except renaming all trait_def_id to trait_id because I fear this will cause a lot of conflicts, and trait_def_id is not incorrect either.

The compiler just puts `DefId` in there, but rust-analyzer uses different types for each kind of item.
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

warning: `test_docs` (lib doc) generated 4 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.57s
   Generated /checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/test_docs/index.html
npm ERR! code ECONNRESET
npm ERR! network aborted
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2025-08-25T14_59_48_442Z-debug-0.log
npm install did not exit successfully

thread 'main' panicked at src/tools/rustdoc-gui-test/src/main.rs:69:10:
unable to install browser-ui-test: Custom { kind: Other, error: "npm install returned exit code exit status: 1" }
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panicking.rs:75:14

@ChayimFriedman2
Copy link
Contributor Author

That must be a spurious failure.

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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants