Skip to content

Commit 01adc82

Browse files
authored
Rollup merge of #140430 - nnethercote:hir-exhaustive, r=dtolnay
Improve test coverage of HIR pretty printing. Details in individual commits. r? `@dtolnay` try-job: test-various
2 parents 27d419a + 3f842e5 commit 01adc82

9 files changed

+1014
-104
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![feature(prelude_import)]
2+
#[prelude_import]
3+
use std::prelude::rust_2024::*;
4+
#[macro_use]
5+
extern crate std;
6+
//@ revisions: expanded hir
7+
//@[expanded]compile-flags: -Zunpretty=expanded
8+
//@[expanded]check-pass
9+
//@[hir]compile-flags: -Zunpretty=hir
10+
//@[hir]check-pass
11+
//@ edition:2024
12+
//@ only-x86_64
13+
//
14+
// asm parts of exhaustive.rs. Separate because we only run this on x86_64.
15+
16+
mod expressions {
17+
/// ExprKind::InlineAsm
18+
fn expr_inline_asm() {
19+
let x;
20+
asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}",
21+
inout(reg)
22+
x,
23+
out(reg)
24+
_);
25+
}
26+
}
27+
28+
mod items {
29+
/// ItemKind::GlobalAsm
30+
mod item_global_asm {
31+
global_asm! (".globl my_asm_func");
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#[prelude_import]
2+
use std::prelude::rust_2024::*;
3+
#[macro_use]
4+
extern crate std;
5+
//@ revisions: expanded hir
6+
//@[expanded]compile-flags: -Zunpretty=expanded
7+
//@[expanded]check-pass
8+
//@[hir]compile-flags: -Zunpretty=hir
9+
//@[hir]check-pass
10+
//@ edition:2024
11+
//@ only-x86_64
12+
//
13+
// asm parts of exhaustive.rs. Separate because we only run this on x86_64.
14+
15+
mod expressions {
16+
/// ExprKind::InlineAsm
17+
fn expr_inline_asm() {
18+
let x;
19+
asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}",
20+
inout(reg)
21+
x,
22+
out(reg)
23+
_);
24+
}
25+
}
26+
27+
mod items {
28+
/// ItemKind::GlobalAsm
29+
mod item_global_asm {/// ItemKind::GlobalAsm
30+
global_asm! (".globl my_asm_func") }
31+
}

tests/ui/unpretty/exhaustive-asm.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ revisions: expanded hir
2+
//@[expanded]compile-flags: -Zunpretty=expanded
3+
//@[expanded]check-pass
4+
//@[hir]compile-flags: -Zunpretty=hir
5+
//@[hir]check-pass
6+
//@ edition:2024
7+
//@ only-x86_64
8+
//
9+
// asm parts of exhaustive.rs. Separate because we only run this on x86_64.
10+
11+
mod expressions {
12+
/// ExprKind::InlineAsm
13+
fn expr_inline_asm() {
14+
let x;
15+
core::arch::asm!(
16+
"mov {tmp}, {x}",
17+
"shl {tmp}, 1",
18+
"shl {x}, 2",
19+
"add {x}, {tmp}",
20+
x = inout(reg) x,
21+
tmp = out(reg) _,
22+
);
23+
}
24+
}
25+
26+
mod items {
27+
/// ItemKind::GlobalAsm
28+
mod item_global_asm {
29+
core::arch::global_asm!(".globl my_asm_func");
30+
}
31+
}

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

+17-70
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() {
@@ -275,16 +286,8 @@ mod expressions {
275286
/// ExprKind::Ret
276287
fn expr_ret() { return; return true; }
277288

278-
/// ExprKind::InlineAsm
279-
fn expr_inline_asm() {
280-
let x;
281-
asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}",
282-
inout(reg)
283-
x,
284-
out(reg)
285-
_);
286-
}
287289

290+
/// ExprKind::InlineAsm: see exhaustive-asm.rs
288291
/// ExprKind::OffsetOf
289292
fn expr_offset_of() {
290293

@@ -300,65 +303,12 @@ mod expressions {
300303

301304

302305

303-
304-
305-
306-
307-
308-
309306
// ...
310307

311308

312309

313310

314311

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-
362312
// concat_idents is deprecated
363313

364314

@@ -450,10 +400,7 @@ mod items {
450400
unsafe extern "C++" {}
451401
unsafe extern "C" {}
452402
}
453-
/// ItemKind::GlobalAsm
454-
mod item_global_asm {
455-
global_asm! (".globl my_asm_func");
456-
}
403+
/// ItemKind::GlobalAsm: see exhaustive-asm.rs
457404
/// ItemKind::TyAlias
458405
mod item_ty_alias {
459406
pub type Type<'a> where T: 'a = T;

0 commit comments

Comments
 (0)