Skip to content

explicitly track inherent const generic args kind - #161929

Open
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:explicitly-track-inherent-args
Open

explicitly track inherent const generic args kind#161929
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:explicitly-track-inherent-args

Conversation

@khyperia

@khyperia khyperia commented Aug 28, 2026

Copy link
Copy Markdown
Member

in doing so, and as an exercise of this new code, implement regular (non-type-const) inherent consts in the type system under feature(generic_const_args)

see the new big doc comment in compiler/rustc_type_ir/src/const_kind.rs if you dunno what the heck I'm on about with "self args" vs "impl args" ✨

on a small note, the FIXME on alias_term_kind_from_def_id becomes even more relevant with this PR, ty::AliasConstInherentArgsKind is kinda gross tbh. explicitly not refactoring that in this PR though, to keep scope/the diff manageable.

also, check_args_compatible is very spooky scary in that if you have a ty::Alias, you ought to use check_term_args_compatible, but nothing's stopping you from calling check_args_compatible with the term's DefId. I was unable to think up a clever API that would prevent this misuse.

and finally, I think some of these match statements could theoretically bug! on one form or the other of InherentSelf/InherentImpl, but for now I'm intentionally being a bit conservative here, we can tighten up later.


relevant tracking issue: rust-lang/project-const-generics#98

also very related to feature(inherent_associated_types): #8995 rust-lang/project-const-generics#71

relevant PR that intentionally failed to implement inherent consts in the type system due to not tracking this: #155341

implementing support for a trait with a regular const being refined with an impl that has a directly represented RHS is extremely annoying and difficult without this, the lack of support of which causes #161264 (was working on adding support when I got sidetracked with this PR), see also this zulip thread: #project-const-generics > implementing assoc consts as direct args (is there an issue for this?)

r? @BoxyUwU

@rustbot

rustbot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_sanitizers

cc @rcvalle

changes to the core type system

cc @lcnr

Some changes occurred in match checking

cc @Nadrieril

This PR changes rustc_public

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

Some changes occurred in rustc_ty_utils::consts.rs

cc @BoxyUwU

HIR ty lowering was modified

cc @fmease

changes to the core type system

cc @lcnr

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 28, 2026
@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 28, 2026
@rust-log-analyzer

Copy link
Copy Markdown
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)
checking C++ file formatting
spellchecking files
building external tool typos from package typos-cli@1.38.1
finished building tool typos
error: `descrption` should be `description`
    ╭▸ compiler/rustc_type_ir/src/const_kind.rs:140:85
    │
140 │     /// An associated const in an inherent `impl`. See [`Self::InherentSelf`] for a descrption on
    ╰╴                                                                                    ━━━━━━━━━━
error: `descrption` should be `description`
   ╭▸ compiler/rustc_type_ir/src/term_kind.rs:69:90
   │
69 │     /// An associated const in an inherent `impl`. See [`ConstKind::InherentSelf`] for a descrption on
   ╰╴                                                                                         ━━━━━━━━━━
error: `descrption` should be `description`
   ╭▸ compiler/rustc_type_ir/src/term_kind.rs:72:90
   │
72 │     /// An associated const in an inherent `impl`. See [`ConstKind::InherentSelf`] for a descrption on
   ╰╴                                                                                         ━━━━━━━━━━
rerun with `--bless` to fix typos: `./x.py test tidy --extra-checks=spellcheck --bless`
tidy [extra_checks:spellcheck]: checks with external tool 'typos' failed
tidy [extra_checks:spellcheck]: FAIL
yarn install v1.22.22
warning package.json: No license field
warning ../../package.json: License should be a valid SPDX license expression
warning No license field
[1/4] Resolving packages...
---
Running eslint on rustdoc JS files
info: ES-Check: checking 7 files...
info: ✓ ES-Check passed! All files are ES10 compatible.
typechecking javascript files
tidy: The following check failed: extra_checks:spellcheck
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --ci=true --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1627:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1748:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1666
Build completed unsuccessfully in 0:02:00
  local time: Fri Aug 28 13:44:55 UTC 2026

@khyperia

Copy link
Copy Markdown
Member Author

it is mildly annoying that ./x test tidy does not spellcheck, instead, tidy fails on CI the moment I push :c

(will fix later in a batch update with any PR feedback)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-exploit-mitigations Project group: Exploit mitigations 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. 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.

4 participants