Skip to content

Commit f54e442

Browse files
committed
Merge remote-tracking branch 'origin/master' into codex/static-vtable-alloc-fallback
2 parents 7c8aa5c + 10a3728 commit f54e442

30 files changed

Lines changed: 161 additions & 5 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rustup-clear-toolchain:
1515
rustup override unset --nonexistent
1616
rustup toolchain uninstall "${TOOLCHAIN_NAME}"
1717

18-
TESTDIR=$(CURDIR)/tests/integration/programs
18+
TESTDIR=tests/integration/programs
1919

2020
.PHONY: integration-test
2121
integration-test: TESTS ?= $(shell find $(TESTDIR) -type f -name "*.rs")

src/printer/ty_visitor.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//! type trees, recording each relevant type along with its `TyKind` and
55
//! `LayoutShape`. These collected types are later transformed into
66
//! [`TypeMetadata`](super::schema::TypeMetadata) entries in the final output.
7-
//! Note that some special kinds (closures, function definitions/pointers, and
8-
//! coroutine witnesses) are traversed only to gather the types they reference
9-
//! and are not themselves stored as entries in the type map.
7+
//! Note that some special kinds (function definitions/pointers and coroutine
8+
//! witnesses) are traversed only to gather the types they reference and are
9+
//! not themselves stored as entries in the type map.
1010
1111
extern crate rustc_middle;
1212
extern crate rustc_smir;
@@ -63,7 +63,13 @@ impl Visitor for TyCollector<'_> {
6363
self.resolved.insert(*ty);
6464
let instance =
6565
Instance::resolve_closure(def, args, stable_mir::ty::ClosureKind::Fn).unwrap();
66-
self.visit_instance(instance)
66+
let control = self.visit_instance(instance);
67+
// Mirror other branches: record closure Ty only when traversal succeeds.
68+
if matches!(control, ControlFlow::Continue(_)) {
69+
let maybe_layout_shape = ty.layout().ok().map(|layout| layout.shape());
70+
self.types.insert(*ty, (ty.kind(), maybe_layout_shape));
71+
}
72+
control
6773
}
6874
// Break on CoroutineWitnesses, because they aren't expected when getting the layout
6975
TyKind::RigidTy(RigidTy::CoroutineWitness(..)) => {

tests/integration/programs/assert_eq.smir.json.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5745,6 +5745,11 @@
57455745
"pointee_type": "elided"
57465746
}
57475747
}
5748+
],
5749+
[
5750+
{
5751+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
5752+
}
57485753
]
57495754
]
57505755
}

tests/integration/programs/binop.smir.json.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10113,6 +10113,11 @@
1011310113
"pointee_type": "elided"
1011410114
}
1011510115
}
10116+
],
10117+
[
10118+
{
10119+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
10120+
}
1011610121
]
1011710122
]
1011810123
}

tests/integration/programs/char-trivial.smir.json.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,11 @@
21742174
"pointee_type": "elided"
21752175
}
21762176
}
2177+
],
2178+
[
2179+
{
2180+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
2181+
}
21772182
]
21782183
]
21792184
}

tests/integration/programs/closure-args.smir.json.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,16 @@
26122612
"pointee_type": "elided"
26132613
}
26142614
}
2615+
],
2616+
[
2617+
{
2618+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
2619+
}
2620+
],
2621+
[
2622+
{
2623+
"FunType": "{closure@tests/integration/programs/closure-args.rs:2:15: 2:28}"
2624+
}
26152625
]
26162626
]
26172627
}

tests/integration/programs/closure-no-args.smir.json.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,16 @@
23072307
"pointee_type": "elided"
23082308
}
23092309
}
2310+
],
2311+
[
2312+
{
2313+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
2314+
}
2315+
],
2316+
[
2317+
{
2318+
"FunType": "{closure@tests/integration/programs/closure-no-args.rs:2:15: 2:24}"
2319+
}
23102320
]
23112321
]
23122322
}

tests/integration/programs/const-arithm-simple.smir.json.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,11 @@
24272427
"pointee_type": "elided"
24282428
}
24292429
}
2430+
],
2431+
[
2432+
{
2433+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
2434+
}
24302435
]
24312436
]
24322437
}

tests/integration/programs/div.smir.json.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,11 @@
25282528
"pointee_type": "elided"
25292529
}
25302530
}
2531+
],
2532+
[
2533+
{
2534+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
2535+
}
25312536
]
25322537
]
25332538
}

tests/integration/programs/double-ref-deref.smir.json.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,11 @@
23502350
"pointee_type": "elided"
23512351
}
23522352
}
2353+
],
2354+
[
2355+
{
2356+
"FunType": "{closure@std::rt::lang_start<()>::{closure#0}}"
2357+
}
23532358
]
23542359
]
23552360
}

0 commit comments

Comments
 (0)