remove unused variables

backport from https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/45029