only reference count closures if the captured values are RC'd

This commit is contained in:
Folkert 2021-02-16 22:00:15 +01:00
parent bc0a6f24ef
commit c788965182

View file

@ -602,7 +602,10 @@ impl<'a> Context<'a> {
consume: bool, consume: bool,
) -> Self { ) -> Self {
// can this type be reference-counted at runtime? // can this type be reference-counted at runtime?
let reference = layout.contains_refcounted(); let reference = match layout {
Layout::Closure(_, closure, _) => closure.layout.contains_refcounted(),
_ => layout.contains_refcounted(),
};
let info = VarInfo { let info = VarInfo {
reference, reference,