summaryrefslogtreecommitdiffstats
path: root/src/test/ui/fmt/format-string-error.rs
blob: eae4f3cb5479fc3ab5e602dc82fd15904e405696 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ignore-tidy-tab

fn main() {
    println!("{");
    //~^ ERROR invalid format string: expected `'}'` but string was terminated
    println!("{{}}");
    println!("}");
    //~^ ERROR invalid format string: unmatched `}` found
    let _ = format!("{_}", _ = 6usize);
    //~^ ERROR invalid format string: invalid argument name `_`
    let _ = format!("{a:_}", a = "", _ = 0);
    //~^ ERROR invalid format string: invalid argument name `_`
    let _ = format!("{a:._$}", a = "", _ = 0);
    //~^ ERROR invalid format string: invalid argument name `_`
    let _ = format!("{");
    //~^ ERROR invalid format string: expected `'}'` but string was terminated
    let _ = format!("}");
    //~^ ERROR invalid format string: unmatched `}` found
    let _ = format!("{\\}");
    //~^ ERROR invalid format string: expected `'}'`, found `'\\'`
    let _ = format!("\n\n\n{\n\n\n");
    //~^ ERROR invalid format string
    let _ = format!(r###"



	{"###);
    //~^ ERROR invalid format string
    let _ = format!(r###"



	{

"###);
    //~^ ERROR invalid format string
    let _ = format!(r###"



	}

"###);
    //~^^^ ERROR invalid format string
    let _ = format!(r###"



        }

"###);
    //~^^^ ERROR invalid format string: unmatched `}` found
    println!("{} {} {}", 1, 2);
    //~^ ERROR 3 positional arguments in format string, but there are 2 arguments
}