1 error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
2 --> $DIR/mut-borrow-needed-by-trait.rs:17:29
4 LL | let fp = BufWriter::new(fp);
5 | ^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
7 = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write`
8 note: required by `BufWriter::<W>::new`
9 --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
11 LL | pub fn new(inner: W) -> BufWriter<W> {
12 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
15 --> $DIR/mut-borrow-needed-by-trait.rs:17:14
17 LL | let fp = BufWriter::new(fp);
18 | ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
20 ::: $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
22 LL | pub struct BufWriter<W: Write> {
23 | ----- required by this bound in `BufWriter`
25 = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write`
27 error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn std::io::Write>`, but its trait bounds were not satisfied
28 --> $DIR/mut-borrow-needed-by-trait.rs:21:5
30 LL | writeln!(fp, "hello world").unwrap();
31 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `BufWriter<&dyn std::io::Write>` due to unsatisfied trait bounds
33 ::: $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
35 LL | pub struct BufWriter<W: Write> {
36 | ------------------------------ doesn't satisfy `BufWriter<&dyn std::io::Write>: std::io::Write`
38 = note: the following trait bounds were not satisfied:
39 `&dyn std::io::Write: std::io::Write`
40 which is required by `BufWriter<&dyn std::io::Write>: std::io::Write`
41 = note: this error originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info)
43 error: aborting due to 3 previous errors
45 Some errors have detailed explanations: E0277, E0599.
46 For more information about an error, try `rustc --explain E0277`.