Skip to content

Conversation

SUPERCILEX
Copy link
Contributor

Recently discovered this was a thing, pretty cool!

error[E0277]: rustix does not accept `String` buffers
   --> src/buffer.rs:436:34
    |
436 |         let nread = read(&input, String::new()).unwrap();
    |                     ----         ^^^^^^^^^^^^^ Unsupported buffer type
    |                     |
    |                     required by a bound introduced by this call
    |
    = help: the trait `Buffer<u8>` is not implemented for `String`
    = note: only (potentially uninitialized) byte arrays, slices, and Vecs are supported
    = note: please read the docs: https://docs.rs/rustix/latest/rustix/buffer/trait.Buffer.html
    = help: the following other types implement trait `Buffer<T>`:
              &mut [MaybeUninit<T>; N]
              &mut [MaybeUninit<T>]
              &mut [T; N]
              &mut [T]
              &mut std::vec::Vec<MaybeUninit<T>>
              &mut std::vec::Vec<T>
              SpareCapacity<'a, T>
note: required by a bound in `read_write::read`
   --> src/io/read_write.rs:39:28
    |
39  | pub fn read<Fd: AsFd, Buf: Buffer<u8>>(fd: Fd, mut buf: Buf) -> io::Result<Buf::Output> {
    |                            ^^^^^^^^^^ required by this bound in `read`

error[E0277]: the trait bound `String: buffer::private::Sealed<u8>` is not satisfied
   --> src/buffer.rs:436:21
    |
436 |         let nread = read(&input, String::new()).unwrap();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `buffer::private::Sealed<u8>` is not implemented for `String`
    |
    = help: the following other types implement trait `buffer::private::Sealed<T>`:
              &'a mut [MaybeUninit<T>; N]
              &'a mut [MaybeUninit<T>]
              &'a mut std::vec::Vec<MaybeUninit<T>>
              &mut [T; N]
              &mut [T]
              &mut std::vec::Vec<T>
              SpareCapacity<'a, T>

For more information about this error, try `rustc --explain E0277`.
error: could not compile `rustix` (lib test) due to 2 previous errors

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@sunfishcode
Copy link
Member

That's a fun feature! We'll need to make it conditional on the compiler though to support our MSRV.

@SUPERCILEX
Copy link
Contributor Author

Whoops, didn't notice the CI failure. I'll take a look tomorrow.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX
Copy link
Contributor Author

Looks like the freebsd failure is unrelated.

@sunfishcode sunfishcode merged commit 1b40a77 into bytecodealliance:main Jul 14, 2025
49 of 51 checks passed
@sunfishcode
Copy link
Member

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants