Skip to content

Allow phased initializing structs#152774

Draft
dingxiangfei2009 wants to merge 1 commit intorust-lang:mainfrom
dingxiangfei2009:partial-init
Draft

Allow phased initializing structs#152774
dingxiangfei2009 wants to merge 1 commit intorust-lang:mainfrom
dingxiangfei2009:partial-init

Conversation

@dingxiangfei2009
Copy link
Contributor

This PR introduces an unstable feature partial_init_nodrop_types. This work corresponds to the new action item in rust-lang/rust-project-goals#548.

Action Items

  • What should we do with non_exhaustive?

Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 17, 2026
@dingxiangfei2009
Copy link
Contributor Author

dingxiangfei2009 commented Feb 17, 2026

cc @BennoLossin @nxsaken FYI.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[group]Runner Image Provisioner
Hosted Compute Agent
Version: 20260123.484
Commit: 6bd6555ca37d84114959e1c76d2c01448ff61c5d
Build Date: 2026-01-23T19:41:17Z
Worker ID: {796d113c-91b6-401c-a511-3bf8d6f3122a}
Azure Region: southcentralus
##[endgroup]
##[group]VM Image
- OS: Linux (arm64)
- Source: Partner
- Name: Ubuntu 24.04 by Arm Limited
---
REPOSITORY                                   TAG       IMAGE ID       CREATED       SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    afc745c7535d   3 weeks ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
fmt: checked 6701 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [features]: /checkout/compiler/rustc_feature/src/unstable.rs:615: no tracking issue for feature partial_init_nodrop_types
tidy [features]: FAIL
tidy: The following check failed: features
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=yarn` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1365:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:00:51
  local time: Tue Feb 17 21:50:05 UTC 2026
  network time: Tue, 17 Feb 2026 21:50:05 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Copy link
Contributor

@BennoLossin BennoLossin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool to see that it's less than 200 lines changed!

Just two small things that I noticed. I can't speak on any of the actual modifications :)

View changes since this review

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a feature gate error.

/// Allows using `#[optimize(X)]`.
(unstable, optimize_attribute, "1.34.0", Some(54882)),
/// Allows partial initialisation of no-Drop `struct`s and tuples.
(unstable, partial_init_nodrop_types, "CURRENT_RUSTC_VERSION", None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(unstable, partial_init_nodrop_types, "CURRENT_RUSTC_VERSION", None),
(unstable, partial_init_locals, "CURRENT_RUSTC_VERSION", None),

I'd call out that this is specifically about local variables. I don't think we need the "nodrop_types" postfix. I'd expect that once we have the explicit_drop_arming feature we just allow combining the two features.

@BennoLossin
Copy link
Contributor

Regarding non-exhaustive: I think it's pretty simple, the reference already covers all of this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants