Skip to content

Commit 5695125

Browse files
committed
Auto merge of rust-lang#140430 - nnethercote:hir-exhaustive, r=<try>
Improve test coverage of HIR pretty printing. Details in individual commits. r? `@dtolnay` try-job: test-various
2 parents 6e23095 + 69e54ae commit 5695125

6 files changed

+930
-75
lines changed

tests/ui/unpretty/expanded-exhaustive.stdout renamed to tests/ui/unpretty/exhaustive.expanded.stdout

+15-57
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#![feature(prelude_import)]
2-
//@ compile-flags: -Zunpretty=expanded
2+
//@ revisions: expanded hir
3+
//@[expanded]compile-flags: -Zunpretty=expanded
4+
//@[expanded]check-pass
5+
//@[hir]compile-flags: -Zunpretty=hir
6+
//@[hir]check-fail
37
//@ edition:2024
4-
//@ check-pass
8+
9+
// Note: the HIR revision includes a `.stderr` file because there are some
10+
// errors that only occur once we get past the AST.
511

612
#![feature(auto_traits)]
713
#![feature(box_patterns)]
@@ -211,7 +217,10 @@ mod expressions {
211217
}
212218

213219
/// ExprKind::Await
214-
fn expr_await() { let fut; fut.await; }
220+
fn expr_await() {
221+
let fut;
222+
fut.await;
223+
}
215224

216225
/// ExprKind::TryBlock
217226
fn expr_try_block() { try {} try { return; } }
@@ -242,7 +251,9 @@ mod expressions {
242251
}
243252

244253
/// ExprKind::Underscore
245-
fn expr_underscore() { _; }
254+
fn expr_underscore() {
255+
_;
256+
}
246257

247258
/// ExprKind::Path
248259
fn expr_path() {
@@ -300,65 +311,12 @@ mod expressions {
300311

301312

302313

303-
304-
305-
306-
307-
308-
309314
// ...
310315

311316

312317

313318

314319

315-
316-
317-
318-
319-
320-
321-
322-
323-
324-
325-
326-
327-
328-
329-
330-
331-
332-
333-
334-
335-
336-
337-
338-
339-
340-
341-
342-
343-
344-
345-
346-
347-
348-
349-
350-
351-
352-
353-
354-
355-
356-
357-
358-
359-
360-
361-
362320
// concat_idents is deprecated
363321

364322

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
error[E0697]: closures cannot be static
2+
--> $DIR/exhaustive.rs:211:9
3+
|
4+
LL | static || value;
5+
| ^^^^^^^^^
6+
7+
error[E0697]: closures cannot be static
8+
--> $DIR/exhaustive.rs:212:9
9+
|
10+
LL | static move || value;
11+
| ^^^^^^^^^^^^^^
12+
13+
error[E0728]: `await` is only allowed inside `async` functions and blocks
14+
--> $DIR/exhaustive.rs:241:13
15+
|
16+
LL | fn expr_await() {
17+
| --------------- this is not `async`
18+
LL | let fut;
19+
LL | fut.await;
20+
| ^^^^^ only allowed inside `async` functions and blocks
21+
22+
error: in expressions, `_` can only be used on the left-hand side of an assignment
23+
--> $DIR/exhaustive.rs:290:9
24+
|
25+
LL | _;
26+
| ^ `_` not allowed here
27+
28+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
29+
--> $DIR/exhaustive.rs:300:9
30+
|
31+
LL | x::();
32+
| ^^^^^ only `Fn` traits may use parentheses
33+
34+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
35+
--> $DIR/exhaustive.rs:301:9
36+
|
37+
LL | x::(T, T) -> T;
38+
| ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
39+
|
40+
help: use angle brackets instead
41+
|
42+
LL - x::(T, T) -> T;
43+
LL + x::<T, T> -> T;
44+
|
45+
46+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
47+
--> $DIR/exhaustive.rs:302:9
48+
|
49+
LL | crate::() -> ()::expressions::() -> ()::expr_path;
50+
| ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
51+
52+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
53+
--> $DIR/exhaustive.rs:302:26
54+
|
55+
LL | crate::() -> ()::expressions::() -> ()::expr_path;
56+
| ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
57+
58+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
59+
--> $DIR/exhaustive.rs:305:9
60+
|
61+
LL | core::()::marker::()::PhantomData;
62+
| ^^^^^^^^ only `Fn` traits may use parentheses
63+
64+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
65+
--> $DIR/exhaustive.rs:305:19
66+
|
67+
LL | core::()::marker::()::PhantomData;
68+
| ^^^^^^^^^^ only `Fn` traits may use parentheses
69+
70+
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
71+
--> $DIR/exhaustive.rs:403:9
72+
|
73+
LL | yield;
74+
| ^^^^^
75+
|
76+
help: use `#[coroutine]` to make this closure a coroutine
77+
|
78+
LL | #[coroutine] fn expr_yield() {
79+
| ++++++++++++
80+
81+
error[E0703]: invalid ABI: found `C++`
82+
--> $DIR/exhaustive.rs:483:23
83+
|
84+
LL | unsafe extern "C++" {}
85+
| ^^^^^ invalid ABI
86+
|
87+
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
88+
89+
error: `..` patterns are not allowed here
90+
--> $DIR/exhaustive.rs:693:13
91+
|
92+
LL | let ..;
93+
| ^^
94+
|
95+
= note: only allowed in tuple, tuple struct, and slice patterns
96+
97+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
98+
--> $DIR/exhaustive.rs:808:16
99+
|
100+
LL | let _: T() -> !;
101+
| ^^^^^^^^ only `Fn` traits may use parentheses
102+
103+
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
104+
--> $DIR/exhaustive.rs:823:16
105+
|
106+
LL | let _: impl Send;
107+
| ^^^^^^^^^
108+
|
109+
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
110+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
111+
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
112+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
113+
114+
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
115+
--> $DIR/exhaustive.rs:824:16
116+
|
117+
LL | let _: impl Send + 'static;
118+
| ^^^^^^^^^^^^^^^^^^^
119+
|
120+
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
121+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
122+
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
123+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
124+
125+
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
126+
--> $DIR/exhaustive.rs:825:16
127+
|
128+
LL | let _: impl 'static + Send;
129+
| ^^^^^^^^^^^^^^^^^^^
130+
|
131+
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
132+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
133+
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
134+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
135+
136+
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
137+
--> $DIR/exhaustive.rs:826:16
138+
|
139+
LL | let _: impl ?Sized;
140+
| ^^^^^^^^^^^
141+
|
142+
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
143+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
144+
= help: add `#![feature(impl_trait_in_bindings)]` 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+
147+
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
148+
--> $DIR/exhaustive.rs:827:16
149+
|
150+
LL | let _: impl ~const Clone;
151+
| ^^^^^^^^^^^^^^^^^
152+
|
153+
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
154+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
155+
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
156+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
157+
158+
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
159+
--> $DIR/exhaustive.rs:828:16
160+
|
161+
LL | let _: impl for<'a> Send;
162+
| ^^^^^^^^^^^^^^^^^
163+
|
164+
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
165+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
166+
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
167+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
168+
169+
error: aborting due to 20 previous errors
170+
171+
Some errors have detailed explanations: E0214, E0562, E0697, E0703, E0728.
172+
For more information about an error, try `rustc --explain E0214`.

0 commit comments

Comments
 (0)