Allow parenthesis around inferred array lengths#139641
Merged
bors merged 1 commit intorust-lang:masterfrom Apr 11, 2025
Merged
Conversation
BoxyUwU
commented
Apr 10, 2025
Comment on lines
+16
to
+17
| #[rustfmt::skip] | ||
| let b: [u8; (_)] = [1; (((((_)))))]; |
Member
Author
There was a problem hiding this comment.
rustfmt wipes nested parenthesis in expressions so in order to make sure people dont accidentally format away part of the test..
d9617ab to
95f90f3
Compare
Contributor
|
@bors r+ rollup |
Collaborator
This comment has been minimized.
This comment has been minimized.
Contributor
|
@bors r- pls bless 🙏 |
Member
Author
|
whatd I fuck up here :thonk: |
Member
Author
|
oh the rustfmt skip bumped line numbers |
95f90f3 to
8f00b1f
Compare
Contributor
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 11, 2025
Rollup of 12 pull requests Successful merges: - rust-lang#137447 (add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`) - rust-lang#138182 (rustc_target: update x86_win64 to match the documented calling convention for f128) - rust-lang#138682 (Allow drivers to supply a list of extra symbols to intern) - rust-lang#138904 (Test linking and running `no_std` binaries) - rust-lang#138998 (Don't suggest the use of `impl Trait` in closure parameter) - rust-lang#139447 (doc changes: debug assertions -> overflow checks) - rust-lang#139469 (Introduce a `//@ needs-crate-type` compiletest directive) - rust-lang#139564 (Deeply normalize obligations in `BestObligation` folder) - rust-lang#139574 (bootstrap: improve `channel` handling) - rust-lang#139600 (Update `compiler-builtins` to 0.1.153) - rust-lang#139641 (Allow parenthesis around inferred array lengths) - rust-lang#139654 (Improve `AssocItem::descr`.) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 11, 2025
Rollup merge of rust-lang#139641 - BoxyUwU:allow_parend_array_len_infer, r=compiler-errors Allow parenthesis around inferred array lengths In rust-lang#135272 it was noticed that we weren't handling `Vec<(((((_)))))>` correctly under the new desugaring for `generic_arg_infer`, this had to be fixed in order to not regress stable code for types that should continue working. This has the side effect of *also* allowing the following to work: ```rust #![feature(generic_arg_infer)] struct Bar<const N: usize>; fn main() { let a: Bar<((_))> = Bar::<10>; } ``` However I did not make the same change for array lengths resulting in the following not compiling: ```rust #![feature(generic_arg_infer)] fn main() { let a: [u8; (((_)))] = [2; 2]; let a: [u8; 2] = [2; (((((_)))))]; } ``` This is rather inconsistent as parenthesis around `_` *are* supported for const args to non-arrays, and type args. This PR fixes this allowing the above example to compile. No stable impact. r? compiler-errors
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.
In #135272 it was noticed that we weren't handling
Vec<(((((_)))))>correctly under the new desugaring forgeneric_arg_infer, this had to be fixed in order to not regress stable code for types that should continue working. This has the side effect of also allowing the following to work:However I did not make the same change for array lengths resulting in the following not compiling:
This is rather inconsistent as parenthesis around
_are supported for const args to non-arrays, and type args. This PR fixes this allowing the above example to compile. No stable impact.r? compiler-errors