-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow parenthesis around inferred array lengths #139641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
#[rustfmt::skip] | ||
let b: [u8; (_)] = [1; (((((_)))))]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonderful!
@bors r+ rollup |
This comment has been minimized.
This comment has been minimized.
@bors r- pls bless 🙏 |
whatd I fuck up here :thonk: |
oh the rustfmt skip bumped line numbers |
95f90f3
to
8f00b1f
Compare
@bors r+ rollup |
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
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
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