modfile: ensure that Cleanup removes extraneous entries after SetRequire

Updates golang/go#34822

Change-Id: If6981c8673c2843f5075d6d9a478bcf80f26e2fb
Reviewed-on: https://go-review.googlesource.com/c/mod/+/204821
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2 files changed