Skip to content

Commit 243c2ea

Browse files
committed
Add regression test for rust-lang#127424
1 parent 8fb32ab commit 243c2ea

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// compile-fail
2+
// Regression test for issue #136335
3+
4+
fn bar() -> impl Into<
5+
[u8; {
6+
f_t(&*s); //~ ERROR cannot find function `f_t` in this scope
7+
8+
c(&*s); //~ ERROR cannot find function `c` in this scope
9+
10+
c(&*s); //~ ERROR cannot find function `c` in this scope
11+
12+
struct X;
13+
14+
c1(*x); //~ ERROR cannot find function `c1` in this scope
15+
let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x }; //~ ERROR `for<...>` binders for closures are experimental
16+
}],
17+
> {
18+
[99]
19+
}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
error[E0425]: cannot find function `f_t` in this scope
2+
--> $DIR/const-generics-closure.rs:6:9
3+
|
4+
LL | f_t(&*s);
5+
| ^^^ not found in this scope
6+
|
7+
help: you might be missing a const parameter
8+
|
9+
LL | fn bar<const f_t: /* Type */>() -> impl Into<
10+
| +++++++++++++++++++++++
11+
12+
error[E0425]: cannot find value `s` in this scope
13+
--> $DIR/const-generics-closure.rs:6:15
14+
|
15+
LL | f_t(&*s);
16+
| ^
17+
...
18+
LL | struct X;
19+
| --------- similarly named unit struct `X` defined here
20+
|
21+
help: a unit struct with a similar name exists
22+
|
23+
LL - f_t(&*s);
24+
LL + f_t(&*X);
25+
|
26+
help: you might be missing a const parameter
27+
|
28+
LL | fn bar<const s: /* Type */>() -> impl Into<
29+
| +++++++++++++++++++++
30+
31+
error[E0425]: cannot find function `c` in this scope
32+
--> $DIR/const-generics-closure.rs:8:9
33+
|
34+
LL | c(&*s);
35+
| ^
36+
...
37+
LL | struct X;
38+
| --------- similarly named unit struct `X` defined here
39+
|
40+
help: a unit struct with a similar name exists
41+
|
42+
LL - c(&*s);
43+
LL + X(&*s);
44+
|
45+
help: you might be missing a const parameter
46+
|
47+
LL | fn bar<const c: /* Type */>() -> impl Into<
48+
| +++++++++++++++++++++
49+
50+
error[E0425]: cannot find value `s` in this scope
51+
--> $DIR/const-generics-closure.rs:8:13
52+
|
53+
LL | c(&*s);
54+
| ^
55+
...
56+
LL | struct X;
57+
| --------- similarly named unit struct `X` defined here
58+
|
59+
help: a unit struct with a similar name exists
60+
|
61+
LL - c(&*s);
62+
LL + c(&*X);
63+
|
64+
help: you might be missing a const parameter
65+
|
66+
LL | fn bar<const s: /* Type */>() -> impl Into<
67+
| +++++++++++++++++++++
68+
69+
error[E0425]: cannot find function `c` in this scope
70+
--> $DIR/const-generics-closure.rs:10:9
71+
|
72+
LL | c(&*s);
73+
| ^
74+
LL |
75+
LL | struct X;
76+
| --------- similarly named unit struct `X` defined here
77+
|
78+
help: a unit struct with a similar name exists
79+
|
80+
LL - c(&*s);
81+
LL + X(&*s);
82+
|
83+
help: you might be missing a const parameter
84+
|
85+
LL | fn bar<const c: /* Type */>() -> impl Into<
86+
| +++++++++++++++++++++
87+
88+
error[E0425]: cannot find value `s` in this scope
89+
--> $DIR/const-generics-closure.rs:10:13
90+
|
91+
LL | c(&*s);
92+
| ^
93+
LL |
94+
LL | struct X;
95+
| --------- similarly named unit struct `X` defined here
96+
|
97+
help: a unit struct with a similar name exists
98+
|
99+
LL - c(&*s);
100+
LL + c(&*X);
101+
|
102+
help: you might be missing a const parameter
103+
|
104+
LL | fn bar<const s: /* Type */>() -> impl Into<
105+
| +++++++++++++++++++++
106+
107+
error[E0425]: cannot find function `c1` in this scope
108+
--> $DIR/const-generics-closure.rs:14:9
109+
|
110+
LL | c1(*x);
111+
| ^^ not found in this scope
112+
|
113+
help: you might be missing a const parameter
114+
|
115+
LL | fn bar<const c1: /* Type */>() -> impl Into<
116+
| ++++++++++++++++++++++
117+
118+
error[E0425]: cannot find value `x` in this scope
119+
--> $DIR/const-generics-closure.rs:14:13
120+
|
121+
LL | struct X;
122+
| --------- similarly named unit struct `X` defined here
123+
LL |
124+
LL | c1(*x);
125+
| ^
126+
|
127+
help: a unit struct with a similar name exists (notice the capitalization difference)
128+
|
129+
LL - c1(*x);
130+
LL + c1(*X);
131+
|
132+
help: you might be missing a const parameter
133+
|
134+
LL | fn bar<const x: /* Type */>() -> impl Into<
135+
| +++++++++++++++++++++
136+
137+
error[E0658]: `for<...>` binders for closures are experimental
138+
--> $DIR/const-generics-closure.rs:15:17
139+
|
140+
LL | ... let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x };
141+
| ^^^^^^^^^^^
142+
|
143+
= note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information
144+
= help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable
145+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
146+
= help: consider removing `for<...>`
147+
148+
error[E0601]: `main` function not found in crate `const_generics_closure`
149+
--> $DIR/const-generics-closure.rs:19:2
150+
|
151+
LL | }
152+
| ^ consider adding a `main` function to `$DIR/const-generics-closure.rs`
153+
154+
error[E0308]: mismatched types
155+
--> $DIR/const-generics-closure.rs:5:10
156+
|
157+
LL | [u8; {
158+
| __________^
159+
LL | | f_t(&*s);
160+
LL | |
161+
LL | | c(&*s);
162+
... |
163+
LL | | let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x };
164+
LL | | }],
165+
| |_____^ expected `usize`, found `()`
166+
167+
error: aborting due to 11 previous errors
168+
169+
Some errors have detailed explanations: E0308, E0425, E0601, E0658.
170+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)