Not sure if this is ok. The intent is to call `collect_garbage` only after the discarded state goes out of scope.