]> git.proxmox.com Git - rustc.git/blame - src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / const-generics / min_const_generics / const-expression-suggest-missing-braces.rs
CommitLineData
29967ef6
XL
1fn foo<const C: usize>() {}
2
3const BAR: usize = 42;
4
5fn a() {
6 foo::<BAR + 3>(); //~ ERROR expected one of
7}
8fn b() {
9 // FIXME(const_generics): these diagnostics are awful, because trait objects without `dyn` were
10 // a terrible mistake.
11 foo::<BAR + BAR>();
12 //~^ ERROR expected trait, found constant `BAR`
13 //~| ERROR expected trait, found constant `BAR`
fc512014 14 //~| ERROR type provided when a constant was expected
29967ef6 15 //~| WARN trait objects without an explicit `dyn` are deprecated
136023e0 16 //~| WARN this is accepted in the current edition
29967ef6
XL
17}
18fn c() {
19 foo::<3 + 3>(); //~ ERROR expressions must be enclosed in braces
20}
21fn d() {
22 foo::<BAR - 3>(); //~ ERROR expected one of
23}
24fn e() {
25 foo::<BAR - BAR>(); //~ ERROR expected one of
26}
27fn f() {
28 foo::<100 - BAR>(); //~ ERROR expressions must be enclosed in braces
29}
30fn g() {
31 foo::<bar<i32>()>(); //~ ERROR expected one of
32}
33fn h() {
34 foo::<bar::<i32>()>(); //~ ERROR expected one of
35}
36fn i() {
37 foo::<bar::<i32>() + BAR>(); //~ ERROR expected one of
38}
39fn j() {
40 foo::<bar::<i32>() - BAR>(); //~ ERROR expected one of
41}
42fn k() {
43 foo::<BAR - bar::<i32>()>(); //~ ERROR expected one of
44}
45fn l() {
46 foo::<BAR - bar::<i32>()>(); //~ ERROR expected one of
47}
48
49const fn bar<const C: usize>() -> usize {
50 C
51}
52
53fn main() {}