Skip to content

write! breakage in newest nightly #19155

Closed
@sfackler

Description

@sfackler
Member

Compiling sfackler/rust-postgres@1fa5941 comes up with this on the current nightly, but not yesterday's:

<std macros>:4:35: 4:50 error: type `&mut [_]` does not implement any method in scope named `write_fmt`
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
                                                 ^~~~~~~~~~~~~~~
<std macros>:4:35: 4:50 error: type `&mut [u8]` does not implement any method in scope named `write_fmt`
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
                                                 ^~~~~~~~~~~~~~~
<std macros>:4:35: 4:50 error: type `&mut [_]` does not implement any method in scope named `write_fmt`
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
                                                 ^~~~~~~~~~~~~~~
<std macros>:4:35: 4:50 error: type `&mut [u8]` does not implement any method in scope named `write_fmt`
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
                                                 ^~~~~~~~~~~~~~~
error: aborting due to 4 previous errors

It's also a bit weird/concerning that there are no expansion traces.

Activity

sfackler

sfackler commented on Nov 20, 2014

@sfackler
MemberAuthor

After building the --pretty expanded version, the write! calls in this function are the ones generating the errors: https://github.com/sfackler/rust-postgres/blob/1fa5941562739104d4a5fc39826f6ab7d27eb210/src/lib.rs#L518-L543

japaric

japaric commented on Nov 20, 2014

@japaric
Member

Just a hunch but this may be related to #19153 and #19142. Namely that write!(f) ICEs, and must be change to write!(&mut f), probably in your case f has type &mut [_]

alexcrichton

alexcrichton commented on Nov 20, 2014

@alexcrichton
Member

What may be happening here is that you're calling write!(vec, ...) when it should be write!(&mut vec, ..) which could mean that the compiler is deref'ing vec to a slice and not finding the write_fmt method.

sfackler

sfackler commented on Nov 20, 2014

@sfackler
MemberAuthor

Yep, that appears to have fixed it. Is the lack of expansion traces a known issue as well?

sfackler

sfackler commented on Nov 20, 2014

@sfackler
MemberAuthor

@alexcrichton This line in write! appears to be the culprit. Why does it exist?

let dst = &mut *$dst;
alexcrichton

alexcrichton commented on Nov 20, 2014

@alexcrichton
Member

The purpose of the write! macro was to take a &mut Writer object at the front as opposed just any plain old Writer. It emphasizes that the macro is not consuming the sink and explains why it must be declared mutable locally.

added a commit that references this issue on Feb 17, 2025

Merge pull request rust-lang#19155 from ShoyuVanilla/migrate-missing-…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexcrichton@sfackler@japaric

        Issue actions

          write! breakage in newest nightly · Issue #19155 · rust-lang/rust