Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypingMode #128

Open
1 of 3 tasks
lcnr opened this issue Nov 4, 2024 · 2 comments
Open
1 of 3 tasks

TypingMode #128

lcnr opened this issue Nov 4, 2024 · 2 comments
Labels
final-comment-period The FCP has started, most (if not all) team members are in agreement major-change A major change proposal T-types Add this label so rfcbot knows to poll the types team to-announce Announce this issue on triage meeting

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 4, 2024

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

@compiler-errors

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.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

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.

@lcnr lcnr added major-change A major change proposal T-types Add this label so rfcbot knows to poll the types team labels Nov 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented 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:

@rustbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/types

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Nov 4, 2024
@compiler-errors
Copy link
Member

@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.

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final-comment-period The FCP has started, most (if not all) team members are in agreement major-change A major change proposal T-types Add this label so rfcbot knows to poll the types team to-announce Announce this issue on triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants