Skip to content

Commit 2b286f9

Browse files
authored
Unrolled build for rust-lang#137035
Rollup merge of rust-lang#137035 - compiler-errors:eagerly-mono-closures-after-norm, r=saethlin Normalize closure instance before eagerly monomorphizing it We were monomorphizing two versions of the closure (or in the original issue, coroutine) -- one with normalized captures and one with unnormalized captures. This led to a symbol collision. Fixes rust-lang#137009 r? `@saethlin` or reassign
2 parents fc147b4 + 2ada9cc commit 2b286f9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

compiler/rustc_monomorphize/src/collector.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,13 @@ impl<'v> RootCollector<'_, 'v> {
15091509
}
15101510
_ => unreachable!(),
15111511
};
1512+
let Ok(instance) = self.tcx.try_normalize_erasing_regions(
1513+
ty::TypingEnv::fully_monomorphized(),
1514+
instance,
1515+
) else {
1516+
// Don't ICE on an impossible-to-normalize closure.
1517+
return;
1518+
};
15121519
let mono_item = create_fn_mono_item(self.tcx, instance, DUMMY_SP);
15131520
if mono_item.node.is_instantiable(self.tcx) {
15141521
self.output.push(mono_item);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: -Clink-dead-code -Csymbol-mangling-version=v0
2+
//@ build-pass
3+
4+
// Ensure that when eagerly collecting `test::{closure#0}`, we don't try
5+
// collecting an unnormalized version of the closure (specifically its
6+
// upvars), since the closure captures the RPIT `opaque::{opaque#0}`.
7+
8+
fn opaque() -> impl Sized {}
9+
10+
fn test() -> impl FnOnce() {
11+
let opaque = opaque();
12+
move || {
13+
let opaque = opaque;
14+
}
15+
}
16+
17+
fn main() {
18+
test()();
19+
}

0 commit comments

Comments
 (0)