Closed compiler-errors closed 1 month ago
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 second
It has been 10 days, so this is accepted.
Proposal
I would like to add unsafe binder types to the language as a T-lang experiment. Please read this document I wrote up for some motivation: https://hackmd.io/rAyz9MURTlazMdnffl2uSQ.
I probably don't need to go into detail about the desired semantics, but briefly: An unsafe binder type is written like
unsafe<'a, 'b> Ty<'a, 'b>
orunsafe<'r> &'r i32
, with any number of bound variables in theunsafe<...>
followed by a type which may reference those bound variables. Unsafe binder types are a distinct types from their wrapped type (Ty<'a, 'b>
); they have no subtyping relationship, no automatic coercion, and user-written impls cannot be implemented on them. They will, however, inherit the layout and act as much as possible like arepr(transparent)
wrapper around their wrapped type, and may have some built-in implementations (such asSized
). They can be interconverted using two unsafe macro-based operatorswrap_unsafe!(expr)
andunwrap_unsafe!(expr)
which areunsafe
to use.This MCP does not guarantee that they will remain in the compiler forever, or move towards any stabilization without an RFC first, and that RFC will certainly have T-types on it. At any point, we as a team can decide to remove them from the compiler just like any other nightly feature. This feature will remain marked incomplete, and it should not be used in the standard library without an RFC first, or at least further team consensus (and likely an FCP of its own, at the very least).
Mentors or Reviewers
I will implement unsafe binders and I will need no mentorship obviously.
@BoxyUwU has expressed interest in reviewing unsafe binder types, but I will also try to break out anything that's not totally types facing such as parsing, name resolution, and diagnostics to the general reviewer pool in T-compiler.
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.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.