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.

@lcnr lcnr closed this Aug 26, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
@lcnr lcnr reopened this Aug 26, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
spellcheck files
building external tool typos from package [email protected]
finished building tool typos
npm WARN deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
npm ERR! code E403
npm ERR! 403 403 Forbidden - GET https://registry.npmjs.org/zod/-/zod-3.23.8.tgz
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2025-08-26T13_36_52_331Z-debug-0.log
tidy error: IO error: npm install returned exit code exit status: 1
npm install did not exit successfully
some tidy checks failed
Bootstrap failed while executing `test --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 /node/bin/npm --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1583:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1225:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:02:49
  local time: Tue Aug 26 13:37:11 UTC 2025
  network time: Tue, 26 Aug 2025 13:37:11 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@lcnr lcnr closed this Aug 26, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
@lcnr lcnr reopened this Aug 26, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
@@ -130,7 +130,7 @@ pub fn simplify_type<I: Interner>(
ty::RawPtr(_, mutbl) => Some(SimplifiedType::Ptr(mutbl)),
ty::Dynamic(trait_info, ..) => match trait_info.principal_def_id() {
Some(principal_def_id) if !cx.trait_is_auto(principal_def_id) => {
Some(SimplifiedType::Trait(principal_def_id))
Some(SimplifiedType::Trait(principal_def_id.into()))
Copy link
Contributor

Choose a reason for hiding this comment

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

SimplifiedType::Trait should just use a TraitId? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SimplifiedType takes a DefId as a parameter, not an Interner, therefore this is harder. And it isn't really useful either - it's used only for comparisons, so a DefId poses no harm.

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.

final nit, then r=me

View changes since this review

@lcnr
Copy link
Contributor

lcnr commented Aug 28, 2025

@bors delegate+

@bors
Copy link
Collaborator

bors commented Aug 28, 2025

✌️ @ChayimFriedman2, you can now approve this pull request!

If @lcnr told you to "r=me" after making some further change, please make that change, then do @bors r=@lcnr

@lcnr lcnr 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 Aug 28, 2025
@ChayimFriedman2
Copy link
Contributor Author

@bors r=@lcnr

@bors
Copy link
Collaborator

bors commented Aug 28, 2025

📌 Commit 38bd808 has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 28, 2025
@bors
Copy link
Collaborator

bors commented Aug 29, 2025

⌛ Testing commit 38bd808 with merge ef8d1d6...

@bors
Copy link
Collaborator

bors commented Aug 29, 2025

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing ef8d1d6 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 29, 2025
@bors bors merged commit ef8d1d6 into rust-lang:master Aug 29, 2025
19 of 31 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 29, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing f2824da (parent) -> ef8d1d6 (this PR)

Test differences

Show 6 test diffs

6 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard ef8d1d6f5bf59524a22943d9f64c002e5c883afd --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-linux: 8569.5s -> 6101.4s (-28.8%)
  2. aarch64-apple: 6758.7s -> 5484.7s (-18.9%)
  3. aarch64-msvc-1: 6666.7s -> 7582.3s (13.7%)
  4. dist-apple-various: 5040.5s -> 5556.3s (10.2%)
  5. dist-aarch64-apple: 6976.1s -> 6263.2s (-10.2%)
  6. aarch64-gnu-debug: 5011.9s -> 4540.7s (-9.4%)
  7. x86_64-gnu-llvm-20-1: 3539.5s -> 3208.5s (-9.3%)
  8. dist-x86_64-msvc-alt: 8883.3s -> 9476.0s (6.7%)
  9. i686-gnu-2: 5863.3s -> 6177.7s (5.4%)
  10. pr-check-1: 1762.8s -> 1675.5s (-5.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@ChayimFriedman2 ChayimFriedman2 deleted the solver-def-id branch August 29, 2025 03:49
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ef8d1d6): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 467.655s -> 465.841s (-0.39%)
Artifact size: 388.50 MiB -> 388.53 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants