Skip to content

write! breakage in newest nightly #19155

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

Closed
sfackler opened this issue Nov 20, 2014 · 6 comments
Closed

write! breakage in newest nightly #19155

sfackler opened this issue Nov 20, 2014 · 6 comments

Comments

@sfackler
Copy link
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.

@sfackler
Copy link
Member Author

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
Copy link
Member

japaric commented Nov 20, 2014

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
Copy link
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
Copy link
Member Author

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

@sfackler
Copy link
Member Author

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

let dst = &mut *$dst;

@alexcrichton
Copy link
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.

@sfackler sfackler closed this as completed Dec 8, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Feb 17, 2025
…match-arms

internal: Remove mutable syntax tree usages from `add_missing_match_arms` assist
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

No branches or pull requests

3 participants