summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/mut-borrow-needed-by-trait.rs
blob: 66e1e77c905e02e4b564f4200fd72fabde0dd8e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::env::args;
use std::fs::File;
use std::io::{stdout, Write, BufWriter};

fn main() {
    let mut args = args();
    let _ = args.next();
    let dest = args.next();

    let h1; let h2; let h3;

    let fp: &dyn Write = match dest {
        Some(path) => { h1 = File::create(path).unwrap(); &h1 },
        None => { h2 = stdout(); h3 = h2.lock(); &h3 }
    };

    let fp = BufWriter::new(fp);
    //~^ ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
    //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied

    writeln!(fp, "hello world").unwrap(); //~ ERROR the method
}