Skip to content

Commit 5f03328

Browse files
authored
Rollup merge of #147442 - folkertdev:thir-print-c-variadic, r=fmease
c-variadic: fix thir-print for `...` without a pattern tracking issue: #44930 fixes #147409 r? `@fmease`
2 parents 883032b + 0a3f1d5 commit 5f03328

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

compiler/rustc_mir_build/src/thir/print.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,9 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
689689
print_indented!(self, "kind: PatKind {", depth_lvl);
690690

691691
match pat_kind {
692-
PatKind::Missing => unreachable!(),
692+
PatKind::Missing => {
693+
print_indented!(self, "Missing", depth_lvl + 1);
694+
}
693695
PatKind::Wild => {
694696
print_indented!(self, "Wild", depth_lvl + 1);
695697
}

tests/ui/thir-print/c-variadic.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ compile-flags: -Zunpretty=thir-tree --crate-type=lib
2+
//@ check-pass
3+
#![feature(c_variadic)]
4+
5+
// The `...` argument uses `PatKind::Missing`.
6+
unsafe extern "C" fn foo(_: i32, ...) {}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
DefId(0:3 ~ c_variadic[a5de]::foo):
2+
params: [
3+
Param {
4+
ty: i32
5+
ty_span: Some($DIR/c-variadic.rs:6:29: 6:32 (#0))
6+
self_kind: None
7+
hir_id: Some(HirId(DefId(0:3 ~ c_variadic[a5de]::foo).1))
8+
param: Some(
9+
Pat: {
10+
ty: i32
11+
span: $DIR/c-variadic.rs:6:26: 6:27 (#0)
12+
kind: PatKind {
13+
Wild
14+
}
15+
}
16+
)
17+
}
18+
Param {
19+
ty: std::ffi::VaListImpl<'{erased}>
20+
ty_span: None
21+
self_kind: None
22+
hir_id: Some(HirId(DefId(0:3 ~ c_variadic[a5de]::foo).3))
23+
param: Some(
24+
Pat: {
25+
ty: std::ffi::VaListImpl<'{erased}>
26+
span: $DIR/c-variadic.rs:6:34: 6:37 (#0)
27+
kind: PatKind {
28+
Missing
29+
}
30+
}
31+
)
32+
}
33+
]
34+
body:
35+
Expr {
36+
ty: ()
37+
temp_lifetime: TempLifetime { temp_lifetime: Some(Node(6)), backwards_incompatible: None }
38+
span: $DIR/c-variadic.rs:6:39: 6:41 (#0)
39+
kind:
40+
Scope {
41+
region_scope: Node(6)
42+
lint_level: Explicit(HirId(DefId(0:3 ~ c_variadic[a5de]::foo).6))
43+
value:
44+
Expr {
45+
ty: ()
46+
temp_lifetime: TempLifetime { temp_lifetime: Some(Node(6)), backwards_incompatible: None }
47+
span: $DIR/c-variadic.rs:6:39: 6:41 (#0)
48+
kind:
49+
Block {
50+
targeted_by_break: false
51+
span: $DIR/c-variadic.rs:6:39: 6:41 (#0)
52+
region_scope: Node(5)
53+
safety_mode: Safe
54+
stmts: []
55+
expr: []
56+
}
57+
}
58+
}
59+
}
60+
61+

0 commit comments

Comments
 (0)