Emit a pre-expansion feature gate warning for box'ed struct field patterns#154475
Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom Mar 28, 2026
Merged
Conversation
Collaborator
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
box'ed struct field patterns
fmease
commented
Mar 27, 2026
tests/ui/auto-traits/pre-cfg.rs
Outdated
Member
Author
There was a problem hiding this comment.
Replaced by tests/ui/feature-gates/soft-feature-gate-auto_traits.rs.
fmease
commented
Mar 27, 2026
Member
Author
There was a problem hiding this comment.
Replaced by tests/ui/feature-gates/soft-feature-gate-try_blocks.rs.
This comment has been minimized.
This comment has been minimized.
334925d to
3a5aa21
Compare
This comment has been minimized.
This comment has been minimized.
3a5aa21 to
a7ad9ac
Compare
Member
|
r? me @bors r+ rollup |
Contributor
15 tasks
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 28, 2026
Rollup of 11 pull requests Successful merges: - #152880 (Tweak incorrect assoc item note) - #153526 (Fix LegacyKeyValueFormat report from docker build: i686) - #153613 (interpreter error reporting: remove arguments that are always the same) - #154029 (Replace `truncate(0)` with `clear()`) - #154125 (Inline and remove `DepGraphData::try_mark_parent_green`.) - #154185 (Prevent no_threads RwLock's write() impl from setting mode to -1 when it is locked for reading) - #154394 (Normalize rustc path prefix when testing `-Z track-diagnostics`) - #154450 (Use the normal arg-parsing machinery for `-Zassert-incr-state`) - #154475 (Emit a pre-expansion feature gate warning for `box`'ed struct field patterns) - #154500 (EnumSizeOpt: use Allocation::write_scalar instead of manual endianess logic) - #154502 (interpret: ensure that untupled arguments are actually tuples)
rust-timer
added a commit
that referenced
this pull request
Mar 28, 2026
Rollup merge of #154475 - fmease:soft-gate-box-struct-field-pat, r=Kivooeo Emit a pre-expansion feature gate warning for `box`'ed struct field patterns While the following code triggers a feature gate *warning*: ```rs fn f() { #[cfg(false)] let box x; //~ WARN box pattern syntax is experimental } ``` the code below does not (on stable & main): ```rs fn f() { #[cfg(false)] let Struct { box x }; } ``` This is an oversight as both are part of the unstable feature `box_patterns` (that isn't properly gated pre expansion for historical reasons). Of course, both forms lead to a feature gate error *post expansion*. This is a bug fix and doesn't need any input from T-compiler or T-lang. For context, emitting warnings in these cases is legitimized by [MCP 535](https://github.com/rust-lang/compiler-team/issues/535)[^1]. Part of #154045. [^1]: In case you're wondering why the MCP talks about a *lint* even though the feature gate warnings as seen today don't reference any lint by name, read #154045 (comment).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While the following code triggers a feature gate warning:
the code below does not (on stable & main):
This is an oversight as both are part of the unstable feature
box_patterns(that isn't properly gated pre expansion for historical reasons). Of course, both forms lead to a feature gate error post expansion.This is a bug fix and doesn't need any input from T-compiler or T-lang. For context, emitting warnings in these cases is legitimized by MCP 5351.
Part of #154045.
Footnotes
In case you're wondering why the MCP talks about a lint even though the feature gate warnings as seen today don't reference any lint by name, read https://github.com/rust-lang/rust/issues/154045#issuecomment-4144034419. ↩