]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/mut-borrow-needed-by-trait.rs
Rollup merge of #106919 - compiler-errors:underscore-typo-in-field-pat, r=jackh726
[rust.git] / tests / ui / suggestions / mut-borrow-needed-by-trait.rs
1 use std::env::args;
2 use std::fs::File;
3 use std::io::{stdout, Write, BufWriter};
4
5 fn main() {
6     let mut args = args();
7     let _ = args.next();
8     let dest = args.next();
9
10     let h1; let h2; let h3;
11
12     let fp: &dyn Write = match dest {
13         Some(path) => { h1 = File::create(path).unwrap(); &h1 },
14         None => { h2 = stdout(); h3 = h2.lock(); &h3 }
15     };
16
17     let fp = BufWriter::new(fp);
18     //~^ ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
19     //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
20
21     writeln!(fp, "hello world").unwrap(); //~ ERROR the method
22 }