Description
Proposal
Implement compiler support for alignment and size niches, as outlined in RFC 3204. This does not propose adding the RFC's WellFormed<T>
type to std
; only &T
and &mut T
are eligible for now.
The rough plan is:
- Add a new
naive_layout_of
query (this was namedmin_layout_of
in the RFC) that can be used to (under)estimate the size/align of a type behind an indirection without causing unwanted query cycles; - Fix the various places in the compiler assuming references and pointers only ever have null niches:
- the niching logic in
rustc_abi
(to maintain the null-pointer optimization guarantee in the presence of non-null niches); - scalar checks in CTFE;
- some checks in the
improper_ctypes
lint; SizeSkeleton
logic for transmute checks;Ty::ty_and_layout_pointee_info_at
;- probably others I missed...
- the niching logic in
- Enable niches for references (maybe behind some unstable
-Z
flag), using the size and alignment estimations provided bynaive_layout_of
.
Mentors or Reviewers
I already have a draft implementation of the naive_layout_of
query (which I'll make into a PR once it's cleaned up), and got some good advice from @scottmcm (and others) on the Rust Discord server; but this is my first contribution to the rustc
codebase and mentoring help for the trickier changes would be greatly appreciated.
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler 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. - Compiler team members can initiate a check-off via
@rfcbot fcp merge
on either the MCP or the PR.
- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
- 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.