Skip to content

refactor(mgca): Change DefKind::Const and DefKind::AssocConst to have a is_type_const flag#153050

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
JayanAXHF:refactor/change-is-type-const
Feb 28, 2026
Merged

refactor(mgca): Change DefKind::Const and DefKind::AssocConst to have a is_type_const flag#153050
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
JayanAXHF:refactor/change-is-type-const

Conversation

@JayanAXHF
Copy link
Member

@JayanAXHF JayanAXHF commented Feb 24, 2026

View all comments

Addresses #152940

  • Changed DefKind::Const and DefKind::AssocConst to have a is_type_const flag.
  • changed is_type_const query to check for this flag
  • removed is_rhs_type_const query

r? @BoxyUwU

@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

changes to the core type system

cc @lcnr

Some changes occurred in match checking

cc @Nadrieril

HIR ty lowering was modified

cc @fmease

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 24, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2026

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added T-clippy Relevant to the Clippy team. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Feb 24, 2026
@rust-log-analyzer

This comment has been minimized.

@JayanAXHF
Copy link
Member Author

@BoxyUwU I think this is mostly complete now

@JayanAXHF JayanAXHF removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. T-clippy Relevant to the Clippy team. labels Feb 25, 2026
Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this :3 it looks correct, just a few minor comments

View changes since this review

pub fn as_def_kind(&self) -> DefKind {
match self {
Self::Const { .. } => DefKind::AssocConst,
Self::Const { .. } => DefKind::AssocConst { is_type_const: false },
Copy link
Member

Choose a reason for hiding this comment

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

unconditionally using false for is_type_const seems wrong. AssocKind::Const might need to be extended to also track is_type_const

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm yeah, that seems fair

@rustbot rustbot added T-clippy Relevant to the Clippy team. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Feb 25, 2026
@fmease
Copy link
Member

fmease commented Feb 25, 2026

Since this change was largely motivated by a perf regression:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 25, 2026
refactor(mgca): Change `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 25, 2026
@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 25, 2026

Oh an additional thing we can do is remove the IsTypeConst flag from hir::TraitItemKind, that information should now be available via the DefKind's flag. That might also help with perf a bit (unsure)

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 25, 2026

☀️ Try build successful (CI)
Build commit: c01784d (c01784d8d0858fd818d2ea1182e0864c10601aec, parent: 3f9853562c73af38a5e6af8b0da1b2734a327e19)

@rust-timer

This comment has been minimized.

@JayanAXHF
Copy link
Member Author

Oh an additional thing we can do is remove the IsTypeConst flag from hir::TraitItemKind, that information should now be available via the DefKind's flag. That might also help with perf a bit (unsure)

I'd suggest having that in a different PR after this one lands (stacked PRs ftw). This is already a pretty widespread refactor, and IMO having that in a separate PR would be easier to work with

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c01784d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.0%, 1.3%] 2
Improvements ✅
(primary)
-0.5% [-0.8%, -0.2%] 17
Improvements ✅
(secondary)
-0.7% [-1.7%, -0.2%] 10
All ❌✅ (primary) -0.5% [-0.8%, -0.2%] 17

Max RSS (memory usage)

Results (primary -1.4%, secondary 0.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)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-1.4% [-2.2%, -0.6%] 2
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.1%] 1
All ❌✅ (primary) -1.4% [-2.2%, -0.6%] 2

Cycles

Results (primary -2.5%, secondary 7.7%)

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)
7.7% [7.7%, 7.7%] 1
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Binary size

Results (primary -0.5%, secondary -0.7%)

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

mean range count
Regressions ❌
(primary)
0.2% [0.1%, 0.2%] 4
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.6% [-1.2%, -0.0%] 60
Improvements ✅
(secondary)
-0.7% [-1.6%, -0.0%] 23
All ❌✅ (primary) -0.5% [-1.2%, 0.2%] 64

Bootstrap: 480.701s -> 486.306s (1.17%)
Artifact size: 397.77 MiB -> 397.77 MiB (0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 25, 2026
@JonathanBrouwer
Copy link
Contributor

@bors p=6
Scheduling this before the next rollup

@JayanAXHF
Copy link
Member Author

@BoxyUwU shouldn't we squash the commits (there's a lot of "ci appeasing" commits here)

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 28, 2026

oh uhh yeah that's probably a good idea hmm

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 28, 2026

@bors r-

@rust-bors rust-bors bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 28, 2026
@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 28, 2026

@bors squash

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

🚧 Squashing... this can take a few minutes.

…have a `is_type_const` flag

* refactor: add `is_type_const` flag to `DefKind::Const` and `AssocConst`
* refactor(cleanup) remove the `rhs_is_type_const` query
* style: fix formatting
* refactor: refactor stuff in librustdoc for new Const and AssocConst
* refactor: refactor clippy for the changes
* chore: formatting
* fix: fix test
* fix: fix suggestions
* Update context.rs

Co-authored-by: Boxy <rust@boxyuwu.dev>
* changed AssocKind::Const to store data about being a type const
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

🔨 10 commits were squashed into efc150e.

@rust-bors rust-bors bot force-pushed the refactor/change-is-type-const branch from b36cd1e to efc150e Compare February 28, 2026 17:28
@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 28, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

📌 Commit efc150e has been approved by BoxyUwU

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 28, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 28, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

☀️ Test successful - CI
Approved by: BoxyUwU
Duration: 3h 30m 33s
Pushing 38c0de8 to main...

@rust-bors rust-bors bot merged commit 38c0de8 into rust-lang:main Feb 28, 2026
12 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Feb 28, 2026
@github-actions
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 ba15679 (parent) -> 38c0de8 (this PR)

Test differences

Show 86 test diffs

86 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 38c0de8dcb14d42290042521be9958d37f3fa390 --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-apple-various: 2h 4m -> 1h 40m (-19.4%)
  2. aarch64-apple: 2h 51m -> 3h 23m (+18.5%)
  3. dist-aarch64-apple: 1h 59m -> 1h 44m (-12.5%)
  4. dist-x86_64-apple: 2h 9m -> 1h 54m (-11.7%)
  5. x86_64-gnu-miri: 1h 20m -> 1h 28m (+10.0%)
  6. armhf-gnu: 1h 31m -> 1h 22m (-9.9%)
  7. dist-aarch64-llvm-mingw: 1h 30m -> 1h 38m (+9.6%)
  8. x86_64-msvc-ext2: 1h 47m -> 1h 57m (+9.1%)
  9. dist-armv7-linux: 1h 35m -> 1h 27m (-8.4%)
  10. aarch64-msvc-2: 1h 44m -> 1h 52m (+7.9%)
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.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (38c0de8): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
-0.5% [-0.8%, -0.2%] 17
Improvements ✅
(secondary)
-0.7% [-1.7%, -0.0%] 10
All ❌✅ (primary) -0.5% [-0.8%, -0.2%] 17

Max RSS (memory usage)

Results (primary -2.3%, secondary 1.7%)

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)
1.7% [0.9%, 3.2%] 7
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Cycles

Results (secondary -3.8%)

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)
- - 0
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.5%, secondary -0.5%)

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

mean range count
Regressions ❌
(primary)
0.2% [0.1%, 0.2%] 4
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.5% [-1.2%, -0.0%] 67
Improvements ✅
(secondary)
-0.5% [-1.6%, -0.0%] 32
All ❌✅ (primary) -0.5% [-1.2%, 0.2%] 71

Bootstrap: 479.975s -> 481.431s (0.30%)
Artifact size: 395.63 MiB -> 397.60 MiB (0.50%)

@panstromek
Copy link
Contributor

perf triage:

Tiny regression in include-blob stress test, overall positive.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Mar 2, 2026
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 5, 2026
…nst, r=BoxyUwU

refactor(mgca): Change `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag



Addresses rust-lang#152940 

- Changed `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag.
- changed `is_type_const` query to check for this flag
- removed `is_rhs_type_const` query

r? @BoxyUwU
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants