-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Proposal
Some of our typing rules depend on the "mode" we're in. Most notably, whether we should force "unknowable" trait goals to be ambiguous during coherence and whether to define or reveal opaque types.
This is currently handled via ParamEnv::reveal
, InferCtxt::intercrate
, and InferCtxt::defining_opaque_types
and never changes during the lifetime of a InferCtxt
. Going forward we intend to add yet another mode to the type system: only reveal opaques defined by some body, but without being able to define them. This is necessary during places such as opaque type well-formedness checking. We currently
- either treat them as opaque, and get an inconsistent state as HIR typeck only succeeded because it was able to observe the hidden type,
- or we allow redefining all the opaques from the body, this causes ambiguity errors in case we end up using an opaque without actually reconstraining it.
This is the reason why we've needed rust-lang/rust#124598 for bootstrap with the new solver. We intend to fix this issue by adding an additional typing mode which allows revealing some opaque types without allowing any new definitions.
We currently also frequently accidentally forget parts of our typing mode, e.g. when calling nested queries which only take a ParamEnvAnd
, dropping both the defining_opaque_types
and intercrate
.
I intend to change this by moving all of this information into a new typing_mode
field on the InferCtxt
and then change queries currently taking a ParamEnv
to instead take a struct TypingEnv<'tcx> { typing_mode: TypingMode<'tcx>, param_env: ty::ParamEnv<'tcx> }
.
I've started to already implement this in rust-lang/rust#131856 and am continuing this work in rust-lang/rust#132460. Given that this is ending up being quite involved and a nightmare to revert, I want to make sure the full Types Team is aware of this effort.
See https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/.60TypingMode.60 for more details, might extend this MCP tomorrow, have to leave for today 😅
Mentors or Reviewers
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.A types team member or contributor who is knowledgeable in the area can second by writing
@rustbot second
.- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
-C flag
, then full team check-off is required. - Types team members can initiate a check-off via
@rfcbot fcp merge
on either the MCP or the PR.
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Activity
rustbot commentedon Nov 4, 2024
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:
Concerns can be lifted with:
See documentation at https://forge.rust-lang.org
cc @rust-lang/types
compiler-errors commentedon Nov 4, 2024
@rustbot second
Very very in favor of this work, and have discussed at length the approach and final state of the type system after this change. I'm volunteering to review this work.
TypingMode
throughout the compiler instead ofParamEnv
rust-lang/rust#132460Auto merge of rust-lang#132460 - lcnr:questionable-uwu, r=compiler-er…
Auto merge of #132460 - lcnr:questionable-uwu, r=compiler-errors
Auto merge of #132460 - lcnr:questionable-uwu, r=compiler-errors
Auto merge of #132460 - lcnr:questionable-uwu, r=compiler-errors
lcnr commentedon Jan 28, 2025
closed as accepted
1 remaining item