-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code:
play.rust-lang.org: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=320bd0fa60b7736e04ac82df5a77c760
It isn't able to run in the online thing, but the rest of the code is at https://github.com/C34A/vm1/blob/files/src/main.rs
let mut output_file = fs::File::create(newfilename).expect("failed to create output file");
output_file.write_all(&binary).expect("failed to write to output file!");The current output is:
error[E0599]: no method named `write_all` found for struct `File` in the current scope
--> src/main.rs:76:41
|
76 | ... output_file.write_all(&binary).expect("failed to write to output file!");
| ^^^^^^^^^ method not found in `File`
|
::: /home/theo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:1438:8
|
1438 | fn write_all(&mut self, mut buf: &[u8]) -> Result<()> {
| ---------
| |
| the method is available for `Box<File>` here
| the method is available for `Box<&mut File>` here
| the method is available for `Box<&File>` here
|
help: consider wrapping the receiver expression with the appropriate type
|
76 | Box::new(output_file).write_all(&binary).expect("failed to write to output file!");
| ^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
76 | Box::new(&mut output_file).write_all(&binary).expect("failed to write to output file!");
| ^^^^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
76 | Box::new(&output_file).write_all(&binary).expect("failed to write to output file!");
Boxing output_file results in:
1438 | fn write_all(&mut self, mut buf: &[u8]) -> Result<()> {
| ---------
| |
| the method is available for `Box<Box<File>>` here
| the method is available for `Box<&mut Box<File>>` here
... and so on.
The issue is that I don't have std::io::Write imported. I'm not sure exactly what the best output would be.
I am using a recent 1.53 nightly build:
rustc 1.53.0-nightly (42816d61e 2021-04-24)
binary: rustc
commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c
commit-date: 2021-04-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.