summaryrefslogtreecommitdiffstats
path: root/tests/ui/typeck/issue-112007-leaked-writeln-macro-internals.fixed
blob: 29b6b8b868f564ca595480e2ce09f0eeb22a80dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// run-rustfix
#![allow(dead_code)]

// https://github.com/rust-lang/rust/issues/112007
fn bug_report<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
    if true {
        writeln!(w, "`;?` here ->")?;
    } else {
        return writeln!(w, "but not here");
        //~^ ERROR mismatched types
    };
    Ok(())
}

macro_rules! baz {
    ($w: expr) => {
        bar!($w)
    }
}

macro_rules! bar {
    ($w: expr) => {
        writeln!($w, "but not here")
        //~^ ERROR mismatched types
    }
}

fn foo<W: std::fmt::Write>(w: &mut W) -> std::fmt::Result {
    if true {
        writeln!(w, "`;?` here ->")?;
    } else {
        return baz!(w);
    };
    Ok(())
}

fn main() {}