Skip to content

audio: Replace inferred array lengths with BUFFER_SIZE#38564

Closed
atomkernel0 wants to merge 1 commit intozed-industries:mainfrom
atomkernel0:fix/stable-array-length
Closed

audio: Replace inferred array lengths with BUFFER_SIZE#38564
atomkernel0 wants to merge 1 commit intozed-industries:mainfrom
atomkernel0:fix/stable-array-length

Conversation

@atomkernel0
Copy link
Copy Markdown

Summary

Fix stable Rust builds (E0658) by replacing _-inferred array lengths with explicit BUFFER_SIZE in crates/audio/src/audio.rs. No behavior changes.

Context

Stable Rust doesn’t allow _ as an array length in type position (E0658; see rust-lang/rust#85077), causing two compile errors in audio.rs.

I got these two compilation errors :

error[E0658]: using `_` for array lengths is unstable
   --> crates/audio/src/audio.rs:131:40
    |
131 |                     let mut buf: [i16; _] = buffer.map(|s| s.to_sample());
    |                                        ^
    |
    = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information

error[E0658]: using `_` for array lengths is unstable
   --> crates/audio/src/audio.rs:172:43
    |
172 |                 let mut int_buffer: [i16; _] = buffer.map(|s| s.to_sample());
    |                                           ^
    |
    = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `audio` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

BUFFER_SIZE matches the surrounding const generics:

  • inspect_buffer::<BUFFER_SIZE, _>(...)
  • process_buffer::<BUFFER_SIZE, _>(...)

Testing

Built successfully on stable:

  • rustc 1.88.0 (6b00bc388 2025-06-23), LLVM 19.1.4
  • target: x86_64-unknown-linux-gnu (Void Linux)

Impact

Build-only fix; no functional changes.

Release notes

Fix: Restore stable Rust build by replacing _ array lengths with BUFFER_SIZE in crates/audio/src/audio.rs (E0658).

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Sep 20, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @atomkernel0 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@maxdeviant maxdeviant changed the title fix(audio): replace _ array lengths with BUFFER_SIZE (fixes E0658 on stable) audio: Replace inferred array lengths with BUFFER_SIZE Sep 20, 2025
@atomkernel0
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Sep 20, 2025
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Sep 20, 2025

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant
Copy link
Copy Markdown
Member

maxdeviant commented Sep 20, 2025

We already build on Rust stable, so this seems like something specific to your environment.

Built successfully on stable:

  • rustc 1.88.0 (6b00bc388 2025-06-23), LLVM 19.1.4

I see you're building with Rust 1.88, but we have Rust 1.89 in our rust-toolchain.toml:

channel = "1.89"

What happens if you build on Rust 1.89?

Edit: It looks like feature(generic_arg_infer) was stabilized in Rust 1.89: https://releases.rs/docs/1.89.0/:

@maxdeviant maxdeviant self-assigned this Sep 20, 2025
@maxdeviant
Copy link
Copy Markdown
Member

Going to close this, as the feature has been stabilized in Rust 1.89, and that is the minimum version of Rust we support building Zed with.

@maxdeviant maxdeviant closed this Sep 20, 2025
…able Rust

On stable Rust, using \`_\` to infer array lengths in type position is not stabilized (E0658). This change replaces the inferred lengths with explicit BUFFER_SIZE in audio.rs, matching the const generic used by the buffer processing. No functional changes; fixes build on stable. Refs: rust-lang/rust#85077.
@atomkernel0 atomkernel0 deleted the fix/stable-array-length branch September 20, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants