mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 17:40:16 +00:00
explicitly track inherent const generic args kind 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: https://github.com/rust-lang/project-const-generics/issues/98 also very related to `feature(inherent_associated_types)`: https://github.com/rust-lang/rust/issues/8995 https://github.com/rust-lang/project-const-generics/issues/71 relevant PR that intentionally failed to implement inherent consts in the type system due to not tracking this: https://github.com/rust-lang/rust/pull/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 https://github.com/rust-lang/rust/issues/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](https://rust-lang.zulipchat.com/#narrow/channel/260443-project-const-generics/topic/implementing.20assoc.20consts.20as.20direct.20args/with/618953051) (is there an issue for this?) r? @BoxyUwU
This crate is currently developed in-tree together with the compiler.
Our goal is to start publishing rustc_public into crates.io.
Until then, users will use this as any other rustc crate, by installing
the rustup component rustc-dev, and declaring rustc-public as an external crate.
See the rustc_public "Getting Started" guide for more information.
Design
The rustc_public crate will follow a similar approach to proc-macro2. Its
implementation is split between two main crates:
rustc_public: Public crate, to be published on crates.io, which will contain the "stable" data structure as well as calls torustc_public_bridgeAPIs. The translation between public and internal constructs is also done in this crate.rustc_public_bridge: This crate implements the public APIs to the compiler. It is responsible for gathering all the information requested, and providing the data in its unstable internal form.
I.e.,
tools will depend on rustc_public crate,
which will invoke the compiler using APIs defined in rustc_public_bridge.
I.e.:
┌────────────────────────────┐ ┌───────────────────────────┐
│ External Tool │ │ Rust Compiler │
│ ┌────────────┐ │ │ ┌────────┐ │
│ │ │ │ │ │ │ │
│ │rustc_public│ │ │ │rustc │ │
│ │ │ ├──────────►| │public │ │
│ │ │ │◄──────────┤ │bridge │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ └────────────┘ │ │ └────────┘ │
└────────────────────────────┘ └───────────────────────────┘
More details can be found here: https://hackmd.io/XhnYHKKuR6-LChhobvlT-g?view