Normalize closure instance before eagerly monomorphizing it
This commit is contained in:
parent
a567209daa
commit
2ada9ccb7d
2 changed files with 26 additions and 0 deletions
|
@ -1509,6 +1509,13 @@ impl<'v> RootCollector<'_, 'v> {
|
|||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let Ok(instance) = self.tcx.try_normalize_erasing_regions(
|
||||
ty::TypingEnv::fully_monomorphized(),
|
||||
instance,
|
||||
) else {
|
||||
// Don't ICE on an impossible-to-normalize closure.
|
||||
return;
|
||||
};
|
||||
let mono_item = create_fn_mono_item(self.tcx, instance, DUMMY_SP);
|
||||
if mono_item.node.is_instantiable(self.tcx) {
|
||||
self.output.push(mono_item);
|
||||
|
|
19
tests/ui/closures/eager-mono-with-normalizable-upvars.rs
Normal file
19
tests/ui/closures/eager-mono-with-normalizable-upvars.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
//@ compile-flags: -Clink-dead-code -Csymbol-mangling-version=v0
|
||||
//@ build-pass
|
||||
|
||||
// Ensure that when eagerly collecting `test::{closure#0}`, we don't try
|
||||
// collecting an unnormalized version of the closure (specifically its
|
||||
// upvars), since the closure captures the RPIT `opaque::{opaque#0}`.
|
||||
|
||||
fn opaque() -> impl Sized {}
|
||||
|
||||
fn test() -> impl FnOnce() {
|
||||
let opaque = opaque();
|
||||
move || {
|
||||
let opaque = opaque;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test()();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue